Linux Developers Discuss A Global Counter For Block/Disk Changes

Written by Michael Larabel in systemd on 27 June 2021 at 07:40 AM EDT. 24 Comments
Microsoft and systemd developers are proposing a global counter for block device changes for the Linux kernel to better track changes and having a unique system-wide number for disk and other block device changes rather than on a per-disk basis.

This monotonically increasing number is system-wide and would be used so systemd and other user-space software could better correlate events for devices that end up re-using the same device, such as /dev/sda and especially /dev/loop0 and other devices often end up getting re-used when one device is detached and another added. Particularly around loop devices isn't a better means of finding out if it's the same loop device as before since not having a serial number or other means of uniquely identifying it.

While user-space can use event listeners for add/remove events for trying to track disk changes, due to events possibly arriving late to user-space or out-of-order, among other concerns, this global counter for tracking is deemed one of the best approaches. Separately there is work ongoing around block namespaces and other improvements but at least the systemd folks feel that this method is immediately worthwhile and beneficial to have with the Linux kernel.

This global number is put in the uevent so user-space can use it for correlating when a driver re-uses a device, a new ioctl would also be added of BLKGETDISKSEQ to get the disk sequence number, and the sequence number would also be exposed via sysfs with diskseq. This sequence number would increment whenever the underlying media has changed or similarly for the loop device whenever setting or changing the backing file.

Those interested in the proposed patches sent out by Microsoft's Matteo Croce can see this patch series and the resulting discussion over the merits of this feature.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via

Popular News This Week