How to add a USB device using vboxmanage
- 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
from squirrel:
ReplyDeleteHi! Great article, thank you. Old, but this mostly all still worked. One thing that was missing, which it looks like you started to do, was the actual "attachusb" command with the UUID you get from the "list usbhost" command. Like so:
VBoxManage controlvm "somevm" usbattach UUIDHERE
Once I did that the drive showed up in my guest.
Thanks again!