Skip to content

feature: VirtIO block devices to provide a serial number #7332

@g-a-c

Description

@g-a-c

When using most Linux distributions, the default udev rules create aliases in /dev/disk/by-id containing information about a block device such as

  • the connection type
  • the serial number

This helps avoid scenarios where a device that is /dev/sda/ on one boot could become /dev/sdb on another, and is the recommended way to assemble things like ZFS pools.

UTM 4.6.5 on macOS 15.6 does not seem to provide serial numbers for the block devices, so they cannot replicate this common behaviour when emulating a Linux machine for testing. This is true of both Apple and QEMU backends

Debian 13, Virtualize (Apple)

root@debian:~# ls -l /dev/disk/by-id
total 0
lrwxrwxrwx 1 root root  9 Aug  6 08:36 usb-Apple_Virtual_Disk-0:0 -> ../../sda
lrwxrwxrwx 1 root root 10 Aug  6 08:36 usb-Apple_Virtual_Disk-0:0-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Aug  6 08:36 usb-Apple_Virtual_Disk-0:0-part2 -> ../../sda2
root@debian:~# lshw -class disk
  *-virtio1
       description: Virtual I/O device
       physical id: 0
       bus info: virtio@1
       logical name: /dev/vda
       size: 32GiB (34GB)
       capabilities: gpt-1.00 partitioned partitioned:gpt
       configuration: driver=virtio_blk guid=4ca559a0-4488-42d0-8cd0-37b15694c86b logicalsectorsize=512 sectorsize=512
  *-disk
       description: SCSI Disk
       product: Virtual Disk
       vendor: Apple
       physical id: 0.0.0
       bus info: scsi@0:0.0.0
       logical name: /dev/sda
       version: 1
       size: 703MiB (737MB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=6 logicalsectorsize=512 sectorsize=512
root@debian:~# lshw -class disk | grep serial
root@debian:~#

Debian 13, Emulate (QEMU)

root@debian2:~# ls -l /dev/disk/by-id
total 0
lrwxrwxrwx 1 root root 9 Aug  6 08:45 usb-QEMU_QEMU_CD-ROM_1-0000:00:04.0-4.1-0:0 -> ../../sr0
root@debian2:~# lshw -class disk
  *-cdrom
       description: DVD reader
       product: QEMU CD-ROM
       vendor: QEMU
       physical id: 0.0.0
       bus info: scsi@0:0.0.0
       logical name: /dev/cdrom
       logical name: /dev/sr0
       version: 2.5+
       capabilities: removable audio dvd
       configuration: ansiversion=5 status=ready
     *-medium
          physical id: 0
          logical name: /dev/cdrom
          capabilities: partitioned partitioned:dos
  *-virtio2
       description: Virtual I/O device
       physical id: 0
       bus info: virtio@2
       logical name: /dev/vda
       size: 32GiB (34GB)
       capabilities: gpt-1.00 partitioned partitioned:gpt
       configuration: driver=virtio_blk guid=2a21b215-4d7b-4f61-932c-658c04111f20 logicalsectorsize=512 sectorsize=512
root@debian2:~# lshw -class disk | grep serial
root@debian2:~#

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions