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

Hi David,
I hope you don't mind me contacting you about some persisting problems
that I have with getting a USB device mounted under virtualbox (running XP
as the guest OS). The host system is Ubuntu Hardy running on a Thinkpad
T61.

I followed the instructions on your blog and edited
/etc/init.dmountkernfs.sh and created a USB filter for the device under the
Settings/USB in Virtualbox (pressing the USB button with the "+" and then
simply "OK"). However, when I boot XP in Virtualbox the entry for the
device in Devices/USB is still grayed out and I cannot connect to the
device

It also does not make a differences whether the device is mount under
Linux or not (which is does just fine). Furthermore, there is also no
difference whether or not the UBS device is plugged in at the time of the
XP boot in Virtualbox.

I also tried editing /etc/init.d/mountdevusbfs.sh and /etc/fstab as other
posts have suggested, but the problem remains. I cannot mount any USB
devices in Virtualbox.

Do you have any further suggestions of what I could try to get the device
mounted?

Thanks a lot for taking the time.

Best wishes,
Jan

Try to put only the additional line in mountkernfs.sh and re-comment the line in mountdevusbfs.sh and comment out usbfs stuff in fstab. Run 'mount' without command-line arguments and see what is mounted. You should only have have usbfs mounted once. I had some problems because I had usbfs mounted twice.

BTW, this is what I get when I run "mount | grep usb"

$ mount |grep usb
procbususb on /proc/bus/usb type usbfs (rw)

I have nothing in fstab that is usb related, I have not changed mountdevusbfs.sh. I added the following to to mountkernfs.sh

domount usbfs usbdevfs /proc/bus/usb -onoexec,nosuid,nodev,devgid=1002,devmode=664

When I run "groups" as my regular user (david) that I use to run Virtualbox, I get "vboxusers" showing up in the list

When I run "cat /etc/group|grep vboxusers" I get:

vboxusers:x:1002:david

Make sure to do a reboot. Let me know if this still doesn't work. Once we find the solution I'd like to add it to my post to make the information more complete. What version of Virtualbox and Ubuntu are you using?

I installed VirtualBox through the Synaptic Package Manager. I was having problems with getting the USB support enabled for my Windows XP guest OS. Come to find out the version installed by Ubuntu was the OSE version, so it doesn't have USB support. I backed up my guest files and uninstalled the OSE version and downloaded and installed the .deb file from VirtualBox's site. Didn't need the backup since the newly installed version updated the files to work with the new version. Now I have USB support. Just something to check before pulling your hair out about USB not working.

I have made all the edits you recommended above. All my settings appear to be OK, but I still cannot access my USB devices in my XP Virtual Machine. They appear on the device list but are "grayed out". I did notice that when I ran "cat /etc/group|grep vboxusers" I get:
vboxusers:x:1001: (my username (jeffrey) does not appear after the second colon.

I am using VirtualBox 2.1.0
Ubuntu 8.10

Thanks for any help you may be able to offer.

Jeffrey

If your username is not after the vboxusers group name, then you are not in the group. Use the Ubuntu user admin (System->Administration->Users and Groups) to add yourself to the group.

This worked for me - ubuntu 9.04 with windows 7 guest, was greyed out until i checked the vboxusers group and added myself to it. Thanks for the help guys.

I have a Dell Vostro 1700 notebook with Ubuntu 10.10 and Windows XP Professional (Service Pack 3) as guest OS in Oracle Virtualbox 3.2.10. Initially webcam option under USB Devices was greyed out. On typing "grep vboxusers /etc/group" in a terminal did not reveal my username. Just by adding my username to vboxusers group, webcam became usable inside virtual box. Thanks guys for the trick!

To add my username, I just followed:
(System->Administration->Users and Groups->Manage Groups->vboxusers->Properties and checking my username). After adding, you must restart the computer and restart the guest OS. If you see LED of webcam glowing for a second while booting of guest OS, you are through! By the way, before doing all the above, please make sure you have installed latest version of guest additions for your Virtualbox!!

I cleaned out all of the garbage that the other links said to do and had only the mountkernfs command and it works fine. Crank up XP and it recognizes the flashdrive. Works for me ...

Dave,

thanks a lot for your quick response.

I tried all your suggestions, but I still cannot mount my USB flash drive

I am using Ubuntu Hardy Heron (8.04) and Virtualbox 1.6.6

I commented the lines in /etc/init.d/mountdevusbfs.sh and /etc/fstab that
was sugested by the other posts.

I did reboot before trying all of the below.

output of:

$ mount | grep usb
procbususb on /proc/bus/usb type usbfs (rw)

output of:

$ cat /etc/group | grep vbox
vboxusers:x:122:glaescher

(glaescher is my username)

I did already add the next line to /etc/init.d/mountkernfs.sh

domount usbfs usbdevfs /proc/bus/usb -onoexec,nosuid,nodev,devgid=122,devmode=644

just before the comment starting with:

# Mount spufs, if Cell Broadband processor is detected

Here is the output of "VBoxManage list usbhost"

VirtualBox Command Line Management Interface Version 1.6.6
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.

Host USB Devices:

UUID: 3c7dc59a-6834-428b-8e8f-6d466be2d06a
VendorId: 0x0483 (0483)
ProductId: 0x2016 (2016)
Revision: 0.1 (0001)
Manufacturer: STMicroelectronics
Product: Biometric Coprocessor
Address: /proc/bus/usb/001/003
Current State: Unavailable

UUID: 7249b281-e1e3-4d16-5caa-cb8e4fe1aa36
VendorId: 0x13fe (13FE)
ProductId: 0x1f00 (1F00)
Revision: 1.16 (0116)
Product: Patriot Memory
SerialNumber: 078501AA0001
Address: /proc/bus/usb/007/003
Current State: Unavailable

So it does recognize the Flash Drive (Patriot Memory, no comments on the name, please. It's embarrassing, but a huge and fast drive).

I also tried to set a global USB filter using the command:

VBoxManage usbfilter add 0 -target global -name "Patriot Memory [0110]" -action hold -active yes -vendorid 13FE -productid 1F00 -product "Patriot Memory" -remote no -serialnumber 078501AA0001

but the command produces and syntax error:

"Syntax error: Mandatory options not supplied"

However, I did include all the mandatory options that are listed under VBoxManage --help

As for the local usbfilters, I ran "VBoxManage showvminfo "Windows XP SP3" and got:

VirtualBox Command Line Management Interface Version 1.6.6
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.

Name: Windows XP SP3
Guest OS: Windows XP
UUID: ed4b8461-36f3-417f-46bc-bdd156126fe7
Config file: /home/glaescher/.VirtualBox/Machines/Windows XP SP3/Windows XP SP3.xml
Memory size: 512MB
VRAM size: 16MB
Boot menu mode: message and menu
ACPI: on
IOAPIC: off
PAE: off
Time offset: 0 ms
Hardw. virt.ext: off
State: powered off (since 2008-09-12T06:29:44.090000000)
Monitor count: 1
Floppy: empty
SATA: disabled
Primary master: /home/glaescher/.VirtualBox/VDI/Windows XP SP2.vdi (UUID: 34c3e23a-d42c-42d3-518b-b2bb80e4d1e6)
DVD: Host drive /dev/scd0
NIC 1: MAC: 080027A63E0B, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: Am79C973, Reported speed: 1000 Mbps
NIC 2: disabled
NIC 3: disabled
NIC 4: disabled
UART 1: disabled
UART 2: disabled
Audio: disabled (Driver: Unknown, Controller: Unknown)
Clipboard Mode: Bidirectional
VRDP: disabled
USB: enabled

USB Device Filters:

Index: 0
Active: yes
Name: Patriot Memory [0110]
VendorId: 13FE
ProductId: 1F00
Revision: 0110
Manufacturer:
Product: Patriot Memory
Remote: no
Serial Number: 078501AA0001

Index: 1
Active: yes
Name: COWON SYSTEM, Inc. COWON A3 [0316]
VendorId: 0E21
ProductId: 1020
Revision: 0316
Manufacturer: COWON SYSTEM, Inc.
Product: COWON A3
Remote: no
Serial Number: 3238204E6F76

Shared folders:

Name: 'winshare', Host path: '/home/glaescher/winshare' (machine mapping), writable
Name: 'ppgdata', Host path: '/projects/ppgdata' (machine mapping), writable
Name: 'latlearn', Host path: '/projects/latlearn' (machine mapping), writable
Name: 'home', Host path: '/home/glaescher' (machine mapping), writable

Guest:

Statistics update: disabled

So the 2 USB filters specific to the VM are recognized.

Do you have any other ideas?

Thanks a lot,
Jan

I attached a couple screnshots. I have no filters. (see 2.png)

I see VBoxManage sees the shares. So are the devices greyed out in the VM, as opposed to mine? (see 1.png)

Other other thing I can suggest is to try to run it as root, or start going crazy with chmod 777 on the /proc/bus/usb folder or something.

I am using Version 1.6.2 of Virtualbox. That might be the problem, I had heard of some features breaking in newer versions of VirtualBox. It looks like it's still available: http://www.virtualbox.org/wiki/Download_Old_Builds
Or, maybe you can try Version 2.0?

I also have the same problem, as my usb scanner is grayed out, my usb webcam too... My settings are exactly like what you recommend in your guide, I am running Hardy, with a virtualbox 2.0, and winxp inside... I can't seem to find a solution...

Hi Jan,

I had the same problem and found the solution in this document

I think, one thing that is missing in your configuration is an additional entry in the file /etc/udev/rules.d/40-basic-permissions.rules.

Don't forget to restart udev service after that and your virtual machine, in this order.

I hope this helps,
regards,
Andrzej

I didn't need to add the group="vboxusers" to the 40-basic-permissions.rules file or the stuff in mountdevsubfs.sh. I just put:

domount usbfs usbdevfs /proc/bus/usb -onoexec,nosuid,nodev,devgid=<gid>,devmode=664

as explained in the post. Thanks Andrzej, hpoefully if Jan tries your suggestion it will work.

i've tried all of this and still the device appears unavailable.

i'm trying to make a winblows xp guest see my pda so i can use activesync.

MS CRAP!!!

this is really frustrating... i'm a linux n00b and i have searched google and the ubuntu forums for hours.
and still not working.
any help would be awesome

I used the info on this blog and am able to mount usb flash drive on the XP guest on a Ubuntu 8.04 host. Thanks David Grant.

I follow the instruction also in the https://help.ubuntu.com/community/VirtualBox#USB but I continue to have the USB devices grayed.
I'm tryng to solve this task to sync my IPOD with Itunes.
Still not working

For others,
in the help.ubuntu they said you need the PUEL version and not the OSE (that has not USB support).

dex

I changed this line
domount usbfs "" usbdevfs /proc/bus/usb -onoexec,nosuid,nodev,devgid=,devmode=664

to

domount usbfs "" /proc/bus/usb usbdevfs -onoexec,nosuid,nodev,devgid=,devmode=664

That's right! I had to do that too, but I forgot to update this blog post. Thanks!

I went through all the suggestions and advices above, but VirtualBox didn't recognise my USB drive.
Finally I opened the xml file belonging to my windows xp installation, $HOME/.VirtualBox/Machines/windows\ xp/windows\ xp.xml (I quit VirtualBox before I did this)
I changed the line that read:
<USBController enabled="false" enabledEhci="false"/>
to:
<USBController enabled="true" enabledEhci="true"/>

and after that I was able to access my USB drive

Hi,

Thanks for the hints!
One additional comment:
I'm on Intrepid. I had to install Virtual Box version 2.0.6

Regards,
Falk

I am running Ubuntu 8.04

I have edited the mountkernfs.sh file as you suggested. Both

domout usbfs usbdevfs /proc/

and when that did not work

usbfs "" /proc/ ...

Before coming across you post, I had tried editing the mountdevsubfs.sh or /etc/fstab as some other internet sources have suggested. Each helpful hint brings be to greyed out USB devices. Better than no devices, yet I can not use my USB devices in my guest OS of WinXP SP3.

I have also created a group called usbuers, and every trick I can find on the web. Any more help would be great. Thank you.

chmod -R 777 /proc/bus/usb

it made it work for me, after trying many of the above fixes . Obviously it's a permissions issue at work. I am currently tracking own the root issue and will report with a cleaner fix later. This fix won't survive reboots, obviously.

thank you this has been very useful tip

Greetings from Costa Rica
Pura Vida!!

Thanks, David.

For me, it works on Ubuntu 8.10 (64b) even after I commented the lines I put before in /etc/init.d/mountdevsubfs.sh and /etc/fstab as I was told by an other internet source.

Gerard.

First of all: Thanks so much for your guide! It worked!

I wanted to say that I had first tried the guide here for Ubuntu Intrepid: https://help.ubuntu.com/community/VirtualBox#USB. that DID NOT WORK for me. I then followed your guide, and that didn't work either. What I had to do is go back and UNDO what the Ubuntu Community's guide suggested before your guide would work.

Again, many thanks.

use only one method, this one because it works better than the ubuntu guide's method. this is the method that got my iPod Touch working in my XP host. use only one method! :)

Thanks for the tutorial,

I'm also on Ubuntu 8.10, followed the instructions and it didn't work until I found out that I wasn't part of the vboxusers group. After I joined I had to reboot and worked smoothly.

By the way, the USB device I wanted to get working is a Garmin ANT stick, for a GPS, which is a "very-proprietary" device using specially designed communication protocols, so if it works for this, everything can.

Thanks a bunch for this. Worked for me on Ubuntu Intrepid (on the apparently-notorious Thinkpad T61, no less) by doing just as you said. (I am in the vboxusers groups, and I didn't previous try anything else specific to making USB work.)

I'm a little worried about enabling something "deprecated", but it works so I'll take it.

I still cannot make this work. I'm running Ubuntu 8.10 host with XP guest on Virtualbox 2.1.4

the results of my '$ mount |grep usb' is

procbususb on /proc/bus/usb type usbfs (rw)

can anyone give me any suggestions?

Worked flawlessly! Followed short and concise guide as-is, reboot and USB works in XP.

Again, like the other T61 owner, I didn't not try any other guides/techniques prior to this one. Running Ubuntu Intrepid 64bit and VirtualBox 2.1.4 (closed-source edition).

Works also under Ubuntu 9.04 (Jaunty) + Virtualbox 2.2.
But "somewhere after /proc" is not enough. The mentioned line should be placed at the end of the do_start () function. Otherwise it didn't work for me.

Worked like a champ on Ubuntu 9.04 32bit. Just have to make sure that you add yourself or whatever user that you need to the vboxuser group. Thanks a lot for the guide!!!!!!

Thanks David! This worked for me. (Hardy Host/Jaunty Guest)

I was pulling my hair out, because it didn't work at first. Although I did exactly what you wrote.

"mount | grep usb" showed one line exactly like yours, I couldn't find any problems.

I finally checked /etc/fstab and I found a line in there referring to usbfs. I didn't check it sooner, cause how could something be there I never added?

The thing is I DID add this line a year ago when I needed it to make USB work with my guests running under VMWare Server.

Took that old line out. Rebooted. Everything worked like a charm in VirtualBox.

So that's just a hint for anyone who's struggling with this config. Make sure the /etc/fstab isn't mounting something else for usbfs that you don't want!

Hello...
I am trying to make what you are saying and I can't
Can you please check if I made it corect?

#! /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
        #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
}
 
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<code>

You have to put

"domount usbfs "" /proc/bus/usb usbdevfs -onoexec,nosuid,nodev,devgid=124,devmode=664"

after

"domount proc "" /proc proc -onodev,noexec,nosuid"

In Jaunty, before you boot the guest, simply do this.

Open Settings>USB
Plug in your device, but ensure it's unmounted in the host
Enable USB controller
Add filter from device (and pick your device)

It worked for me without any mucking around with text files.

Can anyone else confirm that this works on a freshly installed Jaunty system?

For me it is working OK with my old 256 MB pendrive...

... but I am still working on how to install my laserjet printer via USB...

hi david
i have exactly the same problem. i am using suse 11.1 with the closed source version virtualbox 2.2.2. i am allready a member of the vboxusers group.
so i want to implement the next step of your description here. but wehn i am trying:
sudo gedit /etc/init.d/mountkernfs.sh
then i end with: "(gedit:5957): Gtk-WARNING : cannot open display:.

i am a windows crack which want to find his way into linux. but it is so hard, while understand one system and try to do so in a different one! i am quite new here and getting confused sometimes while trying to fix problems in linux.

please: can you send me a step by step manual how to fix this error?

thanks

matthias

Try editing with a different editor. Try:

nano -w /etc/init.d/mountkernfs.sh

or

kate /etc/init.d/mountkernfs.sh

or use vim or emacs if you know how

hi david

sorry that i am comming back. but i tryd every tipps an tricks on your side here. it took me about one day. but i still can not use my usb devices, such as a garmin device and my u3 usb stick..

this is what i have checked and tryed:
- i have installed the closed virtualbox version.
- i am a member of the vbox users.
- i installed the version 2.2.2 and after this the new one 2.2.4.
- remember after each smale change i allways rebooted my system!
- in virtualbox configruation of the wxp machine i added the required usb filters.
- when i startup the wxp machine, under device --> usb devices, i can see the filters but they are allways grayedout. in the taskbar of the wxp machine it shows me the information: no usb devices attached!
- when i attach a common usb stick to my workstation then suse will recogize it an i can use it under linux.

- when i start the: "/etc/init.d/mountkernfs.sh" it was empty.
- i added: domount usbfs usbdevfs /proc/bus/usb -onoexec,nosuid,nodev,devgid=,devmode=664
- then i added: domount proc /proc proc -onodev,noexec,nosuid
- the file contains now this two lines:
domount proc /proc proc -onodev,noexec,nosuid
domount usbfs /proc/bus/usb usbdevfs -onoexec,nosuid,nodev,devgid=1000,devmode=664 (1000 is my gid)
- i first added the first line and checked it after a reboot.

in a feedback above there is something written about the: do_start () function. what exactly does this mean? since no such function is visable in my: "/etc/init.d/mountkernfs.sh".
if nessesary how is the exact syntax of this?

- i changed the permissions: chmod 777 on the /proc/bus/usb

- interesting is that: mount |grep usb shows simly nothing!

- i removed all lines refering to: usbfs in: /etc/fstab

- the settings in: /home/matthias/.VirtualBox/Machines/wxp_client/wxp_client.xml is: "USBController enabled="true" enabledEhci="true".

any help is welcome.

thanks matthias

Pages

Add new comment