Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 2154  / 2 Years ago, fri, november 4, 2022, 9:01:14

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


More From » 12.04

 Answers
3

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/^[ ]*//')
if [ ! -z "$address" ]; then
su - YOURVBOXUSER -c "VBoxManage controlvm YOURVBOXNAME usbattach $address"
fi
fi

[#35641] Sunday, November 6, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bearous

Total Points: 226
Total Questions: 116
Total Answers: 136

Location: Guernsey
Member since Sun, Jan 10, 2021
3 Years ago
;