2

How do you automount usb drives directly to VirtualBox in ubuntu 12.04

0

2 Answers 2

0

I managed to solve this myself. This is only for USB Storage (which I needed)

Remember to create a usb filter on your Vbox machine that takes all USB devices and makes it available.

Create an udev rule file in /etc/udev/rules.d

I called mine 80-automnt.rules

Contents:

DRIVERS=="usb-storage", RUN+="/etc/udev/vboxusb.sh %p"

Create the /etc/udev/vboxusb.sh file.

Contents:

#!/bin/bash
vendorid=`/sbin/udevadm info --query=all --path=$1 | sed 's/E: -*//g' | grep "ID_VENDOR_ID" | awk -F"=" '{print $2}'`
modelid=`/sbin/udevadm info --query=all --path=$1 | sed 's/E: -*//g' | grep "ID_MODEL_ID" | awk -F"=" '{print $2}'`

set `/usr/bin/lsusb -d $vendorid:$modelid | sed 's/:.*//g'`
while [ ! -z "$1" ]; do
  case $1 in
    Bus) shift
    busdevice="$1"
    ;;
    Device) shift
    busdevice=${busdevice}"/$1"
    ;;
  esac
  shift
done
if [ ! -z "$busdevice" ]; then
  address=$(VBoxManage list usbhost | grep "Address:" | grep $busdevice | sed -e 's/Address://' -e 's/^[ \t]*//')
  if [ ! -z "$address" ]; then
    su - YOURVBOXUSER -c "VBoxManage controlvm YOURVBOXNAME usbattach $address"
  fi
fi
-1

As I understood, there are two versions of Virtualbox. One is open source and doesn't have the possibility to automount USB devices. There is another version with a freeware license (downloadable from the oracle website only), that would give the possibility to do so. I don't know if it really works or if it doesn't, but take a look at this.

Good luck!

2
  • Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Oyibo
    Jan 15, 2013 at 15:01
  • I am not using VirtualBox OSE.
    – Alex R
    Feb 1, 2013 at 9:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .