Want to try and help test dracut? Now is the time!

You made me use my brain a bit here, man :slight_smile: , but it seems to run fine. The code, not my brain. I mean my brain runs fine too! I guess... lolll

Ok so I only tested the INSTALL so far, not the REMOVE yet.

Not sure I have the best practices here, see what I've done now:

Created folder /etc/garuda/dracut
Stored 2 executable files, install-no-fallback and remove-no-fallback

Contents of

install-no-fallback

#!/bin/bash -e

echo ":: ==> User has opt out of building a fallback initramfs for ${pkgbase} (${kver})"
if [ -f /boot/initramfs-${pkgbase}-fallback.img ]; then
rm -f "/boot/initramfs-${pkgbase}-fallback.img"
fi

remove-no-fallback

#!/bin/bash -e

rm -f "/boot/vmlinuz-${pkgbase}" "/boot/initramfs-${pkgbase}.img"

Modified the following in /usr/share/libalpm/scripts/dracut-install

*[NOT PASTING WHAT IS BEFORE THIS POINT]*
for line in "${lines[@]}"; do
	if ! pacman -Qqo "${line}/pkgbase" &> /dev/null; then
		# if pkgbase does not belong to any package then skip this kernel
		continue
	fi

	pkgbase="$(<"${line}/pkgbase")"
	kver="${line##*/}"

	echo ":: Building initramfs for ${pkgbase} (${kver})"
	dracut --force "/boot/initramfs-${pkgbase}.img" "${kver}"

# Start of insert by FGD
if [ -f /etc/garuda/dracut/install-no-fallback ]; then
    source /etc/garuda/dracut/install-no-fallback; else
	echo ":: Building fallback initramfs for ${pkgbase} (${kver})"
	dracut --force --no-hostonly -o "network" "/boot/initramfs-${pkgbase}-fallback.img" "${kver}"
fi
# End of insert by FGD

done

Modified the following in /usr/share/libalpm/scripts/dracut-remove (this is the whole file):

#!/bin/bash -e

while read -r line; do
	if [[ "${line}" == */pkgbase ]]; then
		read -r pkgbase < "/${line}"
# Start of insert by FGD
		if [ -f /etc/garuda/dracut/remove-no-fallback ]; then
    	source /etc/garuda/dracut/remove-no-fallback; else
    	rm -f "/boot/vmlinuz-${pkgbase}" "/boot/initramfs-${pkgbase}.img" "/boot/initramfs-${pkgbase}-fallback.img"
		fi
# End of insert by FGD
	fi
done

Looking at this I understand why you say it's safer and cleaner. I would add to that: less overall code and less files!

Is that the kind of stuff you guys were talking about?

EDIT: I have perfected the code by including the removal of the fallback image, if found, on every image generation. This ensures no fallback image remains on the system.

Tested with and without config files, generates the fallback when expected, does not generate it (and deletes it) when expected.