* [gentoo-commits] proj/genkernel:master commit in: mdev/, mdev/helpers/, /
@ 2018-06-05 18:02 Robin H. Johnson
0 siblings, 0 replies; only message in thread
From: Robin H. Johnson @ 2018-06-05 18:02 UTC (permalink / raw
To: gentoo-commits
commit: 84b25046315593897e9a57b73b2e80410b5be35a
Author: Georgy Yakovlev <ya <AT> sysdump <DOT> net>
AuthorDate: Tue Jun 5 01:00:32 2018 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Jun 5 18:01:24 2018 +0000
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=84b25046
Add mdev nvme handler for by-id synlinks
Creates required entries in /dev/disk/by-id
for nvme drives and partitions.
This is mainly needed by zfs nvme rootfs, because
upstream recommends using by-id to import pools.
System fails to boot If genkernel uses zpool cache which
has by-id entries and there are no symlinks in /dev/disk/by-id
Here is an example how it looks with 2 nvme drives
nvme-eui.0123456789876543 -> ../../nvme0n1
nvme-eui.0123456789876543-part1 -> ../../nvme0n1p1
nvme-eui.0123456789876543-part2 -> ../../nvme0n1p2
nvme-eui.0123456789876543 -> ../../nvme1n1
nvme-eui.0123456789876543-part1 -> ../../nvme1n1p1
nvme-eui.0123456789876543-part2 -> ../../nvme1n1p2
nvme-Samsung_SSD_960_PRO_512GB_SN0123456789876 -> ../../nvme0n1
nvme-Samsung_SSD_960_PRO_512GB_SN0123456789876-part1 -> ../../nvme0n1p1
nvme-Samsung_SSD_960_PRO_512GB_SN0123456789876-part2 -> ../../nvme0n1p2
nvme-Samsung_SSD_960_PRO_512GB_SB9876543210123 -> ../../nvme1n1
nvme-Samsung_SSD_960_PRO_512GB_SB9876543210123-part1 -> ../../nvme1n1p1
nvme-Samsung_SSD_960_PRO_512GB_SB9876543210123-part2 -> ../../nvme1n1p2
Closes: https://bugs.gentoo.org/654680
Signed-off-by: Georgy Yakovlev <ya <AT> sysdump.net>
(cherry picked from commit e21fec6b87ca2ada59728f7db6961bf97ee22fff)
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
gen_initramfs.sh | 1 +
mdev/helpers/nvme | 21 +++++++++++++++++++++
mdev/mdev.conf | 7 ++++---
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index d4f56db..768f291 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -128,6 +128,7 @@ append_base_layout() {
mkdir -p "${TEMP}/initramfs-base-temp/etc/mdev/helpers"
install -m 644 -t "${TEMP}/initramfs-base-temp/etc" /usr/share/genkernel/mdev/mdev.conf
+ install -m 755 -t "${TEMP}/initramfs-base-temp/etc/mdev/helpers" /usr/share/genkernel/mdev/helpers/nvme
install -m 755 -t "${TEMP}/initramfs-base-temp/etc/mdev/helpers" /usr/share/genkernel/mdev/helpers/storage-device
cd "${TEMP}/initramfs-base-temp/"
diff --git a/mdev/helpers/nvme b/mdev/helpers/nvme
new file mode 100644
index 0000000..7df96a3
--- /dev/null
+++ b/mdev/helpers/nvme
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+[ -z "${MDEV}" ] && exit 22
+
+DEV="${MDEV%p*}"
+PART="${MDEV#nvme?n?p}"
+PART="${PART#nvme?n?}"
+
+[ -f "/sys/class/block/${DEV}/device/model" ] || exit 6
+cat "/sys/class/block/${DEV}/device/model" >/dev/null 2>&1 || exit 15
+
+MODEL=$(cat /sys/class/block/"${DEV}"/device/model)
+MODEL=$(echo $MODEL) # leave unquoted, it removes spaces
+MODEL="${MODEL// /_}"
+SERIAL=$(cat /sys/class/block/"${DEV}"/device/serial)
+SERIAL="${SERIAL// /}"
+WWID=$(cat /sys/class/block/"${DEV}"/wwid)
+
+mkdir -p /dev/disk/by-id
+ln -sf "../../${MDEV}" "/dev/disk/by-id/nvme-${MODEL}_${SERIAL}${PART:+-part$PART}"
+ln -sf "../../${MDEV}" "/dev/disk/by-id/nvme-${WWID}${PART:+-part$PART}"
diff --git a/mdev/mdev.conf b/mdev/mdev.conf
index 9e8efd0..db18123 100644
--- a/mdev/mdev.conf
+++ b/mdev/mdev.conf
@@ -1,3 +1,4 @@
-sd[a-z].* 0:0 660 @/etc/mdev/helpers/storage-device
-vd[a-z].* 0:0 660 @/etc/mdev/helpers/storage-device
-hw_random 0:0 600 =hwrng
+nvme[0-9]n[0-9].* 0:0 660 @/etc/mdev/helpers/nvme
+sd[a-z].* 0:0 660 @/etc/mdev/helpers/storage-device
+vd[a-z].* 0:0 660 @/etc/mdev/helpers/storage-device
+hw_random 0:0 600 =hwrng
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-06-05 18:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-05 18:02 [gentoo-commits] proj/genkernel:master commit in: mdev/, mdev/helpers/, / Robin H. Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox