Did you know that you can get Virtualbox to boot up from a USB drive instead of your normal disk image? In other words, if you have a bootable USB stick you can plug it into the host machine and then have the guest machine boot up using the OS on your USB stick.
Let me show you how easy it is to get this going.
I’m running Windows 8.1; however, this works in Windows 8 and Windows 7 too.
Get er’ done
First we need to insert the bootable USB stick and get the disk number so we can tell VirtualBox where it is.
Press Windows Key + r then type:
Say hello to your Disk Management application.
You may already know how to get around in here but to all my first-timers, the top pane lists all your volumes such as the C:\ drive and any other connected drives.
The bottom pane displays a graphical view of all your drives. Let’s focus our attention in this bottom pane.
You should see your Removable drive number as Disk 1 or something similar. (you may have to scroll down to bring it into view)
Okay, cool, now that we have the Disk Number of our USB stick we can make Virtualbox aware.
Check it out.
Bust open the command prompt with admin rights by pressings Windows Key + x + a in Windows 8 and 8.1 or press Windows Key and type cmd.exe in Windows 7 and right click it to choose Run as administrator.
Let’s navigate to your VirtualBox directory:
Now paste in the following command but don’t press enter yet. I need to explain a few things:
VBoxManage internalcommands createrawvmdk -filename "C:\Users\vhudson\VirtualBox VMs\usb.vmdk" -rawdisk \\.\PhysicalDrive1
VBoxManage is to Virtualbox what PowerShell is to Windows: you can completely dominate Virtualbox without ever leaving the command line. There are dozens upon dozens of VBoxManage commands that I could dump on you but I’m not mean so I won’t do that.
Instead I’ll tell you one that will surely impress your boss and may even win you a date with that geek girl you’ve been in eyeing in the adjacent cubicle.
Let’s breakdown the account:
VBoxManage internalcommands createvmdk
This creates the virtual hard drive.
-filename "C:\Users\vhudson\VirtualBox VMs\usb.vmdk"
Unless your name is vhudson, you’ll want to change the destination location to something more meaningful. I like keeping all my virtual hard drives in a VirtualBox VMs folder.
This is the biggie: That rawdisk switch allows the guest OS to get to its virtualdisk without even bothering the host OS. This command tell us to access the PhysicalDrive mounted as Disk 1: PhysicalDrive1
This is an extremely dangerous command so don’t do anything else. If you type the wrong thing after the -rawdisk switch you can irrevocably destroy data on your physical hard drive so please just copy and paste what I have and only change the -filename. Also take painstaking time to verify the PhysicalDrive number matches the Disk Number you saw in the Disk Management Application earlier.
Okay once you get past that hump it’s time to launch VirtualBox as an Administrator.
Oh, I just realized my beautiful wife is in the background of that screenshot. Anyway, say hi.
Now create a new Virtual Machine. I’m booting from an openSUSE Linux USB drive so I created mine accordingly.
- I named it “openSUSE from USB Stick”
- Set the type to Linux
- Changed my Version to openSUSE (64-bit)
- Bumped the memory up to 2GB
And then this very important step:
Under the Hard Drive section make sure you select Use an existing virtual hard drive file then select the usb.vmdk file you created with the VBoxManage command line tool.
Click Create and you’re done.
You can now boot up VirtualBox using the physical USB stick plugged into your Host OS.
If you ever want to install the OS from the USB stick just open up the Settings, click over to Storage and click the second plus sign in the Controller:SATA row.
If you’re drinking a beer to celebrate your accomplishment ship me one too! I love Stella.