On systems with multiple 2.5-inch form factor PCIe SSD devices, locating the physical drive can be made easier with symlinks in /dev/disk/by-location.
This rule reads the bay and slot information for each nvme device and creates symlinks like this: /dev/disk/by-location/pcie-ssd-in-slot-9-bay-1-nvme0n1 -> ../../nvme0n1 /dev/disk/by-location/pcie-ssd-in-slot-9-bay-1-nvme1n1 -> ../../nvme1n1 /dev/disk/by-location/pcie-ssd-in-slot-9-bay-1-nvme1n2 -> ../../nvme1n2 /dev/disk/by-location/pcie-ssd-in-slot-5-bay-1-nvme2n1 -> ../../nvme2n1 The bay/slot information is read from the sysfs label attribute available for each pci device. The label attribute is a OEM populated string. Systems from Dell contain Slot and Bay information for NVMe devices. Other OEMs might do something similar, there is no convention for the format at this time - hence the dmi check. Signed-off-by: Charles Rose <charles.r...@dell.com> --- rules/61-nvme-location.rules | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 rules/61-nvme-location.rules diff --git a/rules/61-nvme-location.rules b/rules/61-nvme-location.rules new file mode 100644 index 000000000..296bad2e4 --- /dev/null +++ b/rules/61-nvme-location.rules @@ -0,0 +1,8 @@ +# Symlink NVMe Bay and Slot + +# Tested on Dell PowerEdge Servers. +ATTR{[dmi/id]sys_vendor}!="Dell*", GOTO="nvme_location_end" + +KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", DRIVERS=="nvme", ATTRS{label}=="?*", PROGRAM="/bin/sh -c 'echo $attr{label} | tr [:blank:] - | tr [:upper:] [:lower:]'", SYMLINK+="disk/by-location/%c-%k" + +LABEL="nvme_location_end" -- 2.13.6 _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel