VBox: How to use a raw disk image file in VirtualBox

Method 1: Access disk image dsk.img via loop device. We have a disk image, we just need to convince VirtualBox to access it as a raw block device. This can be done with losetup. Step 1: Associate the disk image with a loop device. $ losetup /dev/loop0 /path/to/dsk.img Step 2: Create a virtual disk and register it with VirtualBox. $ VBoxManage internalcommands createrawvmdk -filename /path/to/dsk.vmdk -rawdisk /dev/loop0 -register Step 3: Attach the virtual disk to a virtual machine and start it. The virtual machine will access the virtual disk, which now is linked to /dev/loop0, which in turn is linked to the disk image file. Warning: In order for this to work, VirtualBox needs to be able to access the loop device you created. This means either adding your user to a group that has access to disks (on my Ubuntu machine, this is group 'disk'), or you need to run VirtualBox as root. Method 2: Convert the disk image to a format VirtualBox understands disk access should be faster with this method Step 1: Convert the raw image file dsk.img to VirtualBox's disk formats: VBoxManage convertfromraw /path/to/dsk.img /path/to/dsk.vdi --format vdi You can also use vmdk or vdh as valid values to the format parameter. I don't know which one is the best, but vdi is the default in my VirtualBox setup so I'll stick to that. Step 2: Add the vdi image to your virtual machine and start it. The obvious disadvantages to this method is that all the data in the image file will be copied to the virtual disk image. This takes some time and you will need, at least temporarily, twice the disk space. Step 3 (optional): Convert the virtual disk image back to raw format. In case you do changes to the virtual disk and you want to have it in a raw image so you can write it back to a real device, there is a corresponding command: VBoxManage internalcommands converttoraw /path/to/dsk.vdi /path/to/dsk.img