How to Boot an OS from a USB Drive in VirtualBox

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.

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.

virtualbox-right-click-windows-start-menu

To open this utility in older versions of Windows, click on the Start Menu and launch a Run dialog.

virtualbox-windows-run-menu

In this dialog type diskmgmt.msc and press Enter.

virtualbox-windows-disk-management

Make note of the disk number associated with your USB drive. For example, in the previous picture the disk number is “1.”

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.”

virtualbox-command-prompt-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:

virtualbox-vboxmanage-command-create-rawdisk-file

A file named “usbdrive.vmdk” is now saved on your desktop. You will use this in the next step.

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.”

virtualbox-run-with-administrator-privileges

Click on “New” to create a new virtual machine.

virtualbox-main-window-2

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.”

virtualbox-new-machine-use-virtual-disk-file

In the following picture you can see a Windows installation kit booting directly from an USB drive in a virtual machine.

virtualbox-booting-windows-setup-from-usb

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.

2 comments

  1. Thanks for the article…I didn’t know that could be done; I thought you could only boot from an ISO file.

    However, it should be noted that most of the required backslashes (“\”) have been removed from the text portions of the article, although they do show properly in the screenshot of the command prompt window.

  2. Thank you Rick. It was OK in the original form of the article. It seems that somewhere in the editing process, some of the tools that format the text (probably the WYSIWYG GUI editor) cut out those backslashes.

    Will be solved. Thank you again for letting us know.

Leave a Comment

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.

Sponsored Stories