1

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

2

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.

  • I did look into that, but if I change the partition, isn't the "part-#" going to change, at that point I could just use /dev/sd* almost. I know that this system won't change often, so I could just partition it and use one of those two methods, but I'd like to learn how to do it "portable" style for future. – FreeSoftwareServers Feb 7 '18 at 6:49
  • I'm literally about to do some partitioning, so I can't set this up until after I do that, but if I could do it by LABEL or UUID, I could just set it up now and change the other partitions later – FreeSoftwareServers Feb 7 '18 at 6:49
  • The partition number will always be the same unless you repartition the block device. – Michael Hampton Feb 7 '18 at 6:50
  • Thats the plan, I'm about to delete part-3 and grow part-2, but I want to passthrough lets say "part-5", im worried if I do any changes in the future,"part-5" could become "part-4", but its UUID wouldn't change. – FreeSoftwareServers Feb 7 '18 at 6:51
  • 1
    turns out you can do by-uuid or by-label! @Michael Hampton, I was tab completing when I figured it out. – FreeSoftwareServers Feb 25 '18 at 2:05
0

Passing through disks doesn't support the LABEL/UUID format of FSTAB, but is possible. You can passthrough a disk via any of the following symlinks in /dev/disk/by-* eg:

cd /dev/disk/by-
by-id/        by-label/     by-partlabel/ by-partuuid/  by-path/      by-uuid/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.