Page 1 of 1

Use Bootable USB Drives in a VM -- VB Bootable USB Mounter

Posted: 22. Nov 2012, 07:32
by japzone
------------------------------------
VirtualBox Bootable USB Mounter v1.1
------------------------------------

by Japzone

This is a bash script front-end for VirtualBox's VBoxManage. It makes the complicated process of mounting a Bootable USB drive in a Virtual Machine on Ubuntu very simple.

Requirements:
-Ubuntu(Tested on v12.04, Should work on any Ubuntu based Distro)
-VirtualBox(Tested on v4.2)

The reason I created this script was because of the lack of other options. If you search google looking for methods you'll find that non of them work reliably(especially on Ubuntu). I finally found a reliable way to do it using VirtualBox's own tools but it involved a really long and hard to remember command. So I built myself this script and then decided I'd spruce it up and share it with the community.

This script should work fine no matter where you put it or what you name it. As long as VirtualBox is installed it should work. The script basically works by creating a VMDK file that redirects to the USB drive's physical address(ie: /dev/sdc), then you just mount the VMDK file in a Virtual Machine and boot from it. Fairly simple and the entire process uses nothing but tools included with VirtualBox and Ubuntu. One danger with this method is data corruption caused by the Drive being mounted by two different OSs, to prevent that the script automatically unmounts all partitions on the USB Device before creating the VMDK.

This Script has two modes:
-Walkthrough Mode - Activated by running the script with no options
-Command Mode - Activated by running the script with the '-c' option

The Walkthrough Mode provides a step-by-step guide to using the script and makes things quite simple, but it's heavy on user interaction. Every step along the way the script will ask you questions and double check you entered in something correctly.

The Command Mode allows Advanced users to send variables straight from the command line using flags. This has the benfits of quicker use and integration into other apps and scripts, but also increases the risk that you could make a mistake and screw something up.

Command Mode Usage -

Code: Select all

Options:
	-c -- switch off walkthrough mode and enable 'Command Flags'
	-h -- show this help info
Command Flags:
	-f -- directory to save VMDK
	      (defaults to home directory if not specified)
	-d -- drive to mount to VMDK 
	      (partitions won't work)

	-s -- silence all output and just execute
	      (!!NOT RECOMMENDED!!)
As it is now the script is very stable and should run without problems. If you encounter problems or have feature suggestions please leave a comment on the FileTrip page or on this VirtualBox Forum Thread.

Downloads:
Latest Version
FileTrip Page(Download, Subscribe to Updates, and more)
Download Page

All Versions
v1.1:
FileTrip Download
VB-Boot-USB-Mount-v1_1.tar.gz
v1.1
(3.6 KiB) Downloaded 649 times
v1.0:
FileTrip Download
VitualBox-Bootable-USB-Mounter.tar.gz
v1.0
(3.15 KiB) Downloaded 139 times
ChangeLog:
v1.1--Fixed VMDK overwrite bug, added check for mounted partitions before trying to unmount them, updated help info
v1.0--First Stable Release
Known Bugs:
-The VMDK(usb.vmdk) isn't overwritten by the script so it needs to be manually deleted before making a new one. Should have a fix out soon. fixed