logo

make-initrd

Unnamed repository; edit this file 'description' to name the repository. git clone https://anongit.hacktivis.me/git/make-initrd.git/
commit: fe28b74570b270a916155de57e1c38a0f6cf93b5
parent 86bdb8f468111f486ff585a69c1d1bfd424c19de
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 13 May 2025 14:47:00 +0200

use findfs instead of blkid+grep

Diffstat:

Minit34++++++++++++++++++++++++----------
Mmake-initrd.sh2+-
2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/init b/init @@ -3,8 +3,7 @@ # SPDX-License-Identifier: ISC export PATH=/bin:/sbin:/usr/bin:/usr/sbin -export init=/sbin/init newroot=/newroot root=zroot/ROOT/gentoo sh=/bin/sh level=3\ -a dev_hotplug=mdev - +export init=/sbin/init newroot=/newroot root=ZFS=zroot/ROOT/gentoo sh=/bin/sh level=3\ -a dev_hotplug=mdev rescueshell() { export PS1='rsh:$(tty | cut -c6-):$PWD # ' @@ -23,7 +22,17 @@ die() { } getdev() { - blkid | grep "$1" | cut -d: -f1 + case "$1" in + UUID=*|LABEL=*) + findfs "$1" + ;; + *-*-*-*) + findfs "UUID=$1" + ;; + *) + echo "$1" + ;; + esac } set -v @@ -69,17 +78,22 @@ command -v "$dev_hotplug" > /proc/sys/kernel/hotplug # shellcheck disable=SC2094 exec 0<"$console" 1>"$console" 2>&1 -#root=$(getdev $crypt_root) -#[ $root ] || root=/dev/sda2 -#cryptsetup open $root root || die -# -#mount /dev/mapper/root $newroot || die +test -n "$crypt_root" && { + rootdev=$(getdev "$crypt_root") + + if test -f /keyfile; then + cryptsetup --key-file /keyfile open "$rootdev" luks-"${rootdev##*/}" || \ + cryptsetup open "$rootdev" luks-"${rootdev##*/}" || die + else + cryptsetup open "$rootdev" luks-"${rootdev##*/}" || die + fi +} /load_modules.sh || die -cryptsetup open /dev/sda2 cryptrpool || die +pool="${root%%/*}" -zpool import -d /dev/mapper -d /dev -N rpool || die +zpool import -d /dev/mapper -d /dev -N "$pool" || die mount -t zfs -o rw,zfsutil "$root" "$newroot" || die diff --git a/make-initrd.sh b/make-initrd.sh @@ -2,7 +2,7 @@ # Copyright 2017 Haelwenn (lanodan) Monnier <contact+make-initrd@hacktivis.me> # SPDX-License-Identifier: ISC -elves="busybox blkid lsblk cryptsetup mksh zfs zpool" +elves="busybox cryptsetup mksh zfs zpool" modules="zfs" WORKDIR="$(pwd)"