How to boot a USB disk as a virtual machine in VirtualBox

VirtualBox does not provide a way to boot a USB disk in a virtual machine. It can be achieved it though by creating a virtual disk from the USB disk and booting up a new VM with that newly disk associated.

1. Plug in the USB disk into your host linux box and find out what device name is assigned to it either with:

# dmesg
...
...
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
Vendor: Kingston Model: DT Ultimate G2 Rev: PMAP
Type: Direct-Access ANSI SCSI revision: 00
SCSI device sda: 62586880 512-byte hdwr sectors (32044 MB)
sda: Write Protect is off
sda: Mode Sense: 23 00 00 00
sda: assuming drive cache: write through
SCSI device sda: 62586880 512-byte hdwr sectors (32044 MB)
sda: Write Protect is off
sda: Mode Sense: 23 00 00 00
sda: assuming drive cache: write through
sda: sda1
sd 2:0:0:0: Attached scsi removable disk sda
...
...

or simply by getting the attached disks with:

# fdisk -l

2. Once we know the USB disk’s device file, /dev/sda, we will use VBoxManage to create a VirtualBox virtual disk pointing to /dev/sda:

$ VBoxManage internalcommands createrawvmdk -filename ~/VirtualBox\ VMs/HardDisks/usbdisk.vmdk -rawdisk /dev/sda

Above command creates a virtual disk named usbdisk.vmdk under ~/VirtualBox\ VMs/HardDisks/ and outputs:

RAW host disk access VMDK file /home/lupas/VirtualBox VMs/HardDisks/usbdisk.vmdk created successfully.

3. Now create a new virtual machine using VirtualBox’s wizard and set the usbdisk.vmdk virtual disk as the start-up disk.

4. Boot the VM up and you’ll be booting from your USB disk. Do not delete that VM as it will help you to boot any USB disk as long as the Linux kernel assigns /dev/sda to it when you plug it in.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s