VirtualBox USB with Windows XP guest in Ubuntu Hardy or Intrepid

[img_assist|nid=366|title=|desc=|link=none|align=right|width=145|height=150]
First of all, USB will not work in VirtualBox if you are using the Open Source Edition (OSE) of VirtualBox. Get the full closed-source edition of VirtualBox from their website. There are many differences between the open-source edition and the closed-source version and one of them is USB.

I finally got USB working with Windows XP running as a guest inside VirtualBox running on a Ubuntu Hardy host. First find out what the group id of the vboxusers group is:

$ grep vbox /etc/group
vboxusers:x:<gid>:david

Then, enable the deprecated /proc/bus/usb inteface:

$ sudo gedit /etc/init.d/mountkernfs.sh

Add the following line after /proc is mounted, at the end of the do_start() function.

#for hardy:
domount usbfs usbdevfs /proc/bus/usb -onoexec,nosuid,nodev,devgid=<gid>,devmode=664
#for intrepid:
domount usbfs "" /proc/bus/usb usbdevfs -onoexec,nosuid,nodev,devgid=<gid>,devmode=664

replacing <gid> with the <gid> you found in the first step. Make sure to reboot. This didn't work for me until I rebooted. There you have it. You shouldn't have to edit /etc/init.d/mountdevsubfs.sh or /etc/fstab as some other internet sources have suggested.

Comments

It worked! I did it as the first post says. I also changed /etc/init.d/mountdevsubfs.sh before i found this instructions, but that did not help me. Host system is Ubuntu Hardy, guest system is Windows XP. Thanks!

finally i got it worked.. thanks

thanks a lot, david...now i can connect my EPSON R230 to XP virtual machine. I really need this to have an easily printer maintanance.

but i think you miss some details :
1. first we have to add our username to vboxusers group. Go to System > Administration > User and Groups. Unlock it, then click "Manage Group". Find the vboxusers, and edit its properties, and add you username to the group.

2. From my workaround, I placed the additional code of [domount usbfs "" /proc/bus/usb usbdevfs -onoexec,nosuid,nodev,devgid=,devmode=664] near the" }" char, as follow

do_start () {
	#
	# Get some writable area available before the root is checked
	# and remounted.
	#
	RW_OPT=
	[ "${RW_SIZE:=$TMPFS_SIZE}" ] && RW_OPT=",size=$RW_SIZE"
	domount tmpfs "" /lib/init/rw tmpfs -omode=0755,nosuid$RW_OPT
	touch /lib/init/rw/.ramfs
 
	# Make pidfile omit directory for sendsigs
	mkdir /lib/init/rw/sendsigs.omit.d/
 
	#
	# Mount proc filesystem on /proc
        #for hardy:
domount usbfs usbdevfs /proc/bus/usb -onoexec,nosuid,nodev,devgid=124,devmode=664
        #for intrepid:
domount usbfs "" /proc/bus/usb usbdevfs -onoexec,nosuid,nodev,devgid=124,devmode=664
	#
	domount proc "" /proc proc -onodev,noexec,nosuid
        #
	# Mount sysfs on /sys
	#
	# Only mount sysfs if it is supported (kernel >= 2.6)
	if grep -E -qs "sysfs\$" /proc/filesystems
	then
		domount sysfs "" /sys sysfs -onodev,noexec,nosuid
		domount fusectl "" /sys/fs/fuse/connections fusectl
	fi
 
	# Mount /var/run and /var/lock as tmpfs if enabled
	if [ yes = "$RAMRUN" ] ; then
		RUN_OPT=
		[ "${RUN_SIZE:=$TMPFS_SIZE}" ] && RUN_OPT=",size=$RUN_SIZE"
		domount tmpfs "" /var/run varrun -omode=0755,nosuid$RUN_OPT
		touch /var/run/.ramfs
	fi
	if [ yes = "$RAMLOCK" ] ; then
		LOCK_OPT=
		[ "${LOCK_SIZE:=$TMPFS_SIZE}" ] && LOCK_OPT=",size=$LOCK_SIZE"
		domount tmpfs "" /var/lock varlock -omode=1777,nodev,noexec,nosuid$LOCK_OPT
		touch /var/lock/.ramfs
	fi
 
	# Mount spufs, if Cell Broadband processor is detected
	if [ -d /spu ] && grep -qs '^cpu.*Cell' /proc/cpuinfo; then
	        domount spufs "" /spu spufs -ogid=spu
	fi
 
	# Propagate files from the initramfs to our new /var/run.
	for file in /dev/.initramfs/varrun/*; do
		[ -e "$file" ] || continue
		cp -a "$file" "/var/run/${x#/dev/.initramfs/varrun/}"
	done
 
domount usbfs "" /proc/bus/usb usbdevfs -onoexec,nosuid,nodev,devgid=123,devmode=664
}

it sure works in my Ubuntu 9.04 32-bit.

U ROCK < i copied the whole code n just put it in the mountkernfs.sh and rebooted the OS, went to the system on VBox and then added the usb to the filter,=.

OMG it was crazy

I think I have followed well your instructions, but it is still not working. I am on intrepid, with virtualbox 3.0 and xp as guest os. When I plug a usb key under xp, there is a sound meaning something was plugged, but then nothing more happens. I don't know know what to do.

Here are some informations:

savourey@zabriskie ~ $ grep vbox /etc/group
vboxusers:x:125:savourey,root

the mountkernfs.sh file:

#! /bin/sh
### BEGIN INIT INFO
# Provides: mountkernfs
# Required-Start:
# Required-Stop:
# Should-Start: glibc
# Default-Start: S
# Default-Stop:
# Short-Description: Mount kernel virtual file systems.
# Description: Mount initial set of virtual filesystems the kernel
# provides and that are required by everything.
### END INIT INFO

PATH=/lib/init:/sbin:/bin
. /lib/init/vars.sh

. /lib/lsb/init-functions
. /lib/init/mount-functions.sh

[ -f /etc/default/tmpfs ] && . /etc/default/tmpfs

do_start () {
#
# Get some writable area available before the root is checked
# and remounted.
#
RW_OPT=
[ "${RW_SIZE:=$TMPFS_SIZE}" ] && RW_OPT=",size=$RW_SIZE"
domount tmpfs "" /lib/init/rw tmpfs -omode=0755,nosuid$RW_OPT
touch /lib/init/rw/.ramfs

# Make pidfile omit directory for sendsigs
mkdir /lib/init/rw/sendsigs.omit.d/

#
# Mount proc filesystem on /proc
#
domount proc "" /proc proc -onodev,noexec,nosuid

#
# Mount sysfs on /sys
#
# Only mount sysfs if it is supported (kernel >= 2.6)
if grep -E -qs "sysfs\$" /proc/filesystems
then
domount sysfs "" /sys sysfs -onodev,noexec,nosuid
fi

# Mount /var/run and /var/lock as tmpfs if enabled
if [ yes = "$RAMRUN" ] ; then
RUN_OPT=
[ "${RUN_SIZE:=$TMPFS_SIZE}" ] && RUN_OPT=",size=$RUN_SIZE"
domount tmpfs "" /var/run varrun -omode=0755,nosuid$RUN_OPT
touch /var/run/.ramfs
fi
if [ yes = "$RAMLOCK" ] ; then
LOCK_OPT=
[ "${LOCK_SIZE:=$TMPFS_SIZE}" ] && LOCK_OPT=",size=$LOCK_SIZE"
domount tmpfs "" /var/lock varlock -omode=1777,nodev,noexec,nosuid$LOCK_OPT
touch /var/lock/.ramfs
fi

# Mount spufs, if Cell Broadband processor is detected
if [ -d /spu ] && grep -qs '^cpu.*Cell' /proc/cpuinfo; then
domount spufs "" /spu spufs -ogid=spu
fi

# Propagate files from the initramfs to our new /var/run.
for file in /dev/.initramfs/varrun/*; do
[ -e "$file" ] || continue
cp -a "$file" "/var/run/${x#/dev/.initramfs/varrun/}"
done

#for intrepid:
domount usbfs "" /proc/bus/usb usbdevfs -onoexec,nosuid,nodev,devgid=125,devmode=664
}

case "$1" in
"")
echo "Warning: mountkernfs should be called with the 'start' argument." >&2
do_start
;;
start)
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
# No-op
;;
*)
echo "Usage: mountkernfs [start|stop]" >&2
exit 3
;;
esac

Can you help me?
Thanks,
David

maybe you haven't setting up which USB device you want to connect. Right Click the virtual machine (off condition), then pick "setting". Go to "USB". check all of the options. Then, click "Add filter from device" or (Alt+Ins). Pick the USB device you want to connect. Start the machine.

Thanks a lot, it worked for me on Intrepid!!
I had to add myself to the group vboxusers, as I wasn't part of it.
Gustavo

I am running VirtualBox 3.0.4 on Ubuntu 9.04. My guest O/S is Windows XP SP3. I've tried the suggestions on this page, but to no avail. I've also tried other suggestions, but to no avail. And yes, I did undo all the other crap like the changes to fstab and the like. My problem is that, while my USB device is NOT grayed out on the VBox client (I can in fact select it for mounting on the guest O/S). VBox actually unmounts it from the host O/S, but does not mount it on the guest. Has anyone had this problem? I can't figure it out for the life of me. The funny thing is that it recognizes peripherals like keyboards and mice, and it even recognizes my USB Bluetooth adaper. When it comes to flash drives and external HDDs, however, I've had no luck. Any help would be greatly appreciated.

Hi, May you update your very usefull post to Karmic Koala 64b and Virtualbox 3.0.10 ?

For me, when I call my WinXP guest from Karmic, the wifi first disconnect, but I can see the USB wifi device in Virtualbox as active, but WinXP doesn't see any network connection and doesn't allow me to build one.

I had no problems until I passed to Karmic and upgrade to Virtualbox 3.0.10.

Thanks.

Hi David. It took some time but I resolved the problem by activating in XP Device Manager Usb Controllers. There was a questionmark because the driver wasn't installed. Reinstallation of the USB controllers did the work.
Henk

I have the same problem - XP guest doesn't show any USB drives. I am running the 64 bit virtualbox 3.1.2 on ubuntu 64 bit 9.10. There is no /etc/init.d/mountdevsubfs.sh file on the ubuntu 64 bit 9.10. Your help is appreciated.

David,

I only need to run Windows for testing websites against the moribund IE, and perhaps run the occasional app. Your recommendations worked great and I have USB running fine.

Again, thank you much!

for posterity, in 9.10(Koala)adding myself to the vboxusers (sudo users-admin) and restarting worked fine.

Thanks for the tip, that worked for me on Ubuntu 10.10 as well.

In Karmic the "/etc/init.d/mountkernfs.sh" didn't exist, I simply pasted the Intrepid code with group ID substitution and now EVERY USB device is shown as "available". Very cool, but a shocking oversight of the installer.

Dear David,
Thank you very much for the solution. The file '/etc/init.d/mountkernfs.sh' was missing from Host Ubuntu 10.04 Lucid Lynx so I just followed Shane's foot steps :)

Regards,
Surender

Thanks, David, it worked fine from second time :))) Host Ubuntu 10.04 Lucid Lynx

I followed the instructions to the letter to no avail nothing worked. I paid close attention to the following line
domount usbfs usbdevfs /proc/bus/usb -onoexec,nosuid,nodev,devgid=124,devmode=664

and realized that I have devgid= <124>.

Thanks for the tip. Adding user to the group did the trick.

Hello ,

I am a first time user of Linux n Virtual Box, get along with VMWare Player.

I have Ubuntu 10.04 LTS and installed Virtual Box 4.1.4 i cant access my usb, i have same frustuation, that Virtual Box has XP installed n updated.

I have tried all i could for a first time linux user, i dont have that USB option when starting my Virtual OS (XP) , is there any first steps to start to troubleshoot.

How does VMware Player works?

Thnx

Kubuntu 11.04
virtualbox 4.1.2
USB won't work while don't add my user to virtualuser-group and reboot host system.
now all in done. Thanks this blog - third result in google-search by keyword "virtualbox usb on guest windows xp".

Pages