Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 0 down vote accepted

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
share|improve this answer

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!

share|improve this answer
    
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 '13 at 15:01
    
I am not using VirtualBox OSE. –  Axlrod Feb 1 '13 at 9:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.