On your VMWare ESXi host, you can redirect an attached local USB device/flash drive/disk inside the virtual machine. This technology is called USB Passthrough and available starting from ESXi 4.1.
Suppose, our task is to redirect an external USB 3.0 drive locally connected to the ESXi 6.7 host into a virtual machine. We need to access a drive to quickly copy data directly from the VM to a separate USB drive.
VMWare USB Passthrough
The Passthrough mode allows to redirect a physical device connected to an ESXi host directly to the guest OS of a virtual machine. In the Passthrough mode you can grant a virtual machine the direct access to a USB drive, a modem or a PCI/USB controller.
To redirect a USB device in ESXi, you will need some main components:
- Arbitrator is a separate service on an ESXi host that scans connected physical USB devices, routes USB device traffic between a host and a VM, and controls access to a device (only one VM may use a connected USB device). A USB arbitrator can track up to 15 USB controllers simultaneously.
- USB controllers — a uSB controller must be installed both on a physical host and on a virtual machine.
To install a USB controller for a VM on VMWare ESXi, open the VM settings and add a new device — a USB controller. When adding a USB controller, select its type:
- USB 2.0 (EHCI+UHCI) – a controller supporting USB 2.0 and USB 1.1 devices;
- USB 3.0 (xHCI) – supports fast USB 3.0 devices, requires virtual hardware version 8 or higher.
USB 3.0 mode is available starting from vSphere 5.5 patch 3. To support it, an xHCI controller must be running in a guest OS. Windows 8.1/Windows Server 2012 R2 and Linux with the kernel version 2.6.35 or newer are supported as a guest OS.
Passthrough a USB Device to ESXi VM
In the native USB Passthrough mode, you can connect a physical USB device from a host to a VMWare virtual machine.
The main requirements and restrictions of this redirection method:
- Virtual Hardware 7.0 or newer;
- You can provide direct access to a USB device for one VM only;
- The maximum number of redirected USB devices for a VM is 20;
- A VM boot from the attached USB device is not supported.
After adding a virtual USB controller for a VM, you can redirect a USB drive connected to the host:
- Add a new Host USB device in the VM settings and click Add;
- Select a connected USB device from a dropdown list to add it;
- To enable vMotion support for a VM with a connected physical USB drive, check the Support vMotion while device is connected option;
- Then the USB drive will appear in the guest OS of the virtual machine.
There are some vMotion restrictions for VMs with a redirected USB drive:
- You cannot stop or pause a VM. If you turn on the machine, you must manually migrate it to the host the USB device is connected to;
- DPM mode is not supported, since vCenter can shutdown a host with the connected USB device to save power;
- ESXi hosts with the VM and a physical USB device must be accessible via vmk0 over TCP Port 902.
If when adding a new USB device a vSphere client shows a message that no USB devices has been found (No available USB devices), it means that VMWare doesn’t support your USB drive for redirecting in the USB passthrough mode. You can find the list of compatible USB devices on the official VMWare website (the list is not long). Check the “USB Devices tested for Passthrough from an ESXi Host to a Virtual Machine in ESXi 6.7” section in the article https://kb.vmware.com/s/article/1021345.
In this case you can redirect the whole USB controller to a VM from the ESXi host.
VMware PCI Passthrough (VMDirectPath): Redirect a USB Controller to a VM
Another, less convenient method to provide access to a physical USB device from a VM is to redirect the whole USB controller from the ESXi host. This mode is called VMDirectPath. To use it, your server chipset must support Intel Directed I/O or AMD I/O Virtualization Technology (AMD IOMMU), and this mode is enabled in the BIOS/UEFI settings.
If only one USB controller is installed on a server and you redirect it to a VM, you won’t be able to use USB devices connected to your host locally (keyboard, mouse). In this case, it is better to add an additional PCI USB controller to the server.
If a host has multiple USB controllers, you can identify a connected USB device and a controller number through the ESXi shell. To display the list of USB devices:
# lsusb -v | grep -e Bus -e iSerial
Find the line related to the USB drive in the output. For example:
Bus 002 Device 003: ID 0280:a00c Toshiba America Info. Systems, Inc.
Then identify a root hub and its iSerial by the controller number (Bus02, in this case):
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 3.0 root hub iSerial 1 0000:00:1D.0
If you do not see your USB drive, try to disconnect it physically and connect it again. See the vmkernel.log
to learn if USB Arbitrator has detected your drive:
tail -f /var/log/vmkernel.log | grep -i USB
cpu0:33271)<6>usb 4-2: new SuperSpeed USB device number 5 using xhci_hcd cpu0:33271)<6>usb 4-2: New USB device found, idVendor=0480, idProduct=b207 cpu0:33271)<6>usb 4-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 cpu0:33271)<6>usb 4-2: Product: External USB 3.0 cpu0:33271)<6>usb 4-2: Manufacturer: TOSHIBA cpu0:33271)<6>usb 4-2: SerialNumber: 20180528012427F cpu0:33271)<6>usb 4-2: Vendor: 0x0480, Product: 0xb207, Revision: 0x0315 cpu0:33271)<6>usb 4-2: Interface Subclass: 0x06, Protocol: 0x50 cpu0:33271)WARNING: LinScsiLLD: scsi_add_host:573: vmkAdapter (usb-storage) sgMaxEntries rounded to 255. Reported size was 65535 cpu0:33271)<6>usb-storage 4-2:1.0: interface is claimed by usb-storage cpu0:33271)<6>usb 4-2: device is not available for passthrough cpu0:33271)<6>usb 4-2: usbfs: registered usb0405 cpu0:33207)<6>usb-storage 4-2:1.0: suspended
If the USB drive is not detected by your ESXi host, make sure that the usbarbitrator
service is running:
#chkconfig usbarbitrator --list
So we have got the number of the USB controller to be redirected to the VM.
- To redirect a physical USB controller, select the ESXi host your VM is running on and go to Manage -> Settings -> PCI Devices -> Edit;
- In the list of PCI devices select the required USB controller by its ID (in my example, it is
00:1D.0
, the controller is calledC610/X99 series chipset USB Enhanced Host Controller #1 Intel Corporation
); - The status of the USB controller must change from Unavailable (This device is not currently available for VMs to use) to Available (This device available for VMs to use). Click OK;
- To save the changes, restart your ESXi host;
- After booting the host, turn your VM off and add a new device (New Device -> PCI Device -> Add). Select your USB controller in the dropdown list (for example,
0000:00:1D| Intel Corporation USB Chipset…
);If when adding a PCI device the following message appears in the VM settings: “Warning: The VM will not power on until its memory reservation equals its memory size
”, reserve some RAM for your VM. - Power on the VM on and make sure that the USB drive has appeared in the guest OS. In my case, the connected USB drive “Toshiba External USB 3.0 USB Device” has appeared in the guest Windows Server 2012 R2.
In the VMDirectPath mode, you can redirect up to two physical PCI devices to a VM. There are some restrictions on a VM with a redirected PCI device: you cannot pause a VM (Suspend), perform vMotion to another host (it is logical, since you are bound to a physical controller) or create snapshots.
Hyper-V also supports the redirection of physical USB devices to a VM.