VirtualBox can boot virtual machines from USB flash drives, allowing you to boot a live Linux system or install an operating system from a bootable USB device. This option is well-hidden.
As this option isn’t exposed in the interface and requires some digging, it may not always work perfectly. It worked fine with Ubuntu 14.04 on a Windows host, but don’t be surprised if you encounter problems with some configurations.
Boot From USB on a Windows Host
We’ll be using the hidden feature in VirtualBox that allows raw access to drives. This feature isn’t exposed in VirtualBox’s interface, but is part of the VBoxManage command. Be sure you have VirtualBox installed on your system before beginning this process.
First, connect the USB drive containing the operating system you want to boot to your computer. Press Windows Key + R, type diskmgmt.msc into the Run dialog, and press Enter to open the Disk Management window.
Look for the USB drive in the Disk Management window and note its disk number. For example, here the USB drive is Disk 1.
First, close any open VirtualBox windows.
Next, open a Command Prompt as Administrator. On Windows 7, open the Start menu, search for Command Prompt, right-click the Command Prompt shortcut, and select Run as administrator. On Windows 8 or 8.1, press Windows Key + X and click Command Prompt (Administrator).
Type the following command into the Command Prompt window and press Enter. This command will change to VirtualBox’s default installation directory. If you installed VirtualBox to a custom directory, you’ll need to replace the directory path in the command with the path to your own VirtualBox directory:
Type the following command into the Command Prompt window, replacing # with the number of the disk you found above, and press Enter.
VBoxManage internalcommands createrawvmdk -filename C:\usb.vmdk -rawdisk \\.\PhysicalDrive#
You can replace C:\usb.vmdk with any file path you want. This command creates a virtual machine disk (VMDK) file that points to the physical drive you select. When you load the VMDK file as a drive in VirtualBox, VirtualBox will actually access the physical device.
Next, open VirtualBox as Administrator. Right-click the VirtualBox shortcut and select Run as administrator. VirtualBox can only access raw disk devices with administrator privileges.
Create a new virtual machine by clicking the New button and go through the wizard. Select the operating system on the USB drive when prompted.
When you’re asked to select a hard disk, select Use an existing virtual hard drive file, click the button to browse for the file, and navigate to it — that’s C:\usb.vmdk if you didn’t select your own path.
Boot the virtual machine and it should boot the operating system from your USB drive, just as if you were booting it on normal computer.
Note that the USB device must be the first hard disk in your virtual machine or VirtualBox won’t boot from it. In other words, you can’t simply create a standard virtual machine and attach the USB device later.
If you want to install an operating system from the USB drive, you’ll need to add a hard disk later from within the virtual machine’s settings window. Be sure the USB drive is the first disk in the list.
Linux and Mac Hosts
The process is basically the same on Linux and Mac host systems. You’ll need to use the same sort of VBoxManage command to create a file representing the raw disk, but you’ll need to specify the path to the disk device on your Linux or Mac system.
The Open Foam wiki has some tips and workarounds that may help you adapt this process to Linux or Mac hosts. The Using a raw host hard disk from a guest section in VirtualBox’s official documentation may also help.
Booting from a standard ISO file is still the most well-supported way to install — or just boot — an operating system in VirtualBox or other virtual machine programs. If possible, you should download ISO files and use them instead of fiddling with USB drives.
If you’re using VMware instead of VirtualBox, try using the Plop Boot Manger to boot from USB in VMware.