803fb7
From 1e61121501f79e654a36bf2efb6a987f6a11c262 Mon Sep 17 00:00:00 2001
803fb7
From: Michal Sekletar <msekletar@users.noreply.github.com>
803fb7
Date: Wed, 17 Aug 2016 14:10:28 +0200
803fb7
Subject: [PATCH] rules: introduce disk/by-id (model_serial) symlinks for NVMe
803fb7
 drives (#3974)
803fb7
803fb7
$ ls -l /dev/disk/by-id/nvme*
803fb7
lrwxrwxrwx. 1 root root 13 Aug 17 04:25 /dev/disk/by-id/nvme-HUSPR3216AHP301_STM0001B6780 -> ../../nvme0n1
803fb7
lrwxrwxrwx. 1 root root 15 Aug 17 04:25 /dev/disk/by-id/nvme-HUSPR3216AHP301_STM0001B6780-part1 -> ../../nvme0n1p1
803fb7
803fb7
https://github.com/systemd/systemd/issues/1453
803fb7
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=779ff75617099f4defe14e20443b95019a4c5ae8
803fb7
803fb7
Cherry-picked from: a5110c90303cf455db5062faef34d5724d12e2e9
803fb7
Related: #1274651
803fb7
---
803fb7
 rules/60-persistent-storage.rules | 6 ++++++
803fb7
 1 file changed, 6 insertions(+)
803fb7
803fb7
diff --git a/rules/60-persistent-storage.rules b/rules/60-persistent-storage.rules
803fb7
index cc01acb16..74f8f21f3 100644
803fb7
--- a/rules/60-persistent-storage.rules
803fb7
+++ b/rules/60-persistent-storage.rules
803fb7
@@ -26,6 +26,12 @@ ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*"
803fb7
 KERNEL=="nvme*[0-9]n*[0-9]", ATTR{wwid}=="?*", SYMLINK+="disk/by-id/nvme-$attr{wwid}"
803fb7
 KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{wwid}=="?*", SYMLINK+="disk/by-id/nvme-$attr{wwid}-part%n"
803fb7
 
803fb7
+KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{serial}=="?*", ENV{ID_SERIAL_SHORT}="$attr{serial}"
803fb7
+KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{model}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_SERIAL}="$attr{model}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}"
803fb7
+
803fb7
+KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{serial}=="?*", ENV{ID_SERIAL_SHORT}="$attr{serial}"
803fb7
+KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{model}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_SERIAL}="$attr{model}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}-part%n"
803fb7
+
803fb7
 # virtio-blk
803fb7
 KERNEL=="vd*[!0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}"
803fb7
 KERNEL=="vd*[0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}-part%n"