Skip to content

Instantly share code, notes, and snippets.

@Ghosthree3
Created February 18, 2022 04:35
Show Gist options
  • Save Ghosthree3/5dc926e7f064c8932c5e91563fc886cf to your computer and use it in GitHub Desktop.
Save Ghosthree3/5dc926e7f064c8932c5e91563fc886cf to your computer and use it in GitHub Desktop.
Modified dracut-hook files
[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = usr/lib/modules/*/vmlinuz
Target = usr/lib/dracut/*
[Action]
Description = Updating initramfs...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/dracut-install
NeedsTargets
#!/bin/bash -e
kernels=()
all=0
while read -r line; do
if [[ "${line}" != usr/lib/modules/* ]]; then
all=1 # Dracut files have been updated
continue
fi
kernels+=("/${line%/vmlinuz}")
done
if (( all )); then
# add every kernel present in /usr/lib/modules/
kernels=($(ls -d /usr/lib/modules/*))
fi
for kernel in "${kernels[@]}"; do
if ! pacman -Qqo "${kernel}/pkgbase" > /dev/null 2>&1; then
# if pkgbase does not exist or does not belong to any package then skip this kernel
continue
fi
read -r pkgbase < "${kernel}/pkgbase"
version="${kernel##*/}"
install -Dm0644 "${kernel}/vmlinuz" "/boot/vmlinuz-${pkgbase}"
echo ":: Building initramfs for ${pkgbase}-${version}"
dracut --force --hostonly --no-hostonly-cmdline "/boot/initramfs-${pkgbase}.img" --kver "${version}"
echo ":: Building fallback initramfs for ${pkgbase}-${version}"
dracut --force --no-hostonly --no-hostonly-cmdline "/boot/initramfs-${pkgbase}-fallback.img" --kver "${version}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment