]> git.ipfire.org Git - thirdparty/systemd.git/commit
udev: generate system-unique storage symlinks using device path
authorRoland Hieber <rhi@pengutronix.de>
Mon, 18 Sep 2023 09:52:06 +0000 (11:52 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 6 Dec 2023 21:22:08 +0000 (22:22 +0100)
commit3af66c089b930b7191c1964f2ea30448fe9688de
tree8e739e3ccbbed59f41a2381e47900850f35a6264
parent27e6681f08753964760bff23339276d0afb825a5
udev: generate system-unique storage symlinks using device path

When the same disk image is written to multiple storage units, for
example an external SD card and an internal eMMC, the symlinks in
/dev/disk/by-{label,uuid,partlabel,partuuid}/ are no longer unique, and
will point to the device that is probed last.

Adressing partitions via labels and UUIDs is nice to work with, and
depending on the use case, it might also be more robust than using the
symlinks in /dev/disk/by-path/ containing the partition number. Combine
the two approaches to create unique symlinks containing both the device
path as well as the respective UUIDs or labels, and throw in a symlink
using the devpath and the partition number for the sake of completeness.

For an exemplary GPT-partitioned disk at "platform-2198000.mmc" with a
partition containing an ext4 file system, this might create symlinks of
the following form:

  /dev/disk/by-path/platform-2198000.mmc-part/by-partnum/1
  /dev/disk/by-path/platform-2198000.mmc-part/by-partuuid/e5a75233-3b90-4aec-8075-b4dd7132b48d
  /dev/disk/by-path/platform-2198000.mmc-part/by-partlabel/rootfs
  /dev/disk/by-path/platform-2198000.mmc-part/by-uuid/b2c92f24-8215-4680-b931-f423aae5f1c9
  /dev/disk/by-path/platform-2198000.mmc-part/by-label/rootfs

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
rules.d/60-persistent-storage.rules.in