Profile picture

about me

Hello! I’m Kona Arctic. I’m an arctic fox (Vulpes lagopus) with interests in technology (old and new), and literature. I love interacting online for as much as my paws allows (which sadly isn’t much). Furry and therianthrope.

How to attach raw disk images in VirtualBox

Posted

When working with virtual machines Kona prefers raw disk images. However, VirtualBox does not allow attaching raw disk images to virtual machines in its graphical user interface — trying to do so produces an error.

Could not get the storage format of the medium ‘' (VERR_NOT_SUPPORTED).

If you think youre clever you might fruitlessly try vboxmanage createmedium disk --format=VMDK --variant=RawDisk --property=RawDrive=…, but this doesnt work either. If theres a way to attach raw disk images using VirtualBox’s command line interface Kona is yet to find it. As a workaround user mpack in a forum post suggests manually creating and using a VMDK descriptor.

Since at least VirtualBox 7.2.4 there is a easier and more direct way:

  1. Ensure VirtualBox is not running.
  2. Find and open VirtualBox.xml in your favourite plain text editor. Its in $HOME/.config/VirtualBox, %USERPROFILE%/.VirtualBox, or $HOME/Library/VirtualBox.
  3. Go to <VirtualBox><Global><MachineRegistry><HardDisks> while creating entries that dont exists.
  4. Create a new <HardDisk> entry with attributes uuid with a fresh UUID, location with the path to your image, and format with raw — see example below.
  5. Open VirtualBox’s graphical user interface and attach your raw disk image to your virtual machine.
<MediaRegistry>
	<HardDisks>
		<HardDisk 
			uuid="{00000000-0000-0000-0000-000000000000}" 
			location="<path to image>" 
			format="raw" 
			type="Normal"
		/>
	</HardDisks>
<MediaRegistry>

Why this is allowed nobody knows. If you do know please mention Kona on the fox’s Mastodon.