]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
feat: also restore the initramfs from /lib/modules
authorHarald Hoyer <harald@redhat.com>
Tue, 4 May 2021 08:36:44 +0000 (10:36 +0200)
committerHarald Hoyer <harald@hoyer.xyz>
Tue, 4 May 2021 09:25:32 +0000 (11:25 +0200)
Fallback to /lib/modules/$(uname -r)/initrd, if present and all other
files don't exist.

dracut-initramfs-restore.sh

index 8fe23df0d29171d8be3e63875b8491c8d77bae8b..abe6b1e206abe56c53e13680b94822af3e28120b 100644 (file)
@@ -24,14 +24,17 @@ elif [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \
     && [[ $MACHINE_ID ]] \
     && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]]; then
     IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
-else
+elif [[ -f /boot/initramfs-${KERNEL_VERSION}.img ]]; then
     IMG="/boot/initramfs-${KERNEL_VERSION}.img"
+elif [[ -f /lib/modules/${KERNEL_VERSION}/initrd ]]; then
+    IMG="/lib/modules/${KERNEL_VERSION}/initrd"
+else
+    echo "No initramfs image found to restore!"
+    exit 1
 fi
 
 cd /run/initramfs
 
-[ -f .need_shutdown -a -f "$IMG" ] || exit 1
-
 if $SKIP "$IMG" | zcat | cpio -id --no-absolute-filenames --quiet > /dev/null; then
     rm -f -- .need_shutdown
 elif $SKIP "$IMG" | xzcat | cpio -id --no-absolute-filenames --quiet > /dev/null; then