Disk passthrough for vms in Proxmox

Kovasky Buezo | Apr 4, 2024 min read

edited on: May 17, 2024

Intro

It has always been recommended to give ZFS full disk control, so after placing my raid card in HBA mode, I went ahead and gave full disk control to my TrueNAS vm.

Figuring out the id of the disk

Typically, disks are labeled as /dev/sdX, but this can change when adding other drives or moving them around. To circumvent this, it is better to figure out the specific id of the disk to be passed through. To do this, execute the following:

lshw -class disk -class storage

Write down the serial and then issue the following command:

ls /dev/disk/by-id/ | grep <serial>

Write this down, as it will be needed for the passthrough.

Map the drive to the vm

After you’ve found the id of the disk, you can issue the following command:

qm set <vm_id> -scsi<disk_number> /dev/disk/by-id/<disk_id>

Navigate to /etc/pve/qemu-server. Locate your vm configuration by vm id and open the file for edition.

It should look something like:

...
scsi<disk_number>: /dev/disk/by-id/<disk_id>,size=<disk_size>
...

If left untouched and multiple disks are passed through, TrueNAS will complain about duplicate serials. To fix this, you have to add the serial option. It should now look like:

...
scsi<disk_number>: /dev/disk/by-id/<disk_id>,serial=<serial>,size=<disk_size>
...

This will now passthrough the disk with a unique serial.

Done!

Reboot the vm and the disk should appear.