Sunday 25 January 2009

Enable Guest USB Access on VirtualBox

Although I have been using Linux exclusively for a long time now, there are still occasions where some pesky applications demand a Windows environment. For those rare moments, I have Windows XP installed as a guest OS on VirtualBox. VirtualBox is an absolutely wonderful virtualization tool that provides almost every function I need from a Windows box.

Recently however, I had to plug in a USB device to the Guest OS and I found out that the USB device menu is grayed out, preventing me from switching the device over from the host to the guest. I tried messing with the settings but none seemed to have an effect. A quick search of the internet revealed this article which worked like a charm!

First create a new group and add yourself to it
sudo groupadd usb
sudo usermod -G usb `whoami`

Find out the gid of the new group by running the following command
MYGID=`cat /etc/group | grep usb | awk -F ":" '{print $3}'`
Create a new entry in fstab
sudo echo "none /sys/bus/usb/drivers usbfs devgid=$MYGID,devmode=664 0 0" >> /etc/fstab
Restart the computer
sudo reboot

Now when you start VirtualBox, the USB devices can be freely assigned to the guest OS.

1 comment:

Anonymous said...

hi there and thanx for that. this way it works fine if you only use virtualbox but all my other usb-things were no longer useable.

in my example, my umts-modem was no longer accessible (usb0).

i did the following to fix:
changed the mountpoint to a free directory. i made one with "mkdir /usbfs" and used that instead of /sys/bus/usb/drivers.

now everything works fine.

best wishes, boris goroncy