commit: 194371d8b1c87baf8b520dee82c9e20a19d156c0
parent e4ea48246c6fcb7d12a8bbc1b7db50e3b99d55ac
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 23 Apr 2024 07:47:07 +0200
make-initrd.sh: Require an argument to get the kernel version, no more initramfs-all
Diffstat:
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/make-initrd.sh b/make-initrd.sh
@@ -1,8 +1,7 @@
#!/bin/sh
-# Copyright 2017-2022 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
+# Copyright 2017 Haelwenn (lanodan) Monnier <contact+make-initrd@hacktivis.me>
# SPDX-License-Identifier: ISC
-out_base=initramfs-all
elves="busybox blkid lsblk cryptsetup mksh zfs zpool"
WORKDIR="$(pwd)"
@@ -11,23 +10,25 @@ die() {
exit 1
}
+[ -n "$1" ] || die "make-initrd takes kernel version as argument"
+kver="$1"
+modulesdir="/lib/modules/${kver}"
+[ -d "$modulesdir" ] || die "${modulesdir}: Directory not found"
+
+out_base="initramfs-${kver}"
+
if test -e "$out_base"; then
rm -fr "$out_base" || die "Failed: rm -fr $out_base"
fi
mkdir -p "$out_base" || die "Failed: mkdir $out_base"
cd "$out_base" || die "Failed: cd $out_base"
-mkdir -p bin lib dev proc sys newroot etc || die "Failed creating base directories"
+mkdir -p bin lib/modules dev proc sys newroot etc || die "Failed creating base directories"
ln -s /proc/mounts etc/mtab || die "Failed symlink for /etc/mtab"
ln -s . usr
ln -s lib lib64
ln -s lib lib32
-if test -d "/lib/modules"
-then
- cp -pr "/lib/modules" lib || die "Failed copying kernel modules"
-else
- echo "[Warning] '/lib/modules' doesn’t exist"
-fi
+cp -pr "${modulesdir}" lib/modules/ || die "Failed copying kernel modules"
mknod -m 660 dev/console c 5 1
mknod -m 666 dev/urandom c 1 9
@@ -43,8 +44,13 @@ for elf in $elves; do
cp "$origin" bin/ || die
done
+if [ -f /root/initrd-keyfile ]; then
+ cp /root/initrd-keyfile ./keyfile || die "copying keyfile"
+fi
+
cp "${WORKDIR}/init" . || die "copying init"
chmod 755 init || die "init chmod"
+
ln bin/mksh bin/sh || die "default shell link"
for lib in $(find bin -type f -exec lddtree -l {} + | grep -v bin/ | sort | uniq); do