VirtualBox USB Setting on Ubuntu and Fedora


Setting up USB on Ubuntu

After I had a taken a look into the insides of Ubuntu 7.04, I managed to get VirtualBox's USB-Support working there in such a way that the user only needs to be a member of a group called usbusers. This howto describes how I did it.

Basically, you just have to tell Ubuntu that a group called usbusers should have read and write access to all usb devices.


Create a group called usbusers
Add yourself to this group
Edit the file /etc/udev/rules.d/40-permissions.rules (for this, you must have administrative privileges)

Search for the following lines

# USB devices (usbfs replacement) SUBSYSTEM=="usb_device", MODE="0664"
Change them to the following

# USB devices (usbfs replacement) SUBSYSTEM=="usb_device", GROUP="usbusers", MODE="0664"

Restart your PC


You should now have write access to all USB devices.



How to setup USB with udev on Fedora

This is how I resolved my VirtualBox USB issues on FC6 which uses udev.

First decide what group usb devices will be in and add yourself to that group. I chose usb (if you choose something else, be sure to update the chgrp commands below).

Add /etc/udev/rules.d/51-usb-group.rules:

SUBSYSTEM=="usb_device", RUN="/etc/udev/scripts/set-usb-group '%c'"


Add /etc/udev/scripts/set-usb-group:

#! /bin/sh
ret=false
if [ "$1" != "" ]; then
if [ -f /proc/$1 ]; then
chgrp usb /proc/$1 && \
chmod g+rw /proc/$1 && \
logger udev/set-usb-group: `ls -l /proc/$1`
ret=true
fi


if [ -e /dev/$1 ]; then
chgrp usb /dev/$1 && \
chmod g+rw /dev/$1 && \
logger udev/set-usb-group: `ls -l /dev/$1`
ret=true
fi
else
logger udev/set-usb-group: Called without device arg
exit 0
fi


if ! $ret; then
logger udev/set-usb-group: Setting permissions on device $1 failed
fi

And then, Reboot your machine. Done!


Revel in how much faster VirtualBox is than VMPlayer.

3 comments:

Anonymous said...

One has to be careful with these instructions. I followed them (Fedora) and afterwards the system refused to boot anymore (entering the infinite cycle of reboots).

I had to boot from a rescue cd, mount the / manually and reverse the changes... :/

So, a word of warning: unless you're confident you're able to restore your system should sth similar happen to you, don't mess with /etc/udev

t.

navaburo said...

Thanks for the info, but these instructions did not work for me (on Fedora 9). I don't mean to say that they won't work for others though.

My USB devices simply show up on the host as normal, but the Guest sees nothing (other than the USB controller).

If anyone knows why, do reply (I will get the followup email).

Gil said...

worked for me - on centos 5.2 with virtualbox 1.6.2.

navaburo: you should see the usb device connected , but greyed out. this means that you have permission problems with virtual box, and this was the aim of this tip.
if you don't the usb device at all thru the guest, then you should check your usb settings thru the machine's settings.

Delicious Digg Technorati Reddit Furl BlinkList Yahoo! NewsVine Netscape Google Live Bookmark Netvouz Squidoo StumbleUpon Magnolia.png