Unique device ID for virtual hard disks?

gurubert

Famous Member
Mar 12, 2015
806
151
113
Berlin, Germany
www.heinlein-consulting.de
Hi,
currently virtual hard disk show up like this under /dev/disk/by-id:

lrwxrwxrwx 1 root root 9 Sep 2 13:47 scsi-0QEMU_QEMU_HARDDISK_drive-scsi0 -> ../../sda
lrwxrwxrwx 1 root root 10 Sep 2 13:47 scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Sep 2 13:47 scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Sep 2 13:47 scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-part3 -> ../../sda3
lrwxrwxrwx 1 root root 10 Sep 2 13:47 scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-part4 -> ../../sda4
lrwxrwxrwx 1 root root 9 Sep 2 16:56 scsi-0QEMU_QEMU_HARDDISK_drive-scsi1 -> ../../sdb
lrwxrwxrwx 1 root root 9 Sep 2 16:56 scsi-0QEMU_QEMU_HARDDISK_drive-scsi2 -> ../../sdc
lrwxrwxrwx 1 root root 9 Sep 2 17:28 scsi-0QEMU_QEMU_HARDDISK_drive-scsi3 -> ../../sdd
lrwxrwxrwx 1 root root 9 Sep 2 17:28 scsi-0QEMU_QEMU_HARDDISK_drive-scsi4 -> ../../sde
lrwxrwxrwx 1 root root 9 Sep 2 17:28 scsi-0QEMU_QEMU_HARDDISK_drive-scsi5 -> ../../sdf

They have a unique ID inside the VM.

But when looking at multiple VMs the IDs are not unique any more. A management system that spans more than one VM gets confused with multiple HDDs having the same ID.

Is it possible to replace QEMU_HARDDISK with a unique id (possibly a UUID)? Is that even something Proxmox can do?

Physical disks in physical machines do not have this issue.
 
Is it possible to replace QEMU_HARDDISK with a unique id (possibly a UUID)? Is that even something Proxmox can do?
What you can do is add both a 'serial' and/or 'wwn' parmeter to the drive specification - e.g.:
Code:
scsi0: local:vm-100-disk-0,size=8G,serial=myserialnumber11444,wwn=0x5566777788888888

in a debian VM this results in a few links being created in /dev/disk/by-id:
Code:
/dev/disk/by-id/scsi-35566777788888888
/dev/disk/by-id/wwn-5566777788888888
out of the box - the links with the serial number don't get created - but this is something that possibly can be achieved by appropriate udev-rules inside the guest

I hope this helps!

Out of curiosity - why would you need unique identifiers for virtualized disks?
 
Would be nice if that parameter could be set via GUI and API.
The use-case is something that is requested rather seldomly (my guess about once per year) - and given that the Disk-Edit GUI window is already quite heavy in terms of possible configurable options we would rather leave the more specific use cases to command-line only instead of putting even more widgets on that window
 
GCP has this functionality. I found this thread trying to find a way to do the same thing in proxmox.
The use-case is something that is requested rather seldomly (my guess about once per year)
2022 is almost over, so here's the obligatory annual request for this feature...
Out of curiosity - why would you need unique identifiers for virtualized disks?
For example, if you want your VMs to automatically mount a disk in, say, /var/log and another in /var/lib/elasticsearch, you could set "serial=logs" and "serial=es" on those disk, and add /dev/disk/by-id/scsi-logs and /dev/disk/by-id/scsi-es to fstab. This is much better than the alternative of remembering the order of disks attached tot he VM, and referring to them as sda/b/c.
You could even have a startup script baked into VM templates to auto-format the disks on first boot.
Modifying the conf files works, but being able to do this from the UI or through the API would make more powerful templating possible.
 
  • Like
Reactions: gurubert

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!