Duplicate Initrd and Kernels Migrating to CachyOS from EOS

After more research and reading relevant threads, decided to continue the gradual migration from EOS. I apologize in advance for the long post.

Here’s are commands I ran today. First removing EOS dracut helper utilities and installing CachyOS versions:

$ yay -Rs kernel-install-for-dracut
$ yay dracut-cachyos

Once the package installed, the hooks automatically executed and initrds were regenerated.

Being unsure if there was anything else required, I ran an additional command provided by systemd package:

$ sudo kernel-install add-all

Then rebooted. I noticed the initrds and kernels installed to /boot, a directory which until now just contained intel-ucode.img for Intel processor. Although not the most intuitive name, the system’s ESP is mounted under /efi in accordance with systemd kernel-install documentation and the “Boot Loader Specification”. This system’s EOS installation is two years old now.

Here’s what my /boot and /efi. The /efi/{EFI,loader} directories are purposely omitted because it contains just the systemd-boot stub and configuration files that point kernel command-line options.

$ sudo ls -Rhl /boot/ /efi/4ba8052a8d764f7f8ab9d89a0199cadb
/boot/:
total 537M
-rw------- 1 root root 157M Jul 27 18:13 initramfs-linux-fallback.img
-rw------- 1 root root 107M Jul 27 18:13 initramfs-linux.img
-rw------- 1 root root 158M Jul 27 18:14 initramfs-linux-zen-fallback.img
-rw------- 1 root root 107M Jul 27 18:13 initramfs-linux-zen.img
-rw-r--r-- 1 root root 7.8M May 31 18:46 intel-ucode.img

/efi/4ba8052a8d764f7f8ab9d89a0199cadb:
total 8.0K
drwxr-x--- 2 root root 4.0K Jul 27 18:15 6.9.10-arch1-1
drwxr-x--- 2 root root 4.0K Jul 27 18:15 6.9.10-zen1-1-zen

/efi/4ba8052a8d764f7f8ab9d89a0199cadb/6.9.10-arch1-1:
total 170M
-rw-r----- 1 root root 157M Jul 27 18:15 initrd
-rw-r----- 1 root root  13M Jul 27 18:15 linux

/efi/4ba8052a8d764f7f8ab9d89a0199cadb/6.9.10-zen1-1-zen:
total 172M
-rw-r----- 1 root root 158M Jul 27 18:15 initrd
-rw-r----- 1 root root  14M Jul 27 18:15 linux

I’m concerned about the unnecessary copies of initrds and kernels causing confusion for me knowing which files are actually used.

Removing fallback is trivial, setting NO_DRACUT_FALLBACK=true. But what about the initrds and kernel files?

Based on research comparing with EOS:

CachyOS dracut-cachyos package, dracut-install

Compare with EOS’ kernel-install-for-dracut package, dracut-rebuild starting from line 19. Portions omitted keeping the relevant lines.

ESP=$(bootctl --print-esp-path)
TOKEN=$(find_token)
while read -r pkgbase; do
    kernelversion=$(basename "${pkgbase%/pkgbase}")
    kernelname=$(cat "${pkgbase}")
    INITRD_PATH="${ESP}/${TOKEN}/${kernelversion}"
...
    echo "Running dracut for ${kernelname}-${kernelversion}"
    [[ ${DRACUT_QUIET} == "true" ]] && DRACUT_EXTRA_PARAMS=" --quiet"
    dracut --force --hostonly --no-hostonly-cmdline${DRACUT_EXTRA_PARAMS} "${INITRD_PATH}/initrd" "${kernelversion}"
    [[ ${NO_DRACUT_FALLBACK} != "true" ]] && dracut --force --no-hostonly${DRACUT_EXTRA_PARAMS} "${INITRD_PATH}/initrd-fallback" "${kernelversion}"
done < <(find /usr/lib/modules -maxdepth 2 -type f -name pkgbase)

And with further investigation of all CachyOS-PKGBUILDS

$ grep -RE '/boot/' .
./cachyos-grub-theme/PKGBUILD:  mkdir -p "${pkgdir}/boot/grub/themes/${pkgname}"
./cachyos-grub-theme/PKGBUILD:  cp -TR "${srcdir}/${pkgname}/theme" "${pkgdir}/boot/grub/themes/${pkgname}"
./cachyos-grub-theme/cachyos-grub-theme.install:  echo '==>  1. Open the file "/etc/default/grub" and inside it update the variable GRUB_THEME="/boot/grub/themes/cachyos-grub-theme/theme.txt"'
./cachyos-grub-theme/cachyos-grub-theme.install:  echo '==>  2. Update the grub config by running "sudo grub-mkconfig -o /boot/grub/grub.cfg"'
./dracut-cachyos/dracut-cachyos.conf:# When BUILD_UKI is set to true, an UKI will be generated and placed in: /boot/EFI/Linux/
./dracut-cachyos/dracut-install:	install -Dm644 "/${line}" "/boot/vmlinuz-${pkgbase}"
./dracut-cachyos/dracut-install:	dracut --force --hostonly --no-hostonly-cmdline${DRACUT_EXTRA_PARAMS} /boot/initramfs-${pkgbase}.img "${kver}"
./dracut-cachyos/dracut-install:		dracut --force --no-hostonly${DRACUT_EXTRA_PARAMS} "/boot/initramfs-${pkgbase}-fallback.img" "${kver}"
./dracut-cachyos/dracut-install:		dracut --hostonly --uefi${DRACUT_EXTRA_PARAMS} "/boot/EFI/Linux/${pkgbase}.efi" --kver "$kver" --force
./dracut-cachyos/dracut-remove:	"/boot/vmlinuz-${pkgbase}"
./dracut-cachyos/dracut-remove:	"/boot/initramfs-${pkgbase}.img"
./dracut-cachyos/dracut-remove:	"/boot/initramfs-${pkgbase}-fallback.img"
./dracut-cachyos/dracut-remove:	"/boot/EFI/Linux/${pkgbase}.efi"
./grub-btrfs-support/grub-btrfs-snapper.service:# If we aren't booted off a snapshot, regenerate just '/boot/grub/grub-btrfs.cfg' if it exists and is not empty, else regenerate the whole grub menu
./grub-btrfs-support/grub-btrfs-snapper.service:ExecStart=bash -c 'if [[ -z $(/usr/bin/findmnt -n / | /usr/bin/grep "\.snapshots") ]]; then if [ -s "${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub-btrfs.cfg" ]; then /etc/grub.d/41_snapshots-btrfs; else ${GRUB_BTRFS_MKCONFIG:-grub-mkconfig} -o ${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub.cfg; fi; fi'

There’s an assumption that everything should be under /boot for CachyOS.

Is this for maintaining backwards compatibility with GRUB?

References:

We have extra moved the customized dracut to dracut-cachyos, so that the original EOS scripts can be still used.

EOS has a bunch of extra’s, to avoid the migration issues we have moved it. Just use the original dracut-eos-scripts.

We dont have explicit support or use of dracut. CachyOS itself uses mkinitcpio.

Did you mean to say the EOS package, “eos-dractut”?

I think they have somehwere own scripts, yes.