Convert a VDI or VHD Virtual Machine into a bootable USB drive. Directly boot from VHD or VDI files; Turning VirtualBox "VHD" (Virtual Hard Disk) Images or "VDI" (Virtual Disk) Images into a bootable physical disk. Copy VHD to Disk to make a USB Virtual Machine.
This can be extremely useful for situations when you would like to clone your VirtualBox Machine onto a real device and run them as real systems.
Why Convert a Virtual Machine into a Bootable USB?
There are several compelling reasons why you might want to take your VirtualBox VDI or VHD image and convert it into a bootable USB drive:
- Portability: By converting a virtual machine into a bootable USB, you gain the ability to take your entire operating system, applications, and files on the go. This can be especially useful if you frequently work on different computers or need access to a specific environment anywhere.
- Testing on Real Hardware: Virtual machines are great for testing in a controlled environment, but sometimes you need to see how your OS and applications perform on actual hardware. Booting a VHD or VDI from a USB drive lets you experience your virtual setup on real physical machines without the need for reinstallation.
- Disaster Recovery: Having a bootable USB drive with a fully configured operating system can serve as a powerful recovery tool. If your primary system fails, you can use the USB drive to boot into your virtual machine’s environment, access your files, or troubleshoot your computer.
- Multi-OS Setup: If you use multiple operating systems or configurations in VirtualBox, turning each one into a bootable USB drive allows you to have a portable version of each system. You can carry them around, boot into whichever system you need, and even boot into multiple OSes on different machines.
- Security and Isolation: For secure tasks or privacy-conscious computing, booting from a USB drive ensures that no traces of your activity are left on the host machine. This is particularly useful for testing, privacy-focused browsing, or using temporary operating systems without installing them on the host device.
This process opens up a whole new level of flexibility for managing your systems and virtual environments in a way that’s far more portable and practical than running them solely inside a virtual machine.
Make a USB Boot from VHD (VirtualBox Image)
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 a USB thumb drive or other external device, instead of VirtualBox.
Convert VirtualBox Image to Physical Disk (Windows)
The following assumes that 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:
- Open a Windows Command Prompt.
- From the Command Line, type
cd %programfiles%\oracle\virtualbox
- 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"
Next, you need to raw data write the file to the external USB drive. To do this, you can use tools like Balena Etcher, Win32 Disk Imager, or even dd. Here we will use Win32 Disk Imager as using this image writing tool is fairly simple:
- Download win32 Disk Imager, install and then run it (as Administrator).
- (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, making sure you can USB boot from VHD:
- Begin to reboot your PC.
- Within the first few seconds (during system post), enter your BIOS or UEFI via your motherboard manufacturer hotkey.
- From your BIOS/UEFI boot options, set your external thumb drive as the first boot device.
- Save your changes (using the F10 key) and let the system startup from your USB.
Pro Tip: You could also try Booting a flash drive from VirtualBox, which can be accomplished without rebooting.
Convert VirtualBox Image to Physical Disk (Linux)
The following section covers how to perform the same task from a running Linux with VirtualBox installed. Again, I used Ubuntu in this example.
- Open a terminal Ctrl+Alt+T
- 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
- 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
- Next type the following and note which device belongs to your USB drive.
fdisk -l
- 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
Final Thoughts
With the process of converting a Virtual Machine into a bootable USB complete, you'll now be able to boot from VHD or VDI files on physical hardware. This offers a new level of flexibility and portability for your virtual environments. If you found this USB Virtual Machine tutorial helpful, you might also be interested in learning how to Boot from a USB in VirtualBox, which can further enhance your experience with portable OS setups and testing.