Ubuntu: Got usb in VirtualBox 3.0 (Updated!)

Karmic Update: and VB 3.08: All you need to do is add Virtualbox permissions to your user under users and groups….bout time!

EDIT:  With Ubuntu 9.04 and VirtualBox 3.x.x, none of the following is necessary other than adding yourself to the vboxusers group.  Hallelujah !!

Update:  I’ve just installed VB in Linux Mint 6 Xfce (8.10) and I lined through the items below that are no long needed with Ubuntu 8.10 and forward.  The rest will do the trick:

The purpose of this how-to is to get usb devices, such as printers, working in a VirtualMachine Windows environment in Ubuntu/Kubuntu. Without usb support, a virtual machine is really only good for testing, and not production.

First off, if you haven’t done so already download and install the non-free version of VirtualBox 3.x.x (no dinero, requires accepting license agreement) from here: VirtualBox 3,0

I did this in Kubuntu 8.04 RC, but below is for Ubuntu 8.04. This is written to apply to Gutsy, Ubuntu 7.10 also.

Go through the new VM set up routine in VirtualBox and install, let’s say XP in VirtualBox.

Here’s how I got usb devices working in an XP Virtual Machine in Hardy (8.04).

Add yourself to the group VirtualBox created during install called “vboxusers” The VB install creates this group, find it, don’t add another one.

Create a group named “usbusers” and put yourself in it.

sudo groupadd usbusers
sudo gpasswd -a john usbusers

Or do the above in Control Center under ‘users and groups’.

Now uncomment the 4 lines below ‘Magic to make /proc/bus/usb work’ in mountdevsubfs.sh , they will be commented out by default) so it looks like the following:

sudo gedit /etc/init.d/mountdevsubfs.sh

#
# Magic to make /proc/bus/usb work
#
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

Now then,

Modify the rules in file “/etc/udev/rules.d/40-permissions.rules” for Gutsy, and “/etc/udev/rules.d/40-basic-permissions.rules” for Hardy:
Change the lines :

From:

# USB devices (usbfs replacement)
SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, MODE=”0664”
SUBSYSTEM==”usb_device”, MODE=”0664”

To :

# USB devices (usbfs replacement)
SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, GROUP=”usbusers”, MODE=”0664”
SUBSYSTEM==”usb_device”, MODE=”0664”

Now on to……

The Grande Finale,

add this line:

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

to your /etc/fstab file (at the bottom). Just make sure that 120 is your vboxusers group (use your own number).
Reboot the computer.

Open VirtualBox and click on “Settings”.

Click on the “USB” item in the left pane to edit the USB prefs.

Click on the “Add device” button to add a filter and select your printer from the list and click on the “Ok” button.

Start your VM and Windows should detect your printer.

The above was taken mostly from various scattered posts in the Ubuntu forums, some from me, and put together here, all mods in one place, in order, for future reference.

Comments and/or edit recommendations welcomed.

23 Responses to Ubuntu: Got usb in VirtualBox 3.0 (Updated!)

  1. Thank you! It works! I have spent many hours without any luck till I see this post. Shame on virtualbox developers, the should write this manual or make use /dev/bus/usb instead of usbfs.

  2. joutlan says:

    Good point, and thank you for your comment.

  3. Ian says:

    In Hardy, the “From” lines:

    # USB devices (usbfs replacement)
    SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, MODE=”0664”
    SUBSYSTEM==”usb_device”, MODE=”0664”

    do exist, but they’re in 40-basic-permissions.rules rather than 40-permissions.rules

  4. joutlan says:

    Thank you! I’m going to look that over again when I get a chance!

  5. joutlan says:

    Thanks Ian….change tested and noted for Hardy:

    Modify the rules in file “/etc/udev/rules.d/40-permissions.rules” for Gutsy, and “/etc/udev/rules.d/40-basic-permissions.rules” for Hardy:

  6. fukazzz says:

    Wow! It really works!!! Ubuntu 8.04 + LaserJet 1320 Thx a lot! It was really a peace of magic. =)

  7. capndingus says:

    Has anyone had this work with an iPod and iTunes? I’m getting an iPhone2 on Friday, and the only machines I own with a USB 2.0 port run Linux (my three macs all have USB 1.1). I was hoping to get around installing windows directly on any of my machines (it’s been 2 years since I have had windows installed directly, and I’d really like not to go back). Do I stand a chance of using this as a way to work with my iPhone without installing windows, or waiting for syncs at 11mbit/s

  8. John says:

    I think that it probably will work. I haven’t tried though, even though I own an iPod Video. I sync it with Amarok. I did try to sync my Blackberry in an XP virtual machine, XP recognized the BB fine, but BB desktop manager couldn’t identify the BB handheld. That may have been my fault. Give it a go, and let us know!

  9. Huntsville says:

    I tried this with Ubuntu 8.04 and iTunes and a 5th Gen Video iPod. These steps worked perfectly for me and everything is working great. Thanks again!!

  10. John says:

    That’s good to know as I myself have an iPod video. thanks for the post !

  11. Chris says:

    Hi Huntsville,

    How did you get iTunes and IPOD to work? This does not seems to work for me, even though USB seems to be working. Do you have any other info about this? Thanks.

  12. Richard says:

    This helped me in Intrepid too. Thanks for the useful post.

  13. duncan says:

    thanks – this worked for a samsung e900 phone in xp under hardy

  14. luvallcomputers says:

    I am using Hardy 8.04.1. Virtual Box 2.0.2. I was having trouble make flash drives show up under winxp. The printer was working but flash drives were not. They showed on VB usb icon but were grayed out.

    I had followed several other post so did not need all the steps but it was good to check them.

    Step 1 added user/groups used gui to help me.
    Step 2, I must have already made magic line visible did not need to do any thing. (Some one might not know how to read the file if a line is commented out so might explain that for them.
    Step 3 was easy. I did do apt-get install gedit to use it in place of VI for step three.
    My virtual box was user 121 but the user gui helped with that also.

    I did not need to add filter under VB 2.0.2 just right click on the usb icon and add check mark for the usb device that I wanted added. Did need to reboot XP for flash drive to work.

    Thank you so much for the nice post. It just worked for me and now I can move files and print when needed. Great Work.

  15. Mike says:

    Please do not claim that you can write in English! I read it 10 times and still cannot understand what you are trying to say….

  16. John says:

    A Russian didn’t have any problem with it? 🙂 Tell me what it is that’s not clear, please and I’ll change it.

  17. Mark says:

    Thank you !!!

  18. Thank you for writing such a clear and easy to follow guide. Unfortunately I cannot get my system to work. I have checked, and re-checked all the files you mention

    mountdevsubfs.sh
    40-basic-permissions.rules
    fstab

    I also have the usbusers group created with my login as a member. All are correctly entered. I am farther than before. Now, all of my USB devices show up in VirtualBox in the little icon, but they are all GREYED out.

    I have Ubuntu 8.04 as the host. VirtualBox 2.06 as the software and WindowsXP SP3 as the guest OS. I have the 2.06 additions installed.

    Any further help would be greatly appreciated. Thank you.

  19. Skrean says:

    Thanks!

    After much googling I got the guide at http://www.ubuntu-unleashed.com/2008/04/howto-install-virtualbox-in-hardy-heron.html .

    It seems they missed a step or 2.

    Yours was what worked…btw …I have Sun VirtualBox 2.1.0 running on a Ubuntu Hardy Host and with an Win XP SP3 guest.

    Thanks again!

  20. john says:

    You’re welcome….actually, that was what started this blog….nowhere could seem to get the instructions right so I took it on myself 🙂

  21. Patrick says:

    Has anyone had _any_ luck with iPod shuffles and Windows XP SP3?
    I have a client that has a ipod shuffle and yet I have not been able to get it to work no matter what I do. I tried this and several other items on the virtualbox forum and still can not get it to work. If you have any more advice or input I would greatly appreciate it. Thanks!

  22. siicis says:

    Thank you!
    Connected my Nokia e65 this way!

Leave a comment