Mastodon

VirtualBox Multiboot USB

Send to Kindle

Yesterday, I wrote about paying for free software. At the very end of that post, I highlighted a program called Macrium Reflect. That program can automatically create a Linux-based Rescue CD (in order to restore a previously saved image to a damaged or new hard drive).

On their site, they have a good tutorial for how to put that rescue ISO on a USB drive. As long as your BIOS supports booting from the USB drive (most modern ones do), it’s a tad more convenient to carry around a flash (thumb) drive than a CD.

In that tutorial, they use a program called UNetbootin (Universal Netboot Installer). What’s cool about this program (free and open source as well) is it can take practically any ISO and create a bootable USB drive out of it. It has many other cool features (e.g., it can automatically download any number of Linux distros and create a bootable USB or CD without you even knowing the location of the Linux project website!).

UNetbootin uses SysLinux under the covers to create and manage the bootable USB drive. Within SysLinux, there is a single file, syslinux.cfg, which controls the menu of selections that can be booted (different kernels, options to pass to a kernel, etc.).

Now switching gears for a moment, then back to the above to tie it all together…

There are a number of high-quality Virtual Machine programs/products available for all of the major operating systems. The three biggies on Windows are VMware, Virtual PC (directly from Microsoft) and VirtualBox (from Sun). All three are very capable, and all three have at least one version that is completely free.

On my old XP laptop, I used to use VMware Player. It’s free and quite good. I have read that recent versions of Virtual PC are good as well (also free), but I’ve never bothered to install it. While I understand that you can run Linux in Virtual PC, I believe it’s not supported, and I don’t really have a need to run Windows under Windows, so I passed on checking it out.

A few months ago, I stumbled onto VirtualBox. It used to be called InnoTek in a previous incarnation, and was purchased by Sun. There is a free version, which is fully open sourced as well, and there is a proprietary version which adds a few bells and whistles (including some cool USB support), which is available in binary form for free as well (for non–commercial use).

Since I have no interest or need (or capability!) to mess with virtualization source code, I am using the full binary version. On my new Vista Ultimate x64 laptop, I have only VirtualBox installed. I didn’t even download VMware (no knock on their product whatsoever!).

Here is what I like about it. Very fast to load. Full 64 bit support (both their app and guest operating systems!). Virtual PC now has 64 bit support for their own application, but you can only run 32 bit guests (if I understand correctly). Most importantly, I like the fact that it’s more complete (or at least easier to use) than the free version of VMware. I’m way too casual a user (I can go months without launching a VM!) to be willing to pay for VMware Workstation.

So, here are my two normal use cases with VirtualBox, and why I rarely need to run it:

  • Check whether a new Rescue ISO works
  • Do something fancy with ssh and X-Windows

The first one is simple. For emergency purposes, I carry around a few Linux Rescue disks (used to be only CDs, but stay tuned). My current favorite is SystemRescueCD (currently in version 1.1.4). When a new version becomes available, I download, and boot it immediately in VirtualBox, make sure it seems to work correctly, and only then burn it to a CD and toss the old CD.

The second is rarer, but more complicated. On rare occasion, a friend of mine who is running Linux (that I set up for her) on a very old laptop (that I gave to her) has a problem that I can’t talk her through over the phone. When that happens, I fire up CDLinux under VirtualBox, do some port forwarding on my router, do some ssh magic, and take control of her machine (by allowing her to ssh into my box first, so I don’t have to make changes on her firewall!). I can then even run GUI apps from her machine, redirecting the X session back to me!

Anyway, the point is that VirtualBox works really well, has tons of knobs (we’ll get to one of them in a minute), and doesn’t seem to slow down my pretty darn fast system.

Back to our main story…

When I created the Macrium Reflect Rescue CD (burned to a real CD), I also followed the tutorial to creat a bootable USB disk. When I looked at the disk, I saw the SysLinux stuff, and noticed that all of the Macrium files were in a folder.

I then experimented by using UNetbootin to create another bootable USB disk with SystemRescueCD on it. I saw that it used a different directory to store the various Linux kernels that it can boot. I was able to copy that directory to the other USB disk and copy/paste the lines from the syslinux.cfg file on the SystemRescueCD drive into the other syslinux.cfg.

I did the same thing with CDLinux (version 0.9.0 Community Edition). It used the same name for its subdirectory as Macrium did. I renamed the subdirectory before copying it over, and used the new name in the merged syslinux.cfg file. That worked, because once SysLinux gives control to the kernel in the renamed directory, everything else is relative to that new root directory!

I then rebooted my machine to test the new USB disk. It booted perfectly, and I had 28 choices of kernels to boot from! SystemRescueCD offers most of them, but I had Macrium Reflect and a few flavors of CDLinux to choose from as well. I was able to boot both 64 bit and 32 bit versions of SystemRescueCD successfully. Awesome.

Now the big test. I wanted to see whether I could boot that USB disk from VirtualBox. That would allow my normal use case of testing new releases without having to burn and reboot. Unfortunately, the GUI for VirtualBox does not permit an actual hard disk (USB or otherwise) to be directly attached to the VM (at least not for direct booting).

A quick scan of their excellent manual gave me the answer. There is a command line administration tool called VBoxManage.exe that can be used to create a tiny virtual disk (a VMDK file) that essentially points to any real disk or partition. I used that to create this virtual pointer to my USB drive. It worked perfectly.

I then attached that tiny VMDK disk to my virtual machine and fired it up. Voila, I got the same 28 choices to boot from. I couldn’t get the 64 bit versions to work (they boot, but they claim to be missing modules and won’t start X-Windows), but everything else works flawlessly under VirtualBox.

So, now I have a multi-boot USB drive, that I can keep adding stuff to, that I can test under VirtualBox to be sure it will work correctly should I ever have an emergency. It’s a 1GB USB drive, that has all of these various operating systems and tools on it, and I still have 500MB free. 🙂


Posted

in

,

by

Comments

25 responses to “VirtualBox Multiboot USB”

  1. kuru Avatar

    very useful

  2. piefke666 Avatar
    piefke666

    And how could I make the tiny VMDK disk?? A small “how to” would be very very nice!!

  3. hadar Avatar

    It's in section 9.9.1 of the VirtualBox manual (version 2.1.0).

    Here's the command that I used:

    VBoxManage.exe internalcommands createrawvmdk -filename usb.vmdk -rawdisk \.PhsicalDrive1 -register

    The above is for mounting a raw disk when the host OS is Windows (hence the “PhysicalDrive1” part. For Linux hosts, you would use the normal /dev/sdb1, etc.

    Be very careful, as PhysicalDrive0 is your real internal hard disk on Windows!

    The addition of -register at the end makes the drive (called usb.vmdk) available in the menu for VirtualBox to attach to any VM.

    I hope this help! 🙂

  4. Alexandre Dumont Avatar

    Nice article. It gave me some ideas 😉

  5. hadar Avatar

    Cool! I just took a peek at your blog and noticed the Launchy/Putty plugin. Before I switched from XP to Vista, I used both, and would have benefited from the plugin. Now, in Vista, Launchy-type functionality is built in. While I still use Putty, I don't use Launchy…

  6. […] also gave me the idea that since putting Linux on a USB stick is so trivial (see this post about multi-boot USB), it would be simple to have a bootable USB stick, with the OpenVPN client on it […]

  7. Ángel Avatar

    Hello, i use vb and i need to know how to do this

    “A quick scan of their excellent manual gave me the answer. There is a command line administration tool called VBoxManage.exe that can be used to create a tiny virtual disk (a VMDK file) that essentially points to any real disk or partition. I used that to create this virtual pointer to my USB drive. It worked perfectly.

    I then attached that tiny VMDK disk to my virtual machine and fired it up. Voila, I got the same 28 choices to boot from. I couldn’t get the 64 bit versions to work (they boot, but they claim to be missing modules and won’t start X-Windows), but everything else works flawlessly under VirtualBox

    https://www.opticality.com/blog/2009/01/12/virtu

    Could you help me???

  8. hadar Avatar

    In the current manual, version 2.2.4, it's now in section 9.10. The command itself is on page 134. It's the same as I responded to Piefke666 in a comment above this one.

  9. dih Avatar
    dih

    Thanks a lot! It really works. Now, after days of unsuccessful tries, I've got Ubuntu Netbook Remix on my VB (2.2.2), ready to experiments 🙂

  10. electronic dog fences Avatar

    It works indeed, I tried that as well, really good one, thank you for the share.

  11. DJ Avatar
    DJ

    Thanku very much, nice artical

  12. Greg Avatar
    Greg

    That's pretty cool. I can't even get my usb drive to boot with just the reflect rescue.iso. I followed all the instructions for using Unetbootin to put the rescue.iso on my usb drive partition, but then my machine fails to boot from it. I should point out that this is a 320GB usb hard drive (NOT a flash drive), with only a single 16MB FAT partition on it.

    If you have any suggestions on how I might get this to work, I'd love to hear it!

    Thanks,
    Greg

  13. hadar Avatar

    Well, I'm probably not going to be able to help you, except to say that an external USB drive and a USB Flash drive don't present themselves identically to the OS, so it's quite likely that utilities like Unetbootin that work correctly with Flash drives won't work with a “real” external drive.

    Beyond that, if your bios is old, it's also possible that it simply can't boot off of USB disks, though most machines made in the past few years are capable. Make sure your boot order is checking to boot off of a USB before looking for the internal disk.

    If you can, you should create a CD with the rescue ISO on it. That should work just fine.

  14. Greg Avatar
    Greg

    Thanks, Hadar. A CD based on the ISO does work fine; I'm experimenting with the USB option for a netbook. Both my netbook and my workstation appear to support a usb boot option, so I think it must be the fact that I'm using a usb HDD instead of a flash drive. I guess I'll just find a flash drive and try that out. Thanks again!

  15. Greg Avatar
    Greg

    That's pretty cool. I can't even get my usb drive to boot with just the reflect rescue.iso. I followed all the instructions for using Unetbootin to put the rescue.iso on my usb drive partition, but then my machine fails to boot from it. I should point out that this is a 320GB usb hard drive (NOT a flash drive), with only a single 16MB FAT partition on it.

    If you have any suggestions on how I might get this to work, I'd love to hear it!

    Thanks,
    Greg

  16. hadar Avatar

    Well, I'm probably not going to be able to help you, except to say that an external USB drive and a USB Flash drive don't present themselves identically to the OS, so it's quite likely that utilities like Unetbootin that work correctly with Flash drives won't work with a “real” external drive.

    Beyond that, if your bios is old, it's also possible that it simply can't boot off of USB disks, though most machines made in the past few years are capable. Make sure your boot order is checking to boot off of a USB before looking for the internal disk.

    If you can, you should create a CD with the rescue ISO on it. That should work just fine.

  17. Greg Avatar
    Greg

    Thanks, Hadar. A CD based on the ISO does work fine; I'm experimenting with the USB option for a netbook. Both my netbook and my workstation appear to support a usb boot option, so I think it must be the fact that I'm using a usb HDD instead of a flash drive. I guess I'll just find a flash drive and try that out. Thanks again!

  18. Carmelo Anthony Shoes Avatar

    Here elaborates the matter not only extensively but also detailly .I support the
    write's unique point.It is useful and benefit to your daily life.You can go those
    sits to know more relate things.They are nostalgic-pushead.com strongly recommended by friends.Personallyhings.They are strongly recommended by friends.Personally

  19. mbt Avatar

    Well , the view of the passage is totally correct ,your details is really reasonable and you guy give us valuable informative post, I totally agree the standpoint of upstairs. I often surfing on this forum when I m free and I find there are so much good information we can learn in this forum!
    http://www.mbt-outlet-store.com/mbt-women-shoes

  20. free registry repair Avatar

    I’m very impressed and happy with the Eee Box’s performance with 1 GB RAM and 160 GB hard drive. No, it’s not for power users as plenty of other reviews will testify, but for our needs at work it seems to work very well and I’d definitely recommend them for similar use elsewhere.

  21. Rihatum Avatar

    Hi Hadar,

    Great article, where can I purchase the virtualbox premium version for windows ? any web link for that ? does that give you the USB boot support via gui ?
    Thanks for the article !
    Kind regards
    Rihatum

  22. hadar Avatar

    I don't believe there is a premium version that's for sale, therefore, not GUI for some of the trickier things that today are only available via command line.

    There is a “commercial” version (which supports _remote_ USB!), but it doesn't cost money, it just requires you to acknowledge the license terms, and it comes without the source.

    Perhaps there is a cost for commercial use for that one, but I use it for personal reasons only.

  23. Cheap USB Flash Drives Avatar

    Same here. It works like a charm.

  24. registrycleaner Avatar

    That’s pretty cool. It gave me some ideas.

  25. remove security shield 2010 Avatar

    This will be great if it will work. Thanks for sharing it.

Leave a Reply

Your email address will not be published. Required fields are marked *