Boot from USB on VirtualBox

virtualbox_compOne way to boot from USB on VirtualBox is to use the Plop boot manager. However, VirtualBox provides a CLI option to generate a vmdk disk to boot from USB flash drive. Here are the steps on Ubuntu:

  1. Check the device node of your USB using fdisk:
    $ sudo fdisk -lu
    //let's say it is /dev/sdc
  2. Generate VM disk linking to the USB:
    $ sudo VBoxManage internalcommands createrawvmdk -filename ~/VirtualBox\ VMs/usb.vmdk -rawdisk /dev/sdc
  3. Create a new VM (or use existing) and attach the usb.vmdk file as a disk (use choose existing disk option).
    NOTE: You need to be root or sudoer.
  4. Change the disk to IDE Primary Master. Note that you might need to change the type of other existing disks.
  5. Boot the VM.

If you want to remove and re-attach the vmdk or add it to a new VM you may hit the following error:

Virtual Box UUID {1a2b.........} does not match the value {d009...} 
stored in the media registry ('/home/username/.VirtualBox/VirtualBox.xml')

One workaround is to rename usb.vmdk to something else and use it again.

The correct way to remove the disk is:

$ sudo VBoxManage list hdds
UUID: d009cc0c-6608-4718-98d5-f3a1bd087296
Parent UUID: base
State: inaccessible
Type: normal (base)
Location: /home/username/VirtualBox VMs/usb.vmdk
Storage format: VMDK
Capacity: 0 MBytes
$ sudo VBoxManage closemedium disk d009cc0c-6608-4718-98d5-f3a1bd087296

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s