If you’re one of those fancy-pants GUI users, this post probably isn’t for you.
On the other hand, if you can see the potential that awaits once you learn to control VirtualBox from the command line, you may be interested to know how to add and remove USB devices to your running VM.
Here’s the quick and dirty version:
- Ensure you actually have USB support for your target VM:
# VBoxManage showvminfo "somevm" | grep USB USB: enabled - If it’s not set to “enabled” you’ll have to add USB support to your VM. You’ll need to power off the VM to do this:
# VBoxManage modifyvm "somevm" --usb on --usbehci on - To attach a device that’s plugged into the same system as your VM (in my case, a Sony USB memory stick), grab its UID as follows:
# VBoxManage list usbhost Sun VirtualBox Command Line Management Interface Version 3.1.4 (C) 2005-2010 Sun Microsystems, Inc. All rights reserved. Host USB Devices: [...] UUID: 2a2c7255-3b90-448e-aa7a-b1c5710ddd79 VendorId: 0x054c (054C) ProductId: 0x0243 (0243) Revision: 1.0 (0100) Manufacturer: Sony Product: Storage Media SerialNumber: 6A08102832911 Address: 0x54c:0x243:256:/pci@0,0/pci108e,5347@2,1 Current State: Busy
- Create a usb filter which will tell VirtualBox to provide the USB device to your virtual machine when it’s detected as plugged in on the host:
# VBoxManage usbfilter add 0 --target "somevm" --name usbstick \ --vendorid 054C --productid 0243
- Go ahead and power on your Virtual Machine. You’ll notice that the USB device (if it’s currently plugged in) immediately becomes unavailable on the host. You can confirm that it’s attached and that you didn’t make a typo with the vendor and/or product IDs:
# VBoxManage showvminfo "somevm" [...] Currently Attached USB Devices: UUID: 582313d4-1d51-41ea-a053-ba5ac552d2e5 VendorId: 0x054c (054C) ProductId: 0x0243 (0243) Revision: 1.0 (0100) Manufacturer: Sony Product: Storage Media SerialNumber: 6A08102832911 Address: 0x54c:0x243:256:/pci@0,0/pci108e,5347@2,1
That’s it. You can mount and unmount this device now inside your VM.
You can do some neat stuff with USB and Virtualbox, but that’s a subject for another post.
This seems to be working for USB memory sticks, but doesn’t work for USB HDs. This is strange since they are both using the same module/driver. I tried it on two different systems at home with the same external usb drive (two linux systems, linux vm). I also just tried it at work with my Windows laptop and a different external usb drive (different linux vm).
I figured it out… seems like the more information I supply the easier it is for the system to add the drive to the VM.
i’m having problems with a Renasas debugger w/ USB in a virtual XP Pro vbox on XP Pro. Selected device in guest saz busy.
Cheers
Jono