How to Convert a Virtual Machine VHD VDI into a Bootable USB. The following covers the process of turning VirtualBox "VHD" (Virtual Hard Disk) Images or "VDI" (Virtual Disk) Images into Bootable Physical Disks. Aka: "Copy VHD to Disk". This is extremely useful for situations when you would like to clone your VirtualBox Machine onto a real device and run them as real systems.
Those once virtual machines containing full operating systems can then be booted and run natively from an external USB drive. Resulting in fully installed Linux or Windows systems booted from an external USB device, instead of VirtualBox.
Table of Contents
Convert a VirtualBox VDI or VHD Image to a Physical Disk
The following sections assume you are up and running from Windows and your Flash Drive is already inserted.
First you will need to Create a Raw Image from the VDI or VHD File. To do this;
1. Open a Windows Command Prompt.
2. From the Command Line, type
3. Then to convert a .vdi or .vhd file to an disk .img file. Assuming your files are stored in the .VirtualBox directory, type the following as a single line.
(replacing filename with your actual file name, and vdi with vhd if the file is a vhd)
VBoxManage internalcommands converttoraw "%USERPROFILE%\.VirtualBox\filename.vdi" "%USERPROFILE%\.VirtualBox\filename.img"
Or, if your files are stored in the VirtualBox VMs directory, use the following command string.
VBoxManage internalcommands converttoraw "%USERPROFILE%\VirtualBox VMs\filepath\filename.vdi" "%USERPROFILE%\VirtualBox VMs\filepath\filename.img"
To keep things simple, we will use Win32 Disk Imager;
1. Download, install, then launch Win32 Disk Imager (as Administrator).
2. Using this Image Writing tool is fairly simple. 1.) Select the disk image you created earlier. 2.) Select your USB Device. 3.) Then click Write.
Warning: All content will be overwritten!
You should now have a USB bootable clone of your VirtualBox Virtual Machine. To test that it works, reboot your PC, select the External drive as the Boot Device from the BIOS or UEFI boot menu, then boot. You can also try Booting a flash drive from VirtualBox.
Convert a VirtualBox VDI or VHD to Physical Disk (Linux)
The following section covers how to perform the same task from a running Linux with VirtualBox installed. I used Ubuntu in this example.
1. Open a terminal Ctrl+Alt+T
2. From the terminal, change to the directory where your .vdi or .vhd is stored. For example, replacing with your actual path, type;
cd /home/ubuntu/'VirtualBox VMs'/path
3. Then type the following to convert the Virtual Machine to a Raw Image. Replacing filename with your actual filename, and vdi with vhd if necessary.
sudo VBoxManage internalcommands converttoraw filename.vdi filename.img
4. Next type the following and note which device belongs to your USB drive.
5. Then use DD (Disk Dump) to raw write the image back to your USB device by typing the following. Again replacing filename with your file and sdX with your actual device.
Warning: All content on the drive will be overwritten!
dd if=filename.img of=/dev/sdX status=progress
This concludes the process to Convert Virtual Machine to Bootable USB.
If you found this tutorial useful, you might also be interested in learning how to Boot from a USB in VirtualBox