Wednesday, September 03, 2008

VirtualBox & USB

To get USB support in VirtualBox, you first need the non-opensource version. Get this by adding the appropriate repository listed on the VirtualBox site noted below. The authentication key is also listed in my sources. After it is installed, do the following:

1. After installation, you must add yourself as a user to the "vboxusers" group (System-->Administration-->Users and Groups). Unlock and click Manage Groups. Then find vboxusers, click properties, and put a check next to your user name.

2. Edit the /etc/init.d/mountdevsubfs.sh file by uncommenting (i.e. deleting the # symbols) to four lines in the section labeled "# Magic to make /proc/bus/usb work." After editing the section, it should look like the following:
# Magic to make /proc/bus/usb work
#
mkdir -p /dev/bus/usb/.usbfs
domount usbfs "" /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
ln -s .usbfs/devices /dev/bus/usb/devices
mount --rbind /dev/bus/usb /proc/bus/usb

Then save the file.

3. Next, edit the file called "/etc/udev/rules.d/40-basic-permissions.rules." For example, type:
sudo gedit /etc/udev/rules.d/40-basic-permissions.rules
In Hardy, you want the section called "# USB devices (usbfs replacement)" to look like this:
# USB devices (usbfs replacement)
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664", GROUP="vboxusers"
SUBSYSTEM=="usb_device", MODE="0664", GROUP="vboxusers"

You are basically adding the "GROUP" stuff. After the edit, save the file.

4. Finally, you will need to run the command "/etc/init.d/mountdevsubfs.sh start" before you start VirtualBox each time. To automate, this you can just add the command to rc.local. You want to add the stated command just before the line "exit 0." So do the following:
sudo gedit /etc/rc.local
Then, add the above stated command. After the edit, my file looks like this:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# VirtualBox USB tweak
/etc/init.d/mountdevsubfs.sh start

exit 0


5. Finally, reboot your computer.

Sources:
VirtualBox repositories
VirtualBox authentication key (Right Click and choose "Save link as..."
Ubuntu Community Documentation on VirtualBox
VirtualBox FAQs (text search for USB)

No comments: