On systems with multiple 2.5-inch form factor PCIe SSD devices, locating the
physical drive can be made easier with symlinks that contain the drive bay
and slot information like this:

   /dev/disk/by-path/PCIe_SSD_in_Slot_9_Bay_1-nvme0n1 -> ../../nvme0n1
   /dev/disk/by-path/PCIe_SSD_in_Slot_9_Bay_1-nvme0n2 -> ../../nvme0n2
   /dev/disk/by-path/PCIe_SSD_in_Slot_9_Bay_1-nvme1n1 -> ../../nvme1n1

The bay/slot information is read from the sysfs label attribute available for
each NVMe device.

v2: Incorporate Lennart's feedback
   Do not shell out to "tr".
   Create link in "by-path", not "by-location".
   Remove "DRIVERS==nvme" check.
   Do not make the rule vendor specific.

Signed-off-by: Charles Rose <charles_r...@dell.com>
---
 rules/60-persistent-storage.rules | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/rules/60-persistent-storage.rules 
b/rules/60-persistent-storage.rules
index 0de8cf3a1..2d3f7dc72 100644
--- a/rules/60-persistent-storage.rules
+++ b/rules/60-persistent-storage.rules
@@ -19,6 +19,8 @@ ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*"
 KERNEL=="nvme*[0-9]n*[0-9]", ATTR{wwid}=="?*", 
SYMLINK+="disk/by-id/nvme-$attr{wwid}"
 KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", 
ATTRS{wwid}=="?*", SYMLINK+="disk/by-id/nvme-$attr{wwid}-part%n"
 
+KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{label}=="?*", 
SYMLINK+="disk/by-path/$attr{label}-%k", OPTIONS="string_escape=replace"
+
 KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{serial}=="?*", 
ENV{ID_SERIAL_SHORT}="$attr{serial}"
 KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{wwid}=="?*", 
ENV{ID_WWN}="$attr{wwid}"
 KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{model}=="?*", 
ENV{ID_MODEL}="$attr{model}"
-- 
2.14.3
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to