How to attach raw disk images in VirtualBox
PostedWhen 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:
- Ensure VirtualBox is not running.
- Find and open
VirtualBox.xmlin your favourite plain text editor. Its in$HOME/.config/VirtualBox,%USERPROFILE%/.VirtualBox, or$HOME/Library/VirtualBox. - Go to
<VirtualBox>→<Global>→<MachineRegistry>→<HardDisks>while creating entries that dont exists. - Create a new
<HardDisk>entry with attributesuuidwith a fresh UUID,locationwith the path to your image, andformatwithraw— see example below. - 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.