lauantai 4. tammikuuta 2014

VirtualBox and USB configuration

Piece of cake?

But things work for me out of the box! Well, if that's the case, you can stop reading here :) But for me this wasn't the case. I needed a Windows box - Windows 7 to be exact - to run certain R/C related software by DJI, so I decided to go for VirtualBox instead of VMWare Fusion of which my license had already expired.

I use OSX Lion on the host machine and this is where the problems started.

Device already in use?

Ever tried to connect USB device into your virtual host only to see the error of device being already in use? 

I encountered this problem again and didn't quite find enough elaboration with googling on how to configure it properly, so here goes. 

VirtualBox Configuration

First of all, download (Oracle) VirtualBox of your preferred version. Now notice that on the download page there is a package called: VirtualBox Extension Pack. You'll need that, so make sure you download a version matching your VirtualBox binary.

Install VirtualBox as usually, then click on the Expansion Pack and it should configure on top of that automatically.

Now, this is important. You'll need to filter out the USB device on the host to get it working in the VM. There's several ways to do this and here's one. This was made with VirtualBox 4.6.3 so some things might vary between different versions, but here's the gist of it. 

I assume you have the Guest Additions installed. But if you don't, turn on your VM and after it has booted up, go to VirtualBox: Devices -> Insert Guest Additions (or just press ctrl-D). Do this, reboot if needed and continue: 

1. Turn of your VM and attach the USB device
2. Go to your VM settings -> Ports -> USB
3. Enable USB 2.0 (EHCI) Controller (this will fail if you haven't installed the expansion pack mentioned earlier) 
4.  Click the green plus sign / USB device to see the list of your currently connected devices
5.  Click on the device you want to pass through to the VM
6.  Double click on the added device and clear all settings apart from: Name, Vendor ID and Product ID (I'm not sure why this is needed, but for some reason I did not get my USBs to work without doing so)
7. Set the Remote to: any 
8. Click OK
9. Unplug your USB device and restart the VM

And voilá! You should be able to pass the USB directly to the VM without OSX (or any other host OS) capturing the device first.

Still not working?

Now this has not happened to me, but several people seem to have noticed that if the VM has more than one CPU allocated, the USB configurations won't work correctly. It's weird, but easy to fix:

1. Turn of your VM
2. Go to your VM settings -> System -> Processor and select 1 CPU
3. Click OK and restart your VM