How do you automount usb drives directly to VirtualBox in ubuntu 12.04
2 Answers
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
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!
-
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.– OyiboJan 15, 2013 at 15:01
-