Identify disks

Ulrar

Active Member
Feb 4, 2016
37
1
28
34
Hi,

Is there anyway to figure out the correspondence between the disk inside the VM (/dev/sda, /dev/sdb ..) and the disks attached to the virtual machine in the proxmox web ui ?
Seems like they don't have a serial number and clearly sometimes they get switched (scsi0 becomes sdc and scsi1 becomes sdb, for some reason), so I can't think of anything besides having them all have a slightly different size to tell them apart.

I ask that because we'll want to be deleting disks every once in a while, it's critical not to mistake them.
 
Hi Ulrar,

you can do so by editing the config file of the VM, for example: /etc/pve/nodes/<server name>/qemu-server/<uid>.conf, simply add a serial:

scsi0: data_VM:vm-100-disk-2,size=30G,serial=<your serial>
 
  • Like
Reactions: Ulrar
@Alwin @oguz

I've had the same problem multiple times. And I just found this thread. This should really be a feature when you add a disk to a VM. Given how easy it is to actually get this functionality with a little conf file "hack", a simple checkbox to generate a "unique disk serial number" could/would be immensely helpful. That checkbox could be checked by default. If a user doesn't want a "fake" serial of your disks, the user can always uncheck it.
 
Thanks for the suggestion @Alwin. However, that's not exactly what I meant. That command does indeed get me the serial number of a disk, if set. My issue is more about not having a serial number for VM disks to begin with.

In my specific use case, I have several VMs with many disks attached. Snippet from the VMID.conf file:

scsi0: ceph_vm:vm-63061-disk-1,discard=on,size=32G scsi1: ceph_vm:vm-63061-disk-3,backup=0,discard=on,size=2G,ssd=1 scsi2: ceph_vm:vm-63061-disk-8,backup=0,discard=on,size=2G,ssd=1 scsi4: ceph_vm:vm-63061-disk-0,backup=0,discard=on,size=5G scsi5: ceph_vm:vm-63061-disk-5,backup=0,discard=on,size=5G scsi6: ceph_vm:vm-63061-disk-6,backup=0,discard=on,size=5G scsihw: virtio-scsi-pci virtio4: ceph_vm:vm-63061-disk-7,backup=0,size=4G,serial=virtio4-disk7

If I need to modify or delete these disks, there's no way to correlate these disks (that I've found) inside of the VM. Hence the need for a serial number to be injected through QEMU, like so:

scsi1: ceph_vm:vm-63061-disk-3,backup=0,discard=on,size=2G,ssd=1,serial=vm-scsi1-d3-47579b10

I wrote a simple bash script to generate a unique-ish serial number for a drive, which I'm now using when I need to make sure I can identify disks. However, it would be nice if the "add disk wizard" in PVE would do this for me automatically.

Hopefully my explanation helps better illuminiate what I meant.
 
Code:
lsblk -o +SERIAL
I meant, run this inside the VM.

As an example, this produces the following output on my VM.
Code:
# lsblk --nodeps -o NAME,SERIAL
NAME SERIAL
sda  drive-scsi0
sdb  drive-scsi6
sdc  drive-scsi5
sdd  drive-scsi3
sde  drive-scsi1
sr0  QM00003
The SCSI numbering corresponds to the VM config. But OFC, you can also use a separate serial.
 
Thanks @Alwin ! That is useful, indeed, but it seems to work only for scsi devices. Disks attached as `virtio` do not receive a serial by default in the VM
Code:
# lsblk --nodeps -o NAME,SERIAL

sda  drive-scsi0
sr0  QM00003
vda
vdb
vdc


image showing 4 drives, of which 1 SCSI and 3 VirtIO, which corresponds to the above output from lsblk
 
  • Like
Reactions: mikeinnyc