How to Boot From a USB Flash Drive in VirtualBox

How to boot from a USB Flash Drive in VirtualBox. This process will allow you to run your Portable Linux from the USB Flash Drive or external hard drive while still running from a Windows, Linux, or Mac OS X Host. By default VirtualBox does not support USB Boot. However this is easily attainable by mapping a virtual machine (.vmdk file) to the USB Drive.

VirtualBox Website: https://www.virtualbox.org

Boot a USB Flash Drive from VirtualBox (Windows Host)

  1. Download and Install VirtualBox (Install to the default path)
  2. Click Start > Run Type diskmgmt.msc and click OK (In Vista/Win7 use the Start > Search Box)
    (1) Locate your USB Disk #
    Diskmgmt.msc
  3. Open a command prompt cmd.exe (run as admin in Vista/Win7)
  4. Type cd %programfiles%\oracle\virtualbox
  5. Type the following (replace # with your USB Disk number from step 2)
    VBoxManage internalcommands createrawvmdk -filename "%USERPROFILE%"\.VirtualBox\usb.vmdk -rawdisk \\.\PhysicalDrive#
  6. Start VirtualBox (run as admin in Vista/Win7) and create a New Virtual Machine Create a New Virtual Machine
  7. When prompted for a Virtual Hard Disk, tick use existing hard disk and select usb.vmdk Select Existing Virtual Disk usb.vmdk
  8. Once you've finished creating your New Virtual Machine, click StartStart VirtualBox

If all goes well, VirtualBox should now be running the Linux version installed on your USB device emulated from within Windows.

Boot from a USB Flash Drive in VirtualBox (Linux Host)

The following was performed from a running Ubuntu Operating environment. The same should work for most Debian/Ubuntu Linux based environments.

  1. Open a Terminal and type sudo apt install virtualbox
    (Or you can visit the virtualbox download section for other options)
  2. Type sudo fdisk -l (note which device is your USB drive I.E. /dev/sdb)
  3. Type vboxmanage internalcommands createrawvmdk -filename ~/usb.vmdk -rawdisk /dev/sdx (replacing sdx with your actual drive letter from step 4)
  4. Type virtualbox to start the program, and proceed create a New Virtual MachineCreate a New Virtual Machine
  5. When prompted for a Virtual Hard Disk, tick use existing hard disk then browse to your Home directory and select usb.vmdkSelect Existing Virtual Disk usb.vmdk
  6. Once you've finished creating your New Virtual Machine, click StartStart VirtualBox - To Boot from USB in Virtualbox

If all went smoothly, you should now be booting your USB flash drive from VirtualBox on the Linux Host.

Boot from a USB Flash Drive in VirtualBox (Mac OS X)

  1. Download and install the VirtualBox for OS X Hosts via the .dmg file.
  2. Open a Terminal and type diskutil list (note which is your USB drive I.E. /dev/disk2)
  3. Type diskutil unmountDisk /dev/disk# (replacing # with the disk number of your USB drive)
    Type vboxmanage internalcommands createrawvmdk -filename ~/usb.vmdk -rawdisk /dev/disk(again replacing # with your actual disk number)
  4. Type diskutil unmountDisk /dev/disk# (once more replacing # with the disk number of your USB drive)
  5. Type sudo virtualbox to start the program with root access (note: you'll need to use sudo virtualbox from a terminal every time you want to boot from the usb).
  6. Proceed create a New Virtual MachineCreate a New Virtual MachineWhen prompted for a Virtual Hard Disk, tick use existing hard disk then browse to your Home directory and select usb.vmdkSelect Existing Virtual Disk usb.vmdk
  7. Once you've finished creating your New Virtual Machine, click StartStart VirtualBox - To Boot from USB in Virtualbox

If all went well, you should now be booting your USB flash drive from VirtualBox on the Mac OS X Host.

Disclaimer