37

I have two flash drive, one with Slax installed and another for Android x86 Live installed, but they do not boot in my laptop (in my work they boot perfectly).

I can boot from some live CDs/DVDs or its ISO files using VirtualBox, but I cannot do it for live flash drives - I put the flash drives and start a VirtualBox without any virtual HD, but VirtualBox does not recognize them as boot options, as it does for CDs/DVDs.

Any ideas? Any alternatives if VirtualBox does not support it?

Edit1: I'm using Windows (Windows 7) but I would like to know how to do it in Linux (Ubuntu, for example) too.

6
  • USB boot isn't supported in VirtualBox. Aug 2, 2011 at 20:59
  • any alternative?
    – kokbira
    Aug 3, 2011 at 2:00
  • 8
    You can try this boot manager... plop.at/en/bootmanager.html. If you extract the file archive, you'll find a plpbt.iso file that you can set as your boot medium. This will give a bootloader with the usb option. If your vm is correctly configured for usb (you may need to disable 2.0 support), and your usb stick is already correctly configured (ie, it has a bootable os installed, and you know that it works), then it should boot in the vm. Aug 3, 2011 at 4:36
  • 2
    @JoeInternet: Unfortunately Plop doesn't seem to work with USB 2.0, so it'll be very slow. Aug 21, 2012 at 7:59
  • 1
    Related: superuser.com/questions/324996/… Aug 21, 2012 at 8:00

8 Answers 8

28
+100

For Windows, see this article : Boot your USB Drive in VirtualBox.
For Linux, the same approach is described in : How to boot from USB in virtualbox on Ubuntu.

The approach is to attach a physical drive to a virtual machine using the VBoxManage command-line tool that comes bundled with VirtualBox. You can then boot your virtual machine from the attached Physical drive.

Alternatively, and only for Windows, Linux Live USB Creator (formerly uSbuntu) is a free software for Windows that allows you to create a bootable Live USB key with a Linux on it. It offers the option of automatic virtualization using portable VirtualBox to directly run Linux in Windows without any configuration nor installation.

3
  • 3
    You are really a superuser!!!! Thanks :) Details: in Windows 7, you have to run cmd commands and VirtualBox as administrator!
    – kokbira
    Aug 12, 2011 at 16:55
  • 1
    @harrymc: For Linux, the guide you linked isn't clear that you have to run VirtualBox as root (!), or alternatively add your user account to the disk group. This is of course a possible security risk. Aug 21, 2012 at 7:58
  • 1
    I would like to add that this evidently does not always work (at least on Windows 10) with drives that utilize USB 3.0 (may give "VERR_IO_NOT_READY" error, among others). To work around this, you can try any USB 2.0 ports that you may have, or use a USB 2.0 hub, and connect it to that. Jan 29, 2016 at 8:02
7

Here's a quick summary of the Windows link provided by harrymc, which I discovered independently:

  1. In Windows 7, open a cmd prompt with admin privileges.
  2. cd to C:\Program Files\Oracle\VirtualBox

  3. Run the following command:

    VBoxManage internalcommands createrawvmdk ^
      -filename "C:\usb.vmdk" -rawdisk \\.\PhysicalDrive#
    

    Replace the # with the disk number from disk management in computer management (Disk 1 in the image below).

    Disk number shown by Disk Management

  4. Finally, attach the newly-created vmdk within VirtualBox as an existing hard drive image.

2
  • same solution described by @harrymc
    – kokbira
    Apr 12, 2012 at 1:30
  • added "" to allow spaces
    – kokbira
    Apr 19, 2017 at 12:17
3

I know this question is old but I'd like to throw something in. As with other answers I recommend the VBoxManage command.

However I created a bash script for Ubuntu that simplifies the command and even offers a helpful walkthrough for less comfortable users. It'll help make any changes needed for USB mounting to work (like adding group membership). Advanced users can use flags to avoid the walkthrough.

Check it out here: Use Bootable USB Drives in a VM -- VB Bootable USB Mounter

2
  • 1
    It isn't a answer for my question "How to boot from a flash drive OS using VirtualBox?". It appears more a comment...
    – kokbira
    Nov 22, 2012 at 19:07
  • I'm saying about the format of a complete answer (suppose all other answers are deleted...).
    – kokbira
    Nov 22, 2012 at 19:10
3

VirtualBox IS able to load from USB! However it is a bit tricky.
I was not able to boot from USB in BIOS mode, so enable the EFI mode!
Enable EFI

Now add the wanted USB device to the config to automatically mount it on start
Add USB to VM

Now start machine
If the USB-drive is already detected, skip this step (the reset). However on some systems unfortunately right after start the USB-Stick might not be detected:
first boot attempt

make sure that USB is connected:
check USB is attached

If there is a general issue to mount an USB drive to a VM, see this post VirtualBox Error: USB device is busy with the previous request.
Now reset the machine (not power off) using the menu or hit Hostkey+R (ususally Hostkey is RightCTRL). You might be lucky and the system is already booting from USB. If not you need to provide the boot file manually. To do this you should now see an additional drive (here FS0: - no other drives are attached to my VM). If there is a vdi attached (this is always detected, probably as FS0:), you might find a new like FS1:
specify boot file
First type the 'drive' to boot from, here FS0:. Next you need to specify the efi-file, you can also use 'ls' or 'cd' commands to browse the folders on the USB drive. Provide file name (usually located below 'EFI') e.g. efi\boot\bootx64.efi. Hit Enter to boot from that EFI boot file.
It is possible to store this info permanently into the file startup.nsh, see here for a good explanation.
As an alternative type 'exit' + Enter to leave the shell and enter the EFI Menu. Now choose 'Boot Manager':
enter image description here
Select the drive to boot from. There are more options in the EFI settings like providing a path to the efi file manually. Unfortunately these settings are not stored permanently in NVRAM of the VM (VBox 7.06).
If you want to enter this menu directly, hit Esc or F2 immeditaly when the VM starts. The timing here is critical, it took me some attempts (resetting machine and try again).

1
  • Best answer! VirtualBox 7.0.10 boot from a UEFI Debian USB Stick without reset und manual work! I only add the USB Stick to "USB Device Filters", start the machine an it works. Thanks a lot!
    – Cor
    Nov 8, 2023 at 10:34
2

Yes, in Windows Vista, 7 and 8, you need to start command prompt and virtualbox program as administrator to make this work. Check the latest guide about how to boot virtual machine from bootable USB on Oracle VirtualBox.

1
  • It isn't a answer for my question "How to boot from a flash drive OS using VirtualBox?". It appears more a comment...
    – kokbira
    Nov 22, 2012 at 19:06
2

according to harrymc's source: you can not set up to boot from USB in the GUI, however, you can create a special virtual disk that only "redirects" to your physical usb pendrive, and attach that. here is the windows way (only, link contains it for linux too).

in windows host

  • attach your physical usb pendrive to your host computer

  • open/run diskmgmt.msc and check which disk number did windows choose for your physical pendrive:

example: example disk 1

  • then do this in cmd.exe:

cd c:\Program Files\Oracle\VirtualBox

VBoxManage internalcommands createrawvmdk ^
-filename <path\to\usb.vmdk> ^
-rawdisk \\.\PhysicalDrive<n>
  • replace <path\to\usb.vmdk> to a path of your choosing, for the "redirect" disk file. example: e:\my_redirect_for_usb.vmdk

  • replace <n> in \\.\PhysicalDrive<n> with the number of your Physical drive, example: \\.\PhysicalDrive1 if your drive number is 1 (got from diskmgmt.msc above!)

  • aside: note, that ^ only means "line-continuation" in cmd - i did this only for better readability. You can write the whole thing in one line, instead -- just leave out any ^, then.

  • now you can attach the vmdk (example: e:\my_redirect_for_usb.vmdk) in Virtualbox like you do with any other hdd image

  • I managed to boot this way in 2014 :) ( -- the source article is from 2009)

0

If you add the USB device via the USB tab in the settings of any virtual machine, and then add a USB controller in the storage tab, your USB should show up when you boot that virtual machine. Then, as you would on any machine, you can choose the USB device from the boot menu, or the BIOS menu by switching the boot order of the devices to boot from.

This is possible on VirtualBox 7+ with guest additions. Not sure about earlier versions, but v7 seems similar to v6.

-1

I'm sorry to break it to you, but VirtualBox does not support booting from USB.

The only thing that I can think of is creating an image of the contents of the USB drive, mounting this as a CD-Rom in VirtualBox and booting from there.

2
  • 1
    I thought it in the past but @harrymc show me how to do it.
    – kokbira
    Apr 12, 2012 at 1:29
  • Factually incorrect.
    – jpaugh
    Aug 30, 2017 at 20:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .