How to Boot VirtualBox Virtual Machine from USB – macOS & Windows OS

Sometimes booting a virtual machine from USB is necessary to install an Operating System as a guest on VirtualBox if you do not have ISO file. Unfortunately, it is not supported by most of the desktop virtualization software as a built-in feature yet. The below guide explains the steps of how I managed to boot a VirtualBox virtual machine from USB on macOS and Windows host computers. This method will be useful if you have a bootable Live Linux on USB and you want to try that on VirtualBox.

Oracle VirtualBox is one of the best and free desktop virtualization software which allows running multiple Operating Systems on the single computer. Nowadays, most of the PC utilities and Operating Systems have the feature to create a portable and bootable USB disk which can be used in varies ways. VirtualBox has a hidden feature to enable this USB boot support.

Basically, we need to create a VMDK file based on the attached USB disk and mount the VMDK as virtual machine’s first bootable disk and boot it.

VirtualBox Boot from USB in Mac

1) Attach the bootable USB disk and find out the disk path.  Because we need to use the disk path in the next command.

Open the Terminal ( Go – Utilities- Terminal) and type mount

Mount command to see USB

It shows the USB disk path, note it down since we need to use it later. In this example, /dev/disk2s2 is mine.

2) Now go to disk utility (Go – Utilities- Disk Utility) and unmount the partition of the USB disk. The next command will not work without unmounting the USB disk. Right-click on USB partition and select ‘Unmount USB name’

unmount USB 3) Type following command in terminal to create VMDK file of the USB disk.

sudo VBoxManage internalcommands createrawvmdk -filename /Users/Dinesh/Documents/myusbdrive.vmdk -rawdisk /dev/disk2s2

 

create raw disk

/Users/Dinesh/Documents/myusbdrive.vmdk – is the location of vmdk file

/dev/disk2s2 – the USB drive path which we got from mount command earlier.

Provide the superuser password to complete the task.

4) Now we have successfully created the VMDK file. But, if you attach the file to VirtualBox and try to boot, it will throw some access denied errors. We need to modify a couple of permissions.

5) Since we will be using VirtualBox as a normal user but the VMDK file is created with su (superuser) command, we need to give read and write access to all users for particular VMDK file.

Type the following command to change the permission of the VMDK file.

sudo chmod 777 /Users/Dinesh/Documents/myusbdrive.vmdk

6) We need to change the permission of USB disk too.

sudo chmod 777 /dev/disk2s2

7) Now the VMDK file is ready to attach and boot a VirtualBox virtual machine on macOS host.

In virtual machine settings, go to storage and select the controller, then add a hard disk. Select choose existing and browse the VMDK file we created in earlier steps.

Attach VMDK to boot from USB

Change the hard disk SATA port number to make sure it has listed as the first hard disk for the virtual machine, so it will boot from it (like a CD/DVD drive). In this way, the virtual machine will boot from USB on VirtualBox with Mac OS X Mavericks host.

Steps on Windows OS Host

The process is almost identical which we did earlier for macOS to boot a VM from USB in Windows 10 or 8.1/7. Also, it is similar to our earlier guide on how to access physical disk and partition from the VirtualBox virtual machine.

I’m demonstrating these steps on a Windows OS computer with the bootable DOS USB flash drive. I’m going to boot an existing Linux virtual machine from this USB disk.

1) Make sure your USB is bootable and it is booting on a physical computer. Because, if the USB is not bootable, there is no point in blaming these steps or VirtualBox.

2) Find out the correct disk number of attached USB drive from Windows Disk Management.

Here is mine. Disk 4 is the USB I need to boot from VirtualBox.

disk number of USB disk

3) Let’s create a raw VMDK file for the USB disk.

Open the command prompt as administrator and go to the installation directory of VirtualBox (usually it will be located under Program Files folder under C partition).

cd virtualbox folder

Important Note – You must open the command prompt by selecting ‘Run as administrator’ option.

Type the following command.

VBoxManage internalcommands createrawvmdk -filename C:\Users\Dinesh\Desktop\usb1.vmdk -rawdisk \\.\PhysicalDrive4

Command to create RAW VMDK file

You must enter the valid path to save output VMDK file and correct disk number of the USB drive which we found from disk management.

A successful message should appear as below if the command works fine.

Worked command

4) Now open the VirtualBox and go to the settings of the virtual machine you like to boot from USB disk.

We need to attach this VMDK file to the VM as the first bootable hard disk to be able to boot. Since my existing virtual machine is having SATA controller, I clicked on Add Hard disk, selected Choose existing disk and attached the VMDK file created earlier.

attach the RAW disk file to VM

Once the disk is added without any error messages, you may need to change the SATA ports or IDE settings to make the added hard disk as the first boot disk, otherwise, it will be booting from earlier OS hard disk only.

Connect as first hard disk

5) Now you can switch on the virtual machine, it should boot from attached USB disk.

Here is my Fedora Linux VM booting from DOS USB flash drive.

Working VM from USB Boot

The involved steps are very easy and straightforward, the only important part is you must open the command prompt as administrator and enter the commands properly with the disk numbers.

If any of the above solutions did not fix the Windows PC issues, we recommend downloading the below PC repair tool to identify and solve any PC Issues.

Dinesh is the founder of Sysprobs and written more than 400 articles. Enthusiast in Microsoft and cloud technologies with more than 15 years of IT experience.

17 thoughts on “How to Boot VirtualBox Virtual Machine from USB – macOS & Windows OS”

  1. VBoxManage internalcommands createrawvmdk -filename C:mikeusb.vmdk -rawdisk \\.\PhysicalDrive7

    you have to have \\.\ for this to work..

  2. “Hi Mike, Great post! this worked well but I get BSoD when booting from the USB!!
    Any Ideas??”

    Sorry that was meant for you Dinesh

  3. Gee’s I wish you could have fixed it….
    Wasn’t until I read the comments (from Mike) that it finally worked – Thanks Mike 🙂

    VBoxManage internalcommands createrawvmdk -filename C:UsersDineshDesktopusb1.vmdk -rawdisk \\.\PhysicalDrive4

  4. Hi there Dear, are you genuinely visiting this site regularly, if so after that you will definitely take fastidious know-how.

  5. Very good method, thank you very much.
    I have Windows XP SP3 x86 and I’m using VirtualBox as admin.
    Only one problem: any changes made to the USB drive in the virtual machine are not visible in the host OS until I remove it and reattach it.
    I tried a tool called sync.exe, who flushes the Windows RAM buffer, no change.
    I tried also to change usb.vmdk to writethrough, still no change.
    Is there any good setting for this, or even a tool/command (preferably fast too), perhaps even one that can be used in a batch file…?
    Please help me…
    Thank you.

    Regards, DavidB

  6. Well, I found a solution: using mountvol command to dismount USB drive’s volume(s) before starting the VM and to mount them again after closing the VM.
    All can be done in a batch file so it will be very easy to use…

  7. There is a tool who does that automatically. It’s called “Virtual machine starter”. Works with Qemu and VirtualBox. More: it’s able to automatically dismount the volumes from the USB drive before the VM starts and to remount them back after it’s closed. This way it can prevent any data loss on the USB drive (from been accessed simultaneously by 2 computers) and you can see any modification made inside the VM (to the USB drive) into the real computer right after the VM is closed.

    Where you can find it: go to reboot pro → Boot methods & tools → Boot from USB / Boot anywhere → Booting VirtualBox with USB workaround (last page of the thread).

    • hi i have made 10 times all these steps and get error when boot the VM : Boot error

      cmd as admin
      VBoxManage internalcommands ….
      vbox as admin
      new vm ….add harddisk…existing disk… i saw that it see my usb 7.47 gb
      when i boot the new vm… Boot error on the screen.

      also can you give the link of your tool? Virtual machine starter” ????

  8. Does anyone have a handy link regarding how to do this on Linux or an OS X (or other ‘nix) system? Many thanks if so.

  9. Dinesh:
    Ref: Your article, “VirtualBox P2V with Disk2vhd, Possible Errors and How to Fix Them”.

    I was trying to P2V, a 64 bit win7 as a guest in a 64 bit win 7 Host.
    Your tips made it work.
    Thank you very much.
    Rajan

  10. Hello, it looks like there has been changes in Virtual Box as this is no longer working. When starting the virtual box, I get a message saying: “A critical error has occurred while running the virtual machine…” Ignore Ok. Have you experienced this error?

  11. Why do you need to boot from USB in VirtualBox? Use virtual optical contain ISO file instead. It’s similar to use live CD.

Comments are closed.