KVM Pass through disk Partition – By Label or UUID

diskmanagementkvm-virtualizationpassthrough

Normally, when I passthrough a disk to a VM I use the entire disk. I am looking at attempting to passthrough a partition in KVM. First question is that possible/ok? Looking at this doc it seems to be the way to go which supprised me.

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/virtualization_administration_guide/sect-virtualization-adding_storage_devices_to_guests-adding_hard_drives_and_other_block_devices_to_a_guest

Important

Guest virtual machines should not be given write access to whole disks or block devices (for example, /dev/sdb). Guest virtual
machines with access to whole block devices may be able to modify
volume labels, which can be used to compromise the host physical
machine system. Use partitions (for example, /dev/sdb1) or LVM
volumes to prevent this issue.

My next question is I have read about how to do this via /dev/sdX and by diskID, but DiskID seems to be the entire disk, IE:

https://lime-technology.com/forums/topic/34659-hard-drive-passthrough/

<disk type='block' device='disk'>
        <source dev='/dev/disk/by-id/ata-Corsair_CSSD-F120GB2_1109650632000461003B' />
        <target dev='hdc' bus='virtio' />
</disk>

And the whole point of using the by-id is because /sdX can change. I was wondering if I can use LABEL or UUID? Anybody with experience, I'd like some input.

Thank you

Best Answer

If you look carefully at the disk symlinks in /dev/disk/by-id you will see that there are also links for each partition on the block devices. For instance:

ata-INTEL_SSDSC2BB480G7_PHDV644200N5480BGN
ata-INTEL_SSDSC2BB480G7_PHDV644200N5480BGN-part1
ata-INTEL_SSDSC2BB480G7_PHDV644200N5480BGN-part2
ata-INTEL_SSDSC2BB480G7_PHDV644200N5480BGN-part3
ata-INTEL_SSDSC2BB480G7_PHDV644200N5480BGN-part5
ata-INTEL_SSDSC2BB480G7_PHDV644200N5480BGN-part6
ata-INTEL_SSDSC2BB480G7_PHDV644200N5480BGN-part7

Use the one corresponding to your desired partition.