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

25 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.

The Beach Geek 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.

Mohamad 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 M 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

Sayantan 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

Sayantan said...

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

Saurabh Bhatia 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 M 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

Jbirriel 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?????

Jbirriel 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.

Crank said...

Thanks!

rdw 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 M 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.

rdw 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.