VirtualBox Bootable USB Mounter 1.1

  1. 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.

    -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 -
    -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

    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 this FileTrip page or on the VirtualBox Forum Thread.