Connecting USB devices to a virtual machine in VirtualBox

Last update: 03/09/2025
Author Isaac
  • The support USB advanced in VirtualBox requires Extension Pack and, in Linux, belong to vboxusers.
  • USB filters automate device capture; the Devices menu allows you to manage them on the fly.
  • For maximum compatibility, prioritize USB 2.0; USB 3.0 works with Extension Pack and drivers adequate.
  • It is possible to boot a VM from a physical USB by creating a raw VMDK with VBoxManage.

Connect USB in VirtualBox

You may have just connected a memory, printer, or dongle to the host computer and are wondering why the virtual machine it doesn't detect it. VirtualBox does not enable USB access to the guest system by default., so you need to prepare the environment to “move” that device from your physical computer to the VM.

The good news is that the process is simple if you follow a clear sequence: install the appropriate Extension Pack, check permissions (on Linux, vboxusers group), configure USB controller and device filters in the VM and use the Devices menu to capture or release hardware hot boot. Plus, if you need to go further, you can even boot a VM from a physical USB drive.

What is USB passthrough in VirtualBox and how does it work?

usb vb

When we talk about “USB passthrough,” we mean allowing a device connected to the host to be controlled by the guest system, as if it were plugged directly into the VM. The host hands over control of the device and offers it to the guest, which means that the host stops seeing it while it is captured by the virtual machine.

In macOS this is very clearly noticeable: when capturing a pendrive from the VM, Finder stops showing it. When you close the virtual machine or release the device, it will reappear as usual in the MacIf you plug in the USB with the VM powered off, it will mount on the host; if the VM is powered on and a filter is present or you capture it from the menu, it will be mounted on the guest.

VirtualBox offers USB 1.1 (OHCI), 2.0 (EHCI), and 3.0 (xHCI) controllers. For performance, it's common to enable USB 2.0 or 3.0, but there are nuances: USB 3.0 requires the Extension Pack that matches the version of VirtualBox to be installed. and also on older guest systems such as Windows 7, xHCI often causes problems; in that case, it's better to stay with 2.0 to avoid incompatibilities.

The key tool for automating the use of a specific device is the USB Filter. By adding a filter associated with a device (for example, a USB flash drive from a specific manufacturer), VirtualBox will automatically capture that USB as soon as it is connected and the VM is running, without you having to manually go to the menu to find it. In environments Windows, You can also use PowerShell to detect USB events and automate complementary actions.

Prerequisites: Extension Pack and Guest Additions

VirtualBox is distributed under GPLv3, but advanced USB functionality (EHCI/xHCI), among others, is provided through the Extension Pack, which uses the PUEL license. This extension package is a must have to properly enable USB 2.0/3.0 and must match the exact version of VirtualBox installed.

   5 Best Programs to Draw on Your PC

Installing it is straightforward: go to the official website of downloads In VirtualBox, locate the Extension Pack section and download the 'All supported platforms' option. Then open VirtualBox, go to Tools > Extensions, press the '+' button, Select the downloaded file, accept the license and authenticate. when it asks you to. It will be installed in seconds.

If you are using Linux as a host, there is an additional permissions step: Your user must belong to the vboxusers group to be able to manage USB devices from VirtualBox and, if you need, learn how to Detect USB events in Linux. You can add the user with the method you prefer (system GUI or terminal) and log back in to apply the changes.

sudo usermod -aG vboxusers NOMBRE_DE_USUARIO
# Alternativa habitual:
sudo adduser NOMBRE_DE_USUARIO vboxusers

Guest Additions, on the other hand, are a set of drivers and utilities that you install within the guest system. Although USB support doesn't depend on them, Improve overall performance, pointer integration and synchronization, so it's a good idea to install them. On the VM, go to Devices > Insert Guest Additions CD Image, open the installer (on Windows, run as administrator), and Restart the guest to apply changes.

Enable USB support on each virtual machine

With the Extension Pack already installed, go to the virtual machine settings (gear icon, or Machine > Settings). In the USB section, activate the controller and choose the appropriate mode: USB 1.1 (basic), 2.0 (recommended in most cases) or 3.0 (if your guest supports it well).

To have the VM assign a specific USB device to the host as soon as it's connected, create a USB Filter. Physically connect the device to the host, return to the VM's USB section, and press the '+' button to add it to the list. The filter will save identifiers such as supplier and product, so it will capture that device (and matching models) as soon as the VM is up.

The resulting behavior is as expected: If the VM is booted when you plug in the USB, it will be assigned to the guestIf the VM is powered off, the device will remain with the host. You can hot-move the device using the Devices menu, as explained below.

On Apple devices, some users prefer to consolidate the filter with the VM powered off to ensure detection. It's as simple as adding the filter with the memory pinned and starting the VM; from then on, every time you plug in that USB while the guest is running, it will automatically switch over.

  1. Open VirtualBox and select the virtual machine.
  2. Go to Settings > USB and enable USB 2.0 or 3.0 as appropriate (for wide compatibility, USB 2.0 is a safe bet).
  3. Connect the device to the host and press the '+' button to create an associated filter.
  4. Save the changes, start the VM, and test device detection within the guest.

Capture and release devices from the hot menu

If you don't want to use filters or need to move devices in a timely manner, use the runtime menu. From the VM window, go to Devices > USB Devices and you'll see a list of hardware connected to the host. Click on the desired device to capture it; it will appear marked with a tick to indicate it's assigned to the VM.

  Can you use Roku without Wi-Fi? Find out how to do it

To disconnect it from the guest, repeat the process: Devices > USB Devices and uncheck the hardware in use. Upon release, the host will remount it. if applicable (for example, it will reappear in the macOS Finder or File Explorer on the host Windows).

Important Caution: Do not capture a USB drive that is mounted and has files open on the host.When you reassign it to the VM, that volume is abruptly unmounted from the host, and you may lose data. First, safely eject it on the host and then capture it on the guest.

Particularities in the host macOS

On Mac, the typical sequence for a Windows VM is: open VirtualBox, with the VM created go to Settings > Ports > USB and select the mode (best 2.0 for compatibility), connect the device to the Mac, Press the '+' icon to create the device filter and save. From that moment on, when the VM Boot, the USB will be transferred to Windows transparently.

As long as the USB is assigned to the VM, Finder will not show the volumeThis is normal. If you close the VM and reinsert the USB drive at any point, it will remount in macOS and you'll be able to use it normally.

A compatibility nuance that is worth remembering: Older guests, such as Windows 7, may not play well with USB 3.0.. One does not detect the device With xHCI, change the controller to EHCI (USB 2.0) in the VM settings and try the connection again.

Linux Host: Permissions and Quick Check

If you get a permissions error when trying to capture a USB or the device bounces back to the host, check that your user belongs to vboxusers. Without belonging to that group, VirtualBox cannot attach USB devices. at Virtual machines in GNU/Linux.

Confirm your membership with the groups command, and if you made any changes, log out and log back in. Without logging in, new permissions are not applied and you will still have the same problem when capturing devices.

groups
sudo usermod -aG vboxusers NOMBRE_DE_USUARIO

Boot a virtual machine from a physical USB drive

VirtualBox doesn't include a button in the interface to boot directly from a USB, but it's possible with a little trick: create a "raw" virtual disk that points to the physical USB. This is done with VBoxManage and requires administrator permissions. on the host system.

Before you begin, connect the USB drive to the system you want to boot and close any VMs using it. Open a console with elevated permissions and navigate to the VirtualBox installation folder. In Windows, the default directory can be opened like this:

cd %programfiles%\Oracle\VirtualBox

Now create the VMDK descriptor pointing to the physical disk on the USB drive. Replace # with the correct disk number (in Windows, you can determine this using tools like Disk Management). The base command would be the following:

VBoxManage internalcommands createrawvmdk -filename C:\usb.vmdk -rawdisk \\.\PhysicalDrive#

With the C:\usb.vmdk file generated, open VirtualBox as administrator, create a new VM (or edit an existing one) and, when configuring the storage, choose “use an existing virtual hard disk file” and select that VMDK. On boot, the VM will attempt to boot from the contents of the USB. as if it were their main album.

  CPI Files – Definition, Features, Uses, Compatible Programs

Please note that working in raw mode with a physical device entails risks: Make sure you select the correct disk and avoid destructive operations on that media if you don't want to overwrite it. If your guest firmware doesn't boot from the USB, check the boot order in the virtual BIOS/UEFI and make sure the system on the USB is actually bootable.

Tips and common problems

Misaligned versions of the Extension Pack and VirtualBox cause subtle errors (USB not showing up, disconnections). Check that the Extension Pack exactly matches your version of VirtualBox (same build number) and reinstall it if you have updated the hypervisor.

If capturing a pendrive from the menu does not transfer it to the VM, it is usually because the host has it mounted and in use, which generates recognition errors. Unmount or eject the device on the host before capturing it and avoid having applications open that keep files locked.

When a USB 3.0 device is not working properly in the VM (crashes, not recognized by the guest), try EHCI. Temporarily reverting to USB 2.0 eliminates many compatibility issues., especially on older guests or those with incomplete drivers.

Guest Additions aren't mandatory for USB, but they help make things run more smoothly, especially with pointer and screen integration. After installing them, always reboot the guest machine so that the drivers remain active.

In GNU/Linux, it is not enough to create the vboxusers group; You must add the user and log in again to inherit the permissions.If you skip this step, you'll see access errors when trying to connect the device.

With all the above in order — Extension Pack installed, user in vboxusers if applicable, appropriate controller (2.0 or 3.0), well-defined filters and correct use of the Devices menu — Connecting a USB to a VM in VirtualBox becomes a routine gesture.And if you need to go a step further, booting from USB using raw VMDK gives you the flexibility to test physical media as is within a virtual machine.

Troubleshoot USB Device Recognition Errors in Windows
Related article:
How to Fix USB Device Recognition Errors in Windows