My ongoing experiences with Ubuntu, and later Mythbuntu, as a media center with MythTV. I'm also using the system for a virtual machine server, a mediawiki server and a general all around home infrastructure base.

Saturday, December 13, 2008

USB devices not appearing in VMs

Hmmm, I went to use a USB device in my Win XP win and it wasn't showing up (Under VM/Removable Devices/USB Devices). This sure seems familiar but I can't find a blog post about it. A quick google turned up this hint which I really remember doing before. In fact I have a /etc/init.d/ file with the changes applied, so I know I did.

However when I re-applied those changes I got an error running the script (see end of post).

Poking around a little more I found this advice which seemed cleaner, except it was a little flawed, when I tried adding the line as given to /etc/fstab, it didn't help and I noticed that if I actually tried to invoke the line, I got the following error:

# mount /proc/bus/usb
[mntent]: line 10 in /etc/fstab is bad

The "usbfs" on the begining seemed wrong to me, so I dropped that, resulting in the following line:

/dev/bus/usb /proc/bus/usb usbfs auto 0 0

Then I restarted VMWare ("/etc/init.d/vmware restart") and my USB devices appeared!

Changes I made to /etc/init.d/

# diff -c
*** 2008-12-13 08:19:38.000000000 -0600
--- 2008-12-13 08:20:25.000000000 -0600
*** 39,44 ****
--- 39,51 ----
   # Mount /dev/pts. Master ptmx node is already created by udev.
          domount devpts "" /dev/pts devpts -onoexec,nosuid,gid=$TTYGRP,mode=$TTYMODE
+  #
+  # Magic to make /proc/bus/usb work so USB devices appear in VMWare
+  #
+  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
  case "$1" in

Error from I got from those changes:
# /etc/init.d/ start
Usage: mount -V                 : print version
       mount -h                 : print this help
       mount                    : list mounted filesystems
       mount -l                 : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount [-t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
       mount -a [-t|-O] ...     : mount all stuff from /etc/fstab
       mount device             : mount device at the known place
       mount directory          : mount known device here
       mount -t type dev dir    : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
       mount --bind olddir newdir
or move a subtree:
       mount --move olddir newdir
One can change the type of mount containing the directory dir:
       mount --make-shared dir
       mount --make-slave dir
       mount --make-private dir
       mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
       mount --make-rshared dir
       mount --make-rslave dir
       mount --make-rprivate dir
       mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using  -L label  or by uuid, using  -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say  man 8 mount .
ln: creating symbolic link `/dev/bus/usb/devices': File exists