wire.less.dk

wireless networking, free software, solar power

How to boot from USB in virtualbox on Ubuntu

Posted on | May 13, 2011 | 13 Comments

How to boot from USB in virtualbox
Useful for quick testing of USB boot media, flexible plug’n’play of guest operating systems, and so on.
Tested for various Ubuntu 9/10, virtualbox 3.1.6/4
Prepare:
$ su
# mkdir /root/.VirtualBox/HardDisks
# VBoxManage internalcommands createrawvmdk -filename /root/.VirtualBox/HardDisks/usbdisk.vmdk -rawdisk /dev/sdb1
So, you tell virtualbox to see the USB drive as a disk, which you then boot from.
Open virtualbox
# virtualbox
Make new machine, choose “Existing harddisk” and point at the one you created.

Useful for quick testing of USB boot media, flexible plug’n’play of guest operating systems, and so on.

Tested for various Ubuntu 9/10, virtualbox 3.1.6/4.0.6

Prepare:

$ su

# mkdir /root/.VirtualBox/HardDisks

# VBoxManage internalcommands createrawvmdk -filename \
/root/.VirtualBox/HardDisks/usbdisk.vmdk \
-rawdisk /dev/sdb1

Note: all in one line! the last bit, the device name, needs to point at your USB drive. In this case /dev/sdb1 – yours will be different!

So, you tell virtualbox to see the USB drive as a disk, which you then boot from.

Open virtualbox:

# virtualbox

Make new machine, choose “Existing harddisk” and point at the one you created.

Thats all.

Thanks, Three Wise Men http://www.twm-kd.com/software/boot-virtualbox-machine-from-a-usb-flash-drive/

Comments

13 Responses to “How to boot from USB in virtualbox on Ubuntu”

  1. William Temple
    December 9th, 2011 @ 8:16 am

    A long preamble. I created a live usb in Ubuntu 10.04 but I wanted to remove the opening screen. I searched and found instructions to install directly to my usb. When I tried to boot I got an error. I wanted to test it in Virtual box. Following your instructions I got this output.

    sudo VBoxManage internalcommands createrawvmdk -filename \ /home/william/.VirtualBox/HardDisks/usbdisk.vmdk \ -rawdisk /dev/sdd1

    Syntax error: Invalid parameter ‘ -rawdisk’

    So did I type something wrong or am I not using the right versions?
    Thanks,
    Bill

  2. dreamon
    February 12th, 2012 @ 10:26 pm

    Hello

    your example is wrong.

    /dev/sdb1

    you have to remove the number at the end.

    sdb is wright
    sdb1 is worg

    with 1 it isnt bootable

  3. sebastian
    February 20th, 2012 @ 12:42 pm

    works fine for me, but thanks for the comment!

  4. axessdenied
    February 25th, 2012 @ 12:19 am

    @dreamon

    /dev/sdb1 is HIS device, not yours.

    Yours will usually differ based on what drives you have installed.

  5. zelyan
    April 19th, 2012 @ 1:27 pm

    it works,
    thanks for article,

  6. Ne0
    May 29th, 2012 @ 3:06 am

    @William: If your question is still current you should delete the slashes “/” in your prompt.

    @dreamon: This is not right at any case.. Sometimes you must use i.e. “sdb1″ instead of “sdb”.
    Also take a look at axessdenied’s post.

  7. Ne0
    May 29th, 2012 @ 3:07 am

    @William: Sorry; I meant the blackslashes “\”!

  8. Fabio
    November 1st, 2012 @ 3:01 pm

    It worked without the 1 at the sdb1: /dev/sdb. Thanks a lot!

  9. noobsplash
    November 27th, 2012 @ 10:52 am

    Everything went fine until I tried to add the disk to the known media in VirtualBox. I got this:

    Failed to open the hard disk /home/shade/VirtualBox VMs/backbox/usbdisk.vmdk.
    The medium ‘/home/shade/VirtualBox VMs/backbox/usbdisk.vmdk’ can’t be used as the requested device type.

    Failed to open the hard disk /home/shade/VirtualBox VMs/backbox/usbdisk.vmdk.

    The medium ‘/home/shade/VirtualBox VMs/backbox/usbdisk.vmdk’ can’t be used as the requested device type.

    Result Code: NS_ERROR_FAILURE (0×80004005)
    Component: Medium
    Interface: IMedium {53f9cc0c-e0fd-40a5-a404-a7a5272082cd}
    Callee: IVirtualBox {c28be65f-1a8f-43b4-81f1-eb60cb516e66}

  10. How to boot from a flash drive OS using VirtualBox?
    February 14th, 2013 @ 5:31 am

    [...] The same approach, but for Linux, is described in How to boot from USB in virtualbox on Ubuntu. [...]

  11. antiplex
    March 13th, 2013 @ 7:07 pm

    thanks for the post, it looked promising but did not work for me for the same reason as noobsplash described running virtualbox v4.1.24.
    i tried to change the files permission and owner but still had no luck.
    also tried both variants (e.g. /dev/sdb and /dev/sdb1) leading both to the same error…

    i was running virtualbox as my user and wondered if there is something wrong with the mounting or such so i tried to add the drive when running virtualbox as root, managed to spot that there is actually a ‘su’ command and a ‘#’ before all commands and SUCCEEDED.

    bottom line: in order for this to work, run virtualbox as root! (note that the resurce mentioned by sebastian is also mentioning this)

    cheers and thanks!

  12. glip
    March 22nd, 2013 @ 10:35 am

    noobsplash, you had to change the rights of new file, for example:

    sudo chmod 777 /home/shade/VirtualBox VMs/backbox/usbdisk.vmdk

  13. How To Boot From A Flash Drive OS Using VirtualBox? | Click & Find Answer !
    April 21st, 2013 @ 7:36 am

    [...] The same approach, but for Linux, is described in How to boot from USB in virtualbox on Ubuntu. [...]

Leave a Reply