mini_banner

Tuesday, December 4, 2007

Installing VirtualBox with USB Support

VirtualBox
VirtualBox by InnoTek is a commercial and proprietary (with a limited GPL version) x86 virtualizer for Linux. It works fast and I like it more than VMware. For more info, check out it's wiki page. This guide will show you how to install both versions, the Open Source (OSE) and the Personal Use & Evaluation License (PUEL).

The Open Source Edition
This version of Virtualbox is released under the GPL. It does not have USB support and Virtual Remote Desktop support. It is the free as in freedom version and the easier of the two to setup. If you don't need USB or remote desktop support this method may be the one for you.

Download Virtualbox & Dependencies
In a terminal type:
sudo apt-get install virtualbox-ose virtualbox-ose-source

Prepare the source for kernel
In at terminal type:
sudo m-a prepare

Then install
In a terminal type:
sudo m-a auto-install virtualbox-ose

Add yourself as a virtual box user
In a terminal type:
sudo adduser username vboxusers
You must replace userame with your user name!


Personal Use & Evaluation License Version
The PUEL version has both USB support and Virtual Remote Desktop support. It is proprietary, but is available as a free download. It's my preferred version of VirtualBox.

Step 1: Download and Install VirtualBox

You can download the PUEL version of Virtualbox from Innotek website here.
Once your download is complete double click the .deb file and install VirtualBox.


Step 2: Setup User groups & USB support
Add yourself as a virtual box user
In a terminal type:
sudo adduser username vboxusers
You must replace userame with your user name!

Add USB support to you fstab file
In a terminal type:
sudo gedit /etc/fstab

And paste this line to the end of your fstab
none /proc/bus/usb usbfs devgid=1001,devmode=664 0 0

Enable USB
In a terminal type:
sudo gedit /etc/init.d/mountdevsubfs.sh

You need to look for this section:
#
# 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

And delete all the # shown, it should look exactly like this.

#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

Find your vboxusers number
In a terminal type:
sudo gedit /etc/group

Look for this, the number following it is your vboxusers number
vboxusers:x:NUMBER

Next you have to add a line to your /etc/fstab to allow usb mounting
In a terminal type:
sudo gedit /etc/fstab

Add this line:
none /proc/bus/usb usbfs devgid= enter
vboxusers number HERE,devmode=664 0 0

Allow access to /proc/bus/usb/
in a teminal type:
sudo chown -R root:vboxusers /proc/bus/usb

Once you Log out or reboot, you can start VirtualBox (Applications>System Tools>Innotek VirtualBox)


Step 3 - Configuring VirtualBox
When you first run VirtualBox there is a wizard that automates setting up your virtual machine. Follow the steps, it's incredibility easy.

Once you have setup up your VM you should configure a couple of things in Settings.

First enable IO APIC
enable_io

Then enable USB, and add the USB devices to your VirtualBox with the green USB icon. Deivces must be plugged in for this to work. Use the green and red USB icons to add and remove USB devices.
enable_usb

55 comments:

Ryan Lovelett said...

Thank you so much for the help on this. I've been trying to get that working for the longest time.

Unknown said...

Thanks. This is a great resource that I've bookmarked for future reference.

bocon_boliviano said...

i just can say something: god bless you men.

Unknown said...

Hello,

Thanks a looot seriusly I was wondring why USB is not there, I just have one question is there is anyway I can put on the 3D support on my guest OS?

Thank you.

Graham MacLeod said...

Nice one man. I was using the open source one. I hadn't realised that the proprietary version was free for personal use.
Thanks

Unknown said...

hi,
thanks for the tutorial on usb.
but i'm not able to find the USB option on my virtual box settings..
here is the screenshot...plz help

file:///home/tan/Desktop/Screenshot.png

Unknown said...

hi,
i 've fixed the problem..
i was using the OSE . i had to use the non-free version...
thanks

Unknown said...

Thanks a lot for this amazing HOWTO, its just perfect, Ran without a mistake on gutsy for me

LoXieL said...

thanks a lot !
this was very usefull
now i use the propietary version with usb and all work deluxe ^^

marc.knuckle said...

i am sorry but i can't get it to work. i have host xp with ubunutu 7.10 guest. i have installed the usb drive on the usb section which then made xp install the 'linux usb drive' driver(???) i then followed you how-to but it still doesn't work. when you sayd to add the vboxusers number, it is 1001 which you had said to add already slightly further up so i guessed that i had to add 'vboxusers:x:1001:****-******* in that section like this 'none /proc/bus/usb usbfs devgid= vboxusers:x:1001:****-*******,devmode=664 0 0' is this right? what could i be doing wrong? i am a complete nubie to linux and just copied and pasted everything you said.

redDEAD said...

marc

This guide is for an Ubuntu Host & a Windows guest

marc.knuckle said...

does that mean no-one can help me or does someone know where i am going wrong?

Graham MacLeod said...

I wouldn't try following this how to. Try googling virtual box "xp host" "ubuntu guest"

woyzeckswoe said...

hi, i cant figure it out! i did everithing you explained in the tutorial but it doesn't work. maybe because im using hardy?

redDEAD said...

woyzeckswoe,

thats because the ose version in hardy still doesn't support usb & there is no hardy deb of the PUEL version.

Fabrizio said...

Your tutorial is too great. I have finally definitively solved my problem with USB devices, running virtualbox as a non root user. I have bookmarked this page for future references. Thanks. Fabrizio

Unknown said...

Thanks you very much this is a great tutorial. I have done everything. And its works.... partially. But when I start de Guest os that is XP Pro. Keeps asking for the USB drivers. Does the regular drivers works or is=ts has to be some other especial driver?????I have done everything. But when I start de Guest os that is XP Pro. Keeps asking for the USB drivers. Does the regular drivers works or is=ts has to be some other especial driver?????

Unknown said...

I dont have the SP2 on the guest. Culd that be the problem with the usb.

malty said...

Just one query, if a USB device, say the mouse, is already working, should it be left out of the installation, thanks in anticipation.

Unknown said...

Thanks!

Poster says said...

So I read the comment about virtualbox not yet being supported in Hardy Heron - this may or may not be related, but here goes..

I got virtualbox installed, and WinXp - but I'm wallowing in fail come the time to load the Dell Drivers. I have the resource CD -but I get an error message from the driver install app that it senses this isn't a dell machine. hmmm.. Any ideas? How can I load the dell drivers to finish config windows.
and and all help greatly appreciated.

Graham MacLeod said...

@rdw - You can't use the machine specific disk that came with your PC/Laptop. I tried installing my Toshiba one and it didn't work. Luckily I was able to download a version of XP through my college.

redDEAD said...

I used the disk that came with my dell 1501 and have had no problems.

Poster says said...

graham m/reddead - thanks for the answers.

graham - I'm not using the OS disk that came with the dell, I have a full legit copy of XP I installed, its the other dell disk, the one that contains the drivers that I can't load.
reddead - are you talking about the OS disk or the drivers disk? I take it your saying it just worked out of the box.

So question to both of you - since I think you're both talking about the OS, how did you load the drivers?
(perhaps I should try installing the OS that came with the dell - problem is I think I got Vista lite...and I really don't want that)
Thanks for the feedback.

redDEAD said...

rdw,

You dont need to load any drivers in VirtualBox. If Ubuntu/Linux can "see"/use your hardware, your virtual machine will too. I have everything working on my virtual machine, video, sound, usb, card reader and DVD drive without installing one windows driver.

Anonymous said...

I'm also getting XP asking for drivers. If they are not needed, why is XP asking for them?

Kernel Kev said...

Hi, i have Ubuntu 8.04 (Hardy) and VirtualBox 1.6.2 and i have followed the steps of making the vboxusers etc and my virtualbox allows me to add my USB devices with the correct ports etc already entered. When i load up Windows XP which runs fine, i plug in my usb pen but nothing happens, Ubuntu recognises it and displays the contents but the VirtualBox dosent and neither (obviosly) does XP. I have tried unmounting it from ubuntu then starting VB but that dosent work. The devices are listed in virtualbox but are greyed out and cant be selected, why is this?

Any help? Thanks

Unknown said...

Thanx man, excellent guide, and worked a treat!!!

Unknown said...

thanx man, excellent guide, and it worked a treat!!!

wrongloop said...

That was really easy, I was struggling with the ose version, not it's running, but as always windows has problems and have to reinstall.

xyzandme said...

It worked!
But i got stuck at one place,its preety common sense but I still got stuck.
The part where :
Add USB support to you fstab file
In a terminal type:
sudo gedit /etc/fstab

And paste this line to the end of your fstab
none /proc/bus/usb usbfs devgid=1001,devmode=664 0 0


and then again its asked to add this line and edit it with the vboxusers number.

Its redundant if one is dumb as me :p
I mean one doesnt need to add the same line again just edit the already added line.

And another thing.. this PUEL edition aint able to access the .vdi made by the OSE version of virtual box.
Or its just me.
Am a linux newbie.
Anyways good work, keep it up.
cheers!

Anonymous said...

Thank you so much for this turtorial.
I've been trying for 2-days to get USB working.

Lots of advice out there; this is the only procedure that workded for me and I'm using Version 2.02.

Fantastic advice!!!!

Tankerdog

Unknown said...

wow man, thanks you very much... I wasn't aware there were two versions and that only the PUEL has USB support. Just like a side note, Folder Sharing is supported in the OSE version by installing the VBox Guest Additions.

I successfully installed the xVM VirtualBox 2.0.6 PUEL version and got the USB support on Ubuntu 8.10 Intrepid Ibex by simply doing as you said (wrote).

Just a few things to point out:

1.- For some reason, in the "/etc/init.d/mountdevsubfs.sh" file, there were no such lines that must be editing. To overcome this, I just added the lines you as they should "look like" within the "do_start ( ) { }" function, just before the closing "}" sign.

2.- As mentioned durg when editing the "/etc/fstab" file, you can simply modify the "devgid number" by the one you got from "sudo gedit /etc/group", instead of adding a new line. Note:I first try adding both lines resulting in an "error" during the boot sequence. Error that disappeared when I got rid of the fist line and just the one with the "vboxusers:x:NUMBER" remained.

3.-durg, about if the PUEL version doesn't support OSE's *.vdi files. At least in my case, it did. In fact, I had already installed another OS before changing to the PUEL version, and the *.vdi as well as the configuration for that OS remained and worked perfectly.

# I subscribed to your site! XD

Jacob Melnick said...

OK I have a problem with this. I have VB installed and when I followed the instructions I found no:
#
# 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


So what do I do???

redDEAD said...

Jacob

USB support is now included, look at the date on the article. It's really old.

Unknown said...

Thank you very much for the detailed tutorial! This is the first one for me to work. Great Job!

PS: If you can't find the needed text in your files, just paste whatever it is said in the tutorial anywhere - it worked for me.

It would be a good idea to backup the files you change though.

NMB said...

This is awesome, BUT, the full vbx 3.0 is MUCH more of a resource hog than the OSE version...and they can't be installed parallel. AND, I can;t go back...I was loving the light and fast integrated XP with my ubuntu 9.04 install, but now i'm sad cause my machine can't handle it...and it grinds to a halt... :(

dual core amd 3.0ghz with 4gb ram...shouldn't be a problem, but it is...whaaaaaa...

Graham MacLeod said...

@NMB
My laptop isn't even as high spec as that, yet it handles v3.0 fine. Maybe you need a fresh install?

redDEAD said...

Graham is right.

NMB said...

so, this morning, I was able to roll back to the ose version and lo and behold it uses about half the ram and it doesn't feel sluggish at all. with 3.0 it felt sluggish from the start. maybe you're right and I need a fresh install, but I haven't time for that now...i'll just have to live without usb on the VM for now...not that big of a deal :)

Ramki said...

Dear redDead, I wish you would bring much more to the OpenSource World. And, the best part is, its UBUNTU.

Going great with your supportive article.

jb_galvez926 said...

This does not work for Lucid Lynx.

jb_galvez926 said...

This does not work for Lucid Lynx...

redDEAD said...

jb_galvez926,

Why would this guide need to work in Lucid Lynx, USB support is built into Virtualbox now.

This article is over 2.5 years old and about Ubuntu 7.04 or 7.10

Linjoy said...

USB support in Virtualbox on Lucid seems to only support some devices by default. If I connect my android, I can pass the usb on to my guest windows os, but my usb pendrive (Sandisk Cruzer 16GB) shows up as status:unavailable and is grayed out. The only reason for this I could come up with was some sort of size restriction, but I'm sure there's got to be a workaround

Unknown said...

Hmm....??
Whats wrong here ?
I did not have '/proc/bus/usb/'

Any Idea ?

Unknown said...

You probably have it under
/sys/bus/usb

Everything is file in linux so it's easy to find stuff with (you're not gonna believe it :) ) find command. Just do

sudo find /path/to/search -name string

Unknown said...

Everything works fine until I get to this point... Any ideas?

adam@mediacenter:~$ sudo gedit /etc/fstab
[sudo] password for adam:
adam@mediacenter:~$ sudo chown -R root:vboxusers /proc/bus/usb
chown: cannot access `/proc/bus/usb': No such file or directory

redDEAD said...

Adam,

This guide is really outdated, I can't help you in at all. New builds of virtualbox have USB support built right in without any special configuration.

Unknown said...

Can u make i vid of this im stuck and have no clue what to do it would be great email me the link to it if u can i cant check this compent everyday so it would help

Unknown said...

Can u make i vid of this im stuck and have no clue what to do it would be great email me the link to it if u can i cant check this compent everyday so it would help

Unknown said...

I'm using Natty Narwhal and I can't complete these steps.

It seems the file locations have changed?

redDEAD said...

Again this GUIDE IS OLD, DO NOT USE WITH NEWER VERSION OF VIRTUALBOX.

Unknown said...

k reverted my changes.

Host: Ubuntu Natty Narwal (11.04)
Guest: Windows XP

VirtualBox (PULE) 4

yet when I look at the device list everything is grayed out.

Unknown said...

I had success on Ubuntu 11.04.

http://ubuntuforums.org/showpost.php?p=9756001&postcount=2

It's just a matter of using the non-OS version.

When you add your user to the vboxusers group be sure to log out so it uses your changes.

Enable IO in General->Advanced->Enable IO APIC.

And then the USB section will be enabled.