Make mkinitcpio allways create UKI

Hi there,
I’m booting to Manjaro 23.1.3 by this configuration:

  • boot loader: systemd-boot installed at /boot
  • ramdisk creator: mkinitcpio
  • Secure boot: enabled, via sbctl
  • Kernel: unified kernel (UKI): 6.6.16-2-MANJARO

I have changed linux66.preset to create the UKI kernel image.
And also changed /usr/share/mkinitcpio/hook.preset so as to keep the uki settings in linux*.preset files untouched after each kernel update.

Today I had a system update, and the mkinitcpio package also got an update. The problem is, the file hook.preset changes back to the original version in the mkinitcpio package. The result is changing in linux66.preset and so no UKI image.
How can I prevent this? Is there a way to make mkinitcpio always create preset files with our customization?

As has been said many times again and again; DON’T edit stuff in /usr. Now you found out why.

Have you checked mkinitcpio manpages and wiki?

2 Likes

You should read the man page:

-c, --config config
Use config file to generate the ramdisk. Default: /etc/mkinitcpio.conf. If specified, drop-in files in /etc/mkinitcpio.conf.d/ will be ignored.
1 Like

Sorry, I didn’t know that.

Indeed. I did all above stuff according to wiki and man pages.

This is the config file which is responsible for hooks (systemd modconf filesystems fsck) and etc. This file does not decide whether creating UKI or not.

Well… after some investigation, apparently it’s hardcoded.

You can use NoExtract in /etc/pacman.conf for such cases:
https://wiki.archlinux.org/title/pacman#Skip_file_from_being_upgraded

But if you plan to stay on linux66 you might only want to change /etc/mkinitcpio.d/linux66.preset.
When switching kernels in the future you need to adjust the corresponding preset file once, that might be acceptable to avoid NoExtract alltogether.

1 Like

True. But you have to be wary of any future major changes to mkinitcpio.

I tried this before. By this way, the current hook.preset file removed after re-installing/updating mkinitcpio. It causes future kernel installs not having a linux**.preset file.
This could make an unbootable system If I forgot to create the images manually after a major update. I’m looking for a permanent solution.

Maybe I should give kernel-install (by systemd-ukify) creating uki image instead of mkinitcpio due to this part of arch wiki.

I highly doubt this. It would only happen if you actually removed mkinitcpio first.

I took a slightly different approach - also using sbctl and verified boot - instead of using systemd-boot efistub I am using the unified kernel instead.

 $ efibootmgr
BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0001
Boot0001* Manjaro Verified Boot	HD(1,GPT,f023aaab-4fbb-4b12-be84-ac16e2444e3e,0x800,0x100000)/main.efi

Edited the preset in /etc/mkinitcpio.d - I only need one image …

 $ cat /etc/mkinitcpio.d/linux66.preset
# mkinitcpio preset file for the '6.6-x86_64' package

#ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-6.6-x86_64"
ALL_microcode=(/boot/*-ucode.img)

PRESETS=('default')

#default_config="/etc/mkinitcpio.conf"
default_image="/boot/initramfs-6.6-x86_64.img"
#default_uki="/efi/EFI/Linux/manjaro-6.6-x86_64.efi"
#default_options="--splash /usr/share/systemd/bootctl/splash-manjaro.bmp"

#fallback_config="/etc/mkinitcpio.conf"
fallback_image="/boot/initramfs-6.6-x86_64-fallback.img"
#fallback_uki="/efi/EFI/Linux/manjaro-6.6-x86_64-fallback.efi"
fallback_options="-S autodetect"

I am using the linux66 and have symlinked manjaro kernel to a generic name

 $ ls -l /boot
-rw------- 1 root root 51747921 Feb 26 05:51 initramfs-6.6-x86_64.img
lrwxrwxrwx 1 root root       24 Feb 25 17:44 initramfs-linux.img -> initramfs-6.6-x86_64.img
-rw-r--r-- 1 root root  7368704 Feb  1 17:16 intel-ucode.img
-rw-r--r-- 1 root root       21 Feb 23 16:37 linux66-x86_64.kver
drwxr-xr-x 1 root root       44 Feb 26 05:51 memtest86+
-rw-r--r-- 1 root root 12960256 Feb 25 17:56 vmlinuz-6.6-x86_64
lrwxrwxrwx 1 root root       18 Feb 25 17:44 vmlinuz-linux -> vmlinuz-6.6-x86_64