How to make VirtualBox virtual machine boot from USB?

Booting ISO files in VirtualBox to create a Virtual Machine is pretty much easy, however, what about Virtual Machine USB boot? Yes, I mean suppose you have a bootable USB drive and no ISO file image or anything to boot with to install an OS on VirtualBox; at such condition what will you do? Simple, we can use our bootable USB drive. Although the procedure of doing this is slightly techie as compared to the normal one, easily achievable by anyone.

By default, the VirtualBox doesn’t support USB Flash Drive boot but we can make it run a virtual machine from a flash drive. After following this tutorial, you will be able to boot Windows 10, Ubuntu, Linux Mint, or any OS using USB boot.

Virtual machine boot from USB on a Windows/macOS/Linux Host

Note: Before following any of the below-given methods to install Virtual Machine on VirtualBox using a bootable USB drive, please ensure the VirtualBox is already on your system.

In Windows 10/8/7

Step 1: Find the Bootable USB drive letter

To identify the plugged-in USB drive letter or identification number in the Windows system, press Win key +R, to open the Run box. Type diskmgmt.msc

boot Virtualbox using USB drive

Step 2: Locate your connected bootable USB Disk drive

On the Disk Management of Windows locate for attached removal drive using which you want to boot and create a VirtualBox Virtual Machine. You can easily identify it as it will be denoted with a Removable text. When you find that note the Disk X letter.

For example, in the below screenshot, our USB drive is labeled as Disk 3, so ‘3‘ is the number that we have to remember.  It might be different in your case.

Virtualbox USB boot

Step 3: Open Command Prompt

On Windows 7/8/10, in the start menu search box typed CMD to search command prompt and when it appears, right-click and select “Run as Administrator“.

run command prompt as administrator

Step 4: Switch to Oracle VirtualBox directory

At this step, we enter into Oracle’s VirtualBox installation directory. For that, just copy and paste the below-given command in the Command prompt and press the Enter button.

cd %programfiles%\Oracle\VirtualBox

Switch to Oracle VirtualBox directory

Step 5: Create USB vmdk -rawdisk

This is a crucial step of the tutorial, as we are going to map a virtual machine (.vmdk file) to the USB Drive. This means we create a VMDK raw file that holds the path of our bootable USB drive for VirtualBox which helps it to recognize the USB drive as a normal Virtual Disk drive.

What you have to do? Just copy-paste the following command in Command Prompt. After that replace the # letter with the drive number which you noted in the second step of this tutorial. For example, our disk number is ‘3’ so we will replace the # letter with 3.

Note: Red color USB2 in the below command is the name of the rawdisk we about to create and you can give it whatever name you want.

VBoxManage internalcommands createrawvmdk -filename C:\usb2.vmdk -rawdisk \\.\PhysicalDrive#

USB boot for VirtualBox VirtualmAchine

Step 6: Create a New Virtual Machine

create USB boot Virtual Machine oN Virtual box

Step 7: Assign some name to it.

Here we are creating Windows 7 Virtual Machine with the name USB Windows 7, however, you can select Linux or any other OS depending upon your bootable USB OS.

Give Virtual Machine name

Allot the amount of RAM you want to give to Virtual Machine.

Assign memeory

Step 8: Use USB boot VDMK Raw disk in VirtualBox

In the Hard disk section, select the “Use an existing virtual hard disk file” option and then click on the folder icon which opens Windows Explorer. Now go to C: drive and select your created.VDMK file. In our case it is usb2.vdmk.

Then click on the Create button.

Create USB boot Virtual Machine 2

Note: If you get an error:

Failed to open the disk image file ~/VirtualBox VMs/xx/usb.vmdk.

Permission problem accessing the file for the medium '~/VirtualBox VMs/xx/usb.vmdk' (VERR_ACCESS_DENIED).

Then simply close the VirtualBox and start it under administrative rights…

 

Step 9: Start created a virtual Machine

Select the created USB bootable virtual machine from the right-side panel and click on the Start button given in the VirtualBox menu and that’s it.


If you are using macOS or Linux like Ubuntu then from step 6 to step 9 will be the same, the only difference is the method to create a .VDMK Raw file. For that please see the below steps:

For macOS, USB boot VirtualBox Virtual Machine

Note: VirtualBox should be installed already on the system.

Step 1: Open a Terminal

In the Terminal of MacOS type a command: diskutil list to see all attached disk and USB drives. When the list appears, jot down the bootable USB drive letter (example /dev/disk2) as we have done for Windows above.

Step 2: Unmount USB Disk

To use the USB disk to create a raw image for VirtualBox, first, we have to unmount it. For that the command is:

diskutil unmountDisk /dev/disk# 

Note: Replace the # with the USB drive disk number noted above.

Step 3: Create VDMK Raw file of connected bootable USB drive

Use the below command in your MacOS command terminal and again replace the # with the USB disk number.

 vboxmanage internalcommands createrawvmdk -filename ~/usb1.vmdk -rawdisk /dev/disk# 

After running the above command once again unmount the same disk. As done above, in the same way, replace # with disk number.

 diskutil unmountDisk /dev/disk# 

Step 4: Run VirtualBox under root access

To run the VirtualBox under root privilege type the below command in terminal

sudo virtualbox

Note: Whenever you want to boot VirtualBox using USB, it should be run under root access.

Step 6: Create a Virtual Machine and assign the created USB VDMK file as a hard disk.

Create USB boot Virtual Machine 2

For Linux (Ubuntu 19.04) VirtualBox Virtual Machine USB boot

To install VirtualBox, if not already, the command is:

sudo apt-get install virtualbox

Step 1: List the attached disks

sudo fdisk -l

Step 2: Create USB raw VDMK file

Replace sdbx with the disk name that appeared on your screen. While usb1 is the name of the RAW file that could be anything you want.

vboxmanage internalcommands createrawvmdk -filename ~/usb1.vmdk -rawdisk /dev/sdbx

Ubuntu Virtualbox virtual machine USB boot

Step 3: Open the VirtualBox

Type sudo virtualbox in the command terminal to run under root access. When it opens, create a new Virtual Machine.

Ubuntu Virtual machine USB boot

And at the Hard disk section, select the “Use an existing virtual hard disk” option. Click on the folder icon and select the above-created USB drive raw image file which will be under the home directory. After that just click on the Create button.  This will let you perform virtual machine USB boot on Ubuntu Linux.

Create virtual machine linux booting using USB drive

Other Useful Resources:

9 thoughts on “How to make VirtualBox virtual machine boot from USB?”

  1. it doesn’t work on my Mac.
    says :
    VBoxManage: error: Cannot open the raw disk ‘/dev/disk2’: VERR_ACCESS_DENIED
    VBoxManage: error: The raw disk vmdk file was not created

    Reply
    • bonjour, pareil pour moi, la cle est bien bootable mais dans un format “non géré”
      diskutil list m’indique :
      /dev/disk6 (external, physical):
      #: TYPE NAME SIZE IDENTIFIER
      0: GUID_partition_scheme *8.0 GB disk6
      1: Linux Filesystem 3.2 GB disk6s16
      2: FE3A2A5D-4F32-41A7-B725-ACCC3285A309 16.8 MB disk6s17
      3: 3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC 3.2 GB disk6s18
      4: FE3A2A5D-4F32-41A7-B725-ACCC3285A309 16.8 MB disk6s19
      5: 3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC 2.1 MB disk6s20
      6: Linux Filesystem 1.1 GB disk6s23
      7: CAB6E88E-ABF3-4102-A07A-D4BB9BE3C1D3 8.4 MB disk6s26
      8: EFI EFI-SYSTEM 67.1 MB disk6s27
      faut-il utiliser une des partitions ?

      Reply
  2. And at Hard disk section, select “USB an existing virtual hard disk” option.
    –change to “Use an existing virtual hard disk”–

    Reply
  3. On a linux host, with a (typical) bootable linux USB stick that has several partitions, you should use the entire device such as /de/sdb, /dev/sdc etc.

    Running as root is necessary, but must use sudo, cannot run logged in as root. Probably depends on how your root account sets up the dbus socket or how sudo treats dbus. I was able to add the vmdk raw image to VM in settings as root but couldn’t as normal user. However, the VM failed to start, saying it couldn’t find the boot device. Here is the contents of the .vmdk file:

    # Disk DescriptorFile
    version=1
    CID=cff4c5c2
    parentCID=ffffffff
    createType=”fullDevice”

    # Extent description
    RW 30720000 FLAT “/dev/sda” 0

    # The disk Data Base
    #DDB

    ddb.virtualHWVersion = “4”
    ddb.adapterType=”ide”
    ddb.geometry.cylinders=”16383″
    ddb.geometry.heads=”16″
    ddb.geometry.sectors=”63″
    ddb.uuid.image=”5033bd12-be57-4d08-828d-149fb104d4f1″
    ddb.uuid.parent=”00000000-0000-0000-0000-000000000000″
    ddb.uuid.modification=”00000000-0000-0000-0000-000000000000″
    ddb.uuid.parentmodification=”00000000-0000-0000-0000-000000000000″
    ddb.geometry.biosCylinders=”1024″
    ddb.geometry.biosHeads=”255″
    ddb.geometry.biosSectors=”63″

    Reply
    • As we know mac OS is not like other operating systems that meant to easily install on Virtual machines like Vmware or VirtualBox, thus unwelcomed problems are inevitable while trying to set up its VM.

      Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.