Skip to content

Commit

Permalink
feat: also restore the initramfs from /lib/modules
Browse files Browse the repository at this point in the history
Fallback to /lib/modules/$(uname -r)/initrd, if present and all other
files don't exist.
  • Loading branch information
haraldh committed May 4, 2021
1 parent 625f11d commit 33e27fa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions dracut-initramfs-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 33e27fa

Please sign in to comment.