VirtualBox is one of the most popular solutions used to manage and run virtual machines. Just like a real computer, it needs a source to boot from. The most straightforward way to run a guest operating system in a virtualized environment is to download a bootable ISO image and then mount it in a virtual CD/DVD drive.
Sometimes, though, you may prefer an alternative. For example, you can boot directly from a USB stick. Since it’s easy to install a Linux distribution on a USB drive, this method allows you to keep an operating system in your pocket and run it anywhere you have access to a virtual machine.
Find the Disk Number Associated with Your USB Drive
Modern editions of Windows associate a number to each disk they can access. This number is needed to use in a subsequent command.
1. Insert your USB drive into a free slot. In Windows 10 you can access Disk Management by right-clicking on the Start Menu.
To open this utility in older versions of Windows, click on the Start Menu and launch a Run dialog.
In this dialog type
diskmgmt.msc and press Enter.
Make note of the disk number associated with your USB drive. For example, in the previous picture the disk number is “1.”
Create a Virtual Raw Disk Associated with Your USB Drive
VirtualBox gives you the option to create a new virtual disk when you launch a new virtual machine. The information you store on this disk gets mapped to a file somewhere on your real storage device. Unfortunately, the graphical user interface doesn’t let you map a virtual disk directly to a real storage device or partition. However, there is a command-line utility, included with the application, that lets you do that.
Open a command prompt with administrator privileges. Click on the Start Menu, type
cmd, right-click on “Command Prompt” and “Run as administrator.”
Change directory to the path where you have installed VirtualBox. By default, this is “C:\Program Files\Oracle\VirtualBox.” If you installed to another path, you may have to modify the next command:
Remember the disk number associated with your USB drive, and change the last digit in the following command, if necessary:
For example, if you have an SSD drive in your system and a hard-drive, then the number of your USB disk might be “2” instead of “1,” so the command should become:
A file named “usbdrive.vmdk” is now saved on your desktop. You will use this in the next step.
Add Your USB Drive to the Virtual Machine
To be able to use raw devices as virtual disks, VirtualBox needs to run with administrator privileges. Click the Start Menu, type “virtualbox,” right-click the application and “Run as administrator.”
Click on “New” to create a new virtual machine.
In the dialog that opens, at the bottom of the window, you will notice the “Hard disk” section. Select “Use an existing virtual hard disk file,” and click the icon that has been highlighted in the next picture. Browse to your desktop, and select the file named “usbdrive.”
In the following picture you can see a Windows installation kit booting directly from an USB drive in a virtual machine.
Potential Problems and Solutions
Keep in mind that every time you want to boot from your USB drive, you have to run VirtualBox with administrator privileges.
On some motherboards, virtualization features are disabled by default. Depending on your CPU, you will have to enable either VT-x on Intel processors or AMD-V on AMD processors. You will find these options in your BIOS or UEFI settings. If VirtualBox only shows you 32-bit versions of operating systems it can host, it’s a sign that these features are inactive. If your CPU supports VT-d or AMD IOMMU equivalent, enable that too, as it may help with performance when booting from a USB device.
Having trouble with this setup? Let us know in the comments. Someone else who ran into the same issue might be able to help.