VirtualBox 2: How To Pass Through USB Devices To Guests On An Ubuntu 8.10 Host

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Thu, 2009-04-02 18:13. :: Ubuntu | VirtualBox | Desktop | Virtualization

VirtualBox 2: How To Pass Through USB Devices To Guests On An Ubuntu 8.10 Host

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 03/19/2009

This short guide shows how you can pass through USB devices (such as a USB flash drive) to VirtualBox guests on an Ubuntu 8.10 VirtualBox 2 host. USB support is available only in the VirtualBox PUEL (closed-source) edition, not in the OSE edition, so make sure you have the PUEL edition installed.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

As I mentioned in the introduction, USB support is available only in the closed-source edition of VirtualBox 2, so please make sure you have that version installed, for example as shown in this tutorial: Installing VirtualBox 2.0 On An Ubuntu 8.10 Desktop. USB support won't work if you're using the OSE version that is available in the Ubuntu repositories!

I'm using a USB flash drive in this tutorial to show how USB support works, and I have an Ubuntu 8.10 guest where I want to use that USB flash drive.

Other tutorials on the net (like this one) might tell you that you have to edit /etc/init.d/mountdevsubfs.sh and /etc/udev/rules.d/40-basic-permissions.rules to make USB support work; I found that USB support works without these changes (maybe because I'm using a newer VirtualBox version?).

 

2 Enabling USB Support For A Guest

Before you power on the guest, go to the Details tab of that guest in VirtualBox and click on USB:

Select Enable USB Controller and Enable USB 2.0 (EHCI) Controller and click on OK:

 

3 Using USB Devices In The Guest

Now plug in your USB device (e.g. your USB flash drive). Its icon should appear on the host desktop. Then power on the guest:

After the guest has started, right-click on the USB icon in the VirtualBox "task bar" and select the USB device that you want to use in the guest:

After a few seconds, the icon of the device should disappear from the host desktop and reappear on the desktop of the guest:

You can now work with the USB device in the guest.

One important thing to note is that if you write to the USB device, please unmount it properly before you deattach it from the guest and reattach it to the host because otherwise your changes will be lost. (Instead of unmounting the device manually, you can also shut down the guest - this will also unmount the USB device.)

If you want to reattach the USB device to the host, right-click on the USB icon again in the VirtualBox "task bar" and select the USB device (please make sure you've unmounted it - see my previous note!). (Another way to reattach the USB device to the host is to simply shut down the guest.)

After a few seconds, the icon of the USB device disappears from the guest desktop and reappears on the host desktop:

 

4 Links


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Fri, 2010-01-08 06:45.
I am running a Windows XP virtual machine on a Ubuntu Karmic host.  Your solution does not work.  You say, "After the guest has started, right-click on the USB icon in the VirtualBox "task bar" and select the USB device that you want to use in the guest," but the mass storage USB device is grayed out (its listed, but grayed out), and cannot be selected.  And, yes, I am part of the vboxusers group.
Submitted by Anonymous (not registered) on Wed, 2011-03-02 15:44.
If the devices are greyed out, be sure to add your user in the group vboxuser.  After your next logon everything will be working.
Submitted by altair4 (not registered) on Mon, 2009-04-06 12:23.

Actually, if all you need is access to a usb mass storage device ( sorry no usb webcam ) you can easily do that with the OSE version. If linux is the host simply add another shared folder to the host's /media directory. When you insert a usb device it is automatically  mounted to  /media on the host and visible  to the guest through the shared folder.

The advantage is that the host is always in control of the device and the system and the user never gets confused over when or if and by whom the device was unmounted. I haven't figured out yet how to do that on a Windows host.

Submitted by Scormen (not registered) on Thu, 2009-04-02 22:04.

Nice howto, thanks.

But, it is still not possible to use the webcam, is there a method to slove that problem?

Greetz,
Kris

Submitted by diverbelow (not registered) on Mon, 2009-04-06 16:27.

This I've known with the latest version of VB.  I also found great success of adding a line in fstab for VB:

none /proc/bus/usb usbfs devgid=500,devmode=664 0 0

You might be asking why I had great success by adding that line, well I bought my parent TomTom 130 for a present and they are running Hardy (at that time), and when I updated the device I was using Ubuntu 8.10 and Windows XP was able to see the GPS. So when I gave them their present, their VB Windows XP did not see their GPS, so I did a fresh install of Ubuntu 8.10 and when I attached their GPS to VB Windows XP, XP did not see the device. So I remembered what I added that entry into fstab, so I ssh into my machine and copied that line to my parent machine and their VB saw their GPS device.

Hope this helps people.

Submitted by Frank (not registered) on Thu, 2009-12-03 17:14.

The key to this issue, not just for webcam but other devices too, is this line in your /etc/fstab:

 

none /proc/bus/usb usbfs devgid=500,devmode=664 0 0 

 

The devgid has to match your gid of your vboxusers group. For some reason the gid changed on my system, I don't know how or why but I suspect it was part of the numerous updates that vbox urges you to do. If you need to change this value a reboot of your host will likely be required due to proc/bus/usb being busy.

 

BTW, the fstab entry was done by the installation script so there is no longer a need to insert it manually.