Use VBoxManage to Pass Through USB device to VirtualBox VM
Written on October 5, 2021

To pass through a USB device to a VirtualBox VM on a headless machine, use the VBoxManage command.

  1. Connect your USB device to the host computer
  2. Run vboxmanage list usbhost to list connected USB devices. Make a note of the device’s VendorId, ProductId (in parentheses), and SerialNumber (in parentheses). We’ll use these later.
     $ vboxmanage list usbhost
     Host USB Devices:
     UUID:               8bc87bce-b9fc-4773-ba3c-6dbbe8d53c9b
     VendorId:           0x0bc2 (0BC2)
     ProductId:          0x331a (331A)
     Revision:           9.21 (0921)
     Port:               3
     USB version/speed:  3/Super
     Manufacturer:       Seagate
     Product:            Expansion Desk
     SerialNumber:       NBBBXX5V
     Address:            sysfs:/sys/devices/pci0000:00/0000:00:14.0/usb4/4-4//device:/dev/vboxusb/004/002
     Current State:      Available

    For the above, we’ll be using:

    • Vendor ID: 0BC2
    • Product ID: 331A
    • Serial Number: NBBBXX5V
  3. Run vboxmanage modifyvm myvmname --usbehci on --usbxhci on to enable the USB 2.0 and USB 3.0 controllers inside the VM. Replace myvmname in the command with the name of your VM
  4. Run vboxmanage showvminfo myvmname --machinereadable | grep USBFilter to review any USB filters already created for this VM. If there are any, increment the filter number below to the next available integer. Replace myvmname in the command with the name of your VM
  5. Run vboxmanage usbfilter add 0 --target myvmname --name "MyExternalHardDrive" --vendorid 0BC2 --productid 331A --remote no --serialnumber NBBBXX5V to create a filter that will make this USB device available to the VM when it appears on the host. Replace variables for VM name, Vendor ID, Product ID, and Serial Number in the command as appropriate
  6. Unplug the USB device and plug it back in to the host. The filter will apply and the device will be detected by the VM:
     $ sudo lshw -C disk
          description: ATA Disk
          product: VBOX HARDDISK
          vendor: VirtualBox
     *-disk UNCLAIMED
          description: SCSI Disk
          product: Expansion Desk
          vendor: Seagate
          physical id: 0.0.0
          bus info: scsi@32:0.0.0
          version: 0915
          serial: NBBBXX5V
          configuration: ansiversion=6


There's no commenting functionality here. If you'd like to comment, please either mention me (@[email protected]) on Mastodon or email me. I don't have any logging or analytics running on this website, so if you found something useful or interesting it would mean a lot to hear from you.