In this article, we will look at how to pass through a physical hard disk (HDD/SSD) or USB storage to a virtual machine running on Proxmox VE.
How to Passthrough Physical Disks (HDD/SSD) to a Proxmox Virtual Machine?
The Proxmox VE web interface allows you can add only USB disks or flash drives to the virtual machine. To pass a physical hard disk (passthrough mode) to a Proxmox virtual machine, you must use the hypervisor shell. The
qm set command is used to do this.
qm set <vm_id> -[virtio|sata|ide|scsi][№] /dev/sd[a|b|c|...]
vm_id– Virtual machine ID (in the Proxmox WebGUI GUI it is specified before the virtual machine name)
[virtio|sata|ide|scsi][№]– virtual disk controller type and interface number
/dev/sd[a|b|c...]– a physical device to passthrough
List the physical disks on the hypervisor:
For example, you want to add the /dev/sdb1 disk partition to the VM. It is possible to use the device address to passthrough the disk to the VM, but this is not recommended. The fact is that the disk path can change when adding, disconnecting, or rearranging disks. Therefore, it is better to use its UUID or serial disk number (ID) to pass through a disk.
To get the UUID:
# blkid /dev/sdb1
If the disk does not appear, you will need to partition and format it first.
Check if the disk is displayed in the /by-uuid directory:
# ls /dev/disk/by-uuid/
If you do not see your UUID in the output of the command, you will need to use the disk ID or the path to it (/dev/sdb1).
You can get the disk serial number with the command:
# lshw -class disk -class storage
Copy serial value. For example, Serial: D221KDV1Z
Display the identifiers of the hard disk and the partitions on it by their serial number:
# ls -l /dev/disk/by-id | grep D221KDV1Z
For example, the command gave me this disc ID:
Open the Proxmox web interface and remember the ID of the virtual machine you want to connect the physical disk to (
119 in my example).
To pass through the disk to this VM by UUID, run the command:
# qm set 119 -virtio2 /dev/disk/by-id/0b56138b-6124-4ec4-a7a3-7c503516a65c
To add a physical disk/partition by ID and serial number:
# qm set 119 -virtio2 /dev/disk/by-id/ata-WDCxxxxxx-xxxxxx_D221KDV1Z
Or you can specify the disk path (not recommended)::
# qm set 119 -virtio2 /dev/sdb1
Check that your disk has been added to the VM configuration file:
# cat /etc/pve/qemu-server/119.conf
Something like this should appear in the configuration file:
Check that the new drive appears in the VM Hardware tab of the Proxmox interface.
After the hypervisor is restarted, the mapped disk will remain mounted in the VM.
If you have a Windows guest operating system installed in the Proxmox VM, it may not be able to recognize the new drive. In order for Windows to detect the physical disk drive on the virtio controller, you need to install the VirtIO driver according to this guide.
If you want to passthrough a disk from a RAID controller, you must use the -virtio(x) format, not a -scsi(x).
To disconnect the hard disk from the Proxmox virtual machine, run the following command
# qm unlink 119 --idlist virtio2
Adding USB Drive to Proxmox VM
You can add any USB device from the host to the Proxmox virtual machine directly from the PVE web console.
- Open the Proxmox VE web interface;
- Locate the virtual machine you need and go to the Hardware tab;
- Select Add -> USB Device;
- Select the USB device that you want to passthrough from the list. You can use one of two modes:
Use USB Vendor/Device ID – If you need to pass a USB device through to the VM, regardless of which USB port it is connected to.
Use USB Port – full physical USB port redirection, where any device connected to the specified USB port is passed to the VM.
In our example, this is Mass Storage Device. Enable the Use USB3 option if required.
- A line appears in the VM configuration with information about the connected USB stick;
- Reboot the VM and check that the new USB drive is recognized by the guest OS.
You can also passthrough the USB drive to the VM from the shell. First, check how your USB device is recognized by the host OS:
If it’s a USB drive, view information about its partitions and file system:
# fdisk -l
To pass a USB drive to a Proxmox virtual machine, specify its number and the USB device ID that you get using the lsusb command. For example
# qm set 119 -usb0 host=0bba:b020
If it’s a USB 3.0 device, use the command:
# qm set 119 -usb0 host=0bba:b020,usb3=yes
To disconnect the USB drive from the virtual machine:
- Make sure that the device is not being used in your guest operating system (when you unmount the device, the error message “Unmount device is busy” should not appear)
- From the Proxmox console, remove the USB device from the guest VM:
# device_del <idofyourdevice>
- Remove the USB drive from the VM configuration in the Proxmox web interface or run the command:
# qm set VMID -delete usb0