Mkinitcpio-install hook fail

Hello,
I don’t know if it’s just me but when I update the linux kernel the mkinitcpio-install hook fail to create the mkinitcpio preset and as a consequence, mkinitcpio can’t create the initramfs image and the system can’t be booted.

It does not matter which kernel do you try to update, the same problem shows up with linux, linux-cachyos, linux-cachyos-lto and so on.

The error that appears in the pacman log is the following:

Updating linux initcpios...
call to execv failed (No such file or directory)
error: command failed to execute correctly

My current versions are
mkinitcpio 39.2-2
linux-cachyos-lto 6.9.3-4

I have never saw this actually.

Are you inside a chroot? Does another kernel work?

No i am not inside chroot. I was able to recover the system through btrfs snapshots but I am not able to update any kernel.

The ones that are already installed work well.

I have also tried on a different cachyos installation and I have the same problem

Does reinstalling the kernel does fix the issue?

This seems really weird, since youre saying you have this on another installation. In no other support channel we did see such a message so far.

No, reinstalling the kernel break the system because it triggers the mkinitcpio-install hooks that fails, so no initram image is generated.

Could you please provide the complete log?

Checking others, it seems like there is something wrong with the locales. Did you maybe install the package “glibc-locales” ?

Does sudo locale-gen fix the issue?

No, it doesn’t solve the issue.

This is the link to the output of the cachyos-bugreport script: b0b5ce6

The following is /var/log/pacman.log

Running pacman with --verbose I also obtain the following errors but I don’t think they are related to the mkinitcpio problem:

debug: "/var/lib/pacman/sync/core.db.sig" is not readable: No such file or directory
debug: sig path /var/lib/pacman/sync/core.db.sig could not be opened
debug: got error 43 at _alpm_gpgme_checksig (../lib/libalpm/signing.c: 599) : missing PGP signature
debug: missing optional signature
debug: "/var/lib/pacman/sync/extra.db.sig" is not readable: No such file or directory
debug: sig path /var/lib/pacman/sync/extra.db.sig could not be opened
debug: got error 43 at _alpm_gpgme_checksig (../lib/libalpm/signing.c: 599) : missing PGP signature
debug: missing optional signature
debug: "/var/lib/pacman/sync/multilib.db.sig" is not readable: No such file or directory
debug: sig path /var/lib/pacman/sync/multilib.db.sig could not be opened
debug: got error 43 at _alpm_gpgme_checksig (../lib/libalpm/signing.c: 599) : missing PGP signature
debug: missing optional signature
 

/var/log/pacman.log

4364   │ [2024-06-23T13:53:32+0200] [PACMAN] Running 'pacman --sync -y --verbose --debug -- linux-zen'
4365   │ [2024-06-23T13:53:32+0200] [PACMAN] synchronizing package lists
4366   │ [2024-06-23T13:54:08+0200] [ALPM] transaction started
4367   │ [2024-06-23T13:54:08+0200] [ALPM] installed linux-zen (6.9.6.zen1-1)
4368   │ [2024-06-23T13:54:08+0200] [ALPM-SCRIPTLET] debug: unregistering database 'local'
4369   │ [2024-06-23T13:54:08+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'local'
4370   │ [2024-06-23T13:54:08+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-v3'
4371   │ [2024-06-23T13:54:08+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-v3'
4372   │ [2024-06-23T13:54:08+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-core-v3'
4373   │ [2024-06-23T13:54:08+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-core-v3'
4374   │ [2024-06-23T13:54:08+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-extra-v3'
4375   │ [2024-06-23T13:54:08+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-extra-v3'
4376   │ [2024-06-23T13:54:08+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos'
4377   │ [2024-06-23T13:54:08+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos'
4378   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'core'
4379   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'core'
4380   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'extra'
4381   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'extra'
4382   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'multilib'
4383   │ [2024-06-23T13:54:09+0200] [ALPM] transaction completed
4384   │ [2024-06-23T13:54:09+0200] [ALPM] running '30-systemd-update.hook'...
4385   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'local'
4386   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'local'
4387   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-v3'
4388   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-v3'
4389   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-core-v3'
4390   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-core-v3'
4391   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-extra-v3'
4392   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-extra-v3'
4393   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos'
4394   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos'
4395   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'core'
4396   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'core'
4397   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'extra'
4398   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'extra'
4399   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'multilib'
4400   │ [2024-06-23T13:54:09+0200] [ALPM] running '60-depmod.hook'...
4401   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'local'
4402   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'local'
4403   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-v3'
4404   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-v3'
4405   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-core-v3'
4406   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-core-v3'
4407   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-extra-v3'
4408   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-extra-v3'
4409   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos'
4410   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos'
4411   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'core'
4412   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'core'
4413   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'extra'
4414   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'extra'
4415   │ [2024-06-23T13:54:09+0200] [ALPM-SCRIPTLET] debug: unregistering database 'multilib'
4416   │ [2024-06-23T13:54:11+0200] [ALPM] running '90-mkinitcpio-install.hook'...
4417   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: unregistering database 'local'
4418   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'local'
4419   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-v3'
4420   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-v3'
4421   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-core-v3'
4422   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-core-v3'
4423   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-extra-v3'
4424   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-extra-v3'
4425   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos'
4426   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos'
4427   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: unregistering database 'core'
4428   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'core'
4429   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: unregistering database 'extra'
4430   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'extra'
4431   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: unregistering database 'multilib'
4432   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] call to execv failed (No such file or directory)
4433   │ [2024-06-23T13:54:11+0200] [ALPM] running '90-packagekit-refresh.hook'...
4434   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: unregistering database 'local'
4435   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'local'
4436   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-v3'
4437   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-v3'
4438   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-core-v3'
4439   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-core-v3'
4440   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-extra-v3'
4441   │ [2024-06-23T13:54:11+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-extra-v3'
4442   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos'
4443   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos'
4444   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: unregistering database 'core'
4445   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'core'
4446   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: unregistering database 'extra'
4447   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'extra'
4448   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: unregistering database 'multilib'
4449   │ [2024-06-23T13:54:12+0200] [ALPM] running 'grub.hook'...
4450   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: unregistering database 'local'
4451   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'local'
4452   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-v3'
4453   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-v3'
4454   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-core-v3'
4455   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-core-v3'
4456   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos-extra-v3'
4457   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos-extra-v3'
4458   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: unregistering database 'cachyos'
4459   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'cachyos'
4460   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: unregistering database 'core'
4461   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'core'
4462   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: unregistering database 'extra'
4463   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: freeing package cache for repository 'extra'
4464   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] debug: unregistering database 'multilib'
4465   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] Generating grub configuration file ...
4466   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] Found theme: /boot/grub/themes/fallout-grub-theme/theme.txt
4467   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] Found linux image: /boot/vmlinuz-linux-cachyos-lto
4468   │ [2024-06-23T13:54:12+0200] [ALPM-SCRIPTLET] Found initrd image: /boot/initramfs-linux-cachyos-lto.img
4469   │ [2024-06-23T13:54:13+0200] [ALPM-SCRIPTLET] Found fallback initrd image(s) in /boot:  initramfs-linux-cachyos-lto-fallback.img
4470   │ [2024-06-23T13:54:13+0200] [ALPM-SCRIPTLET] Warning: os-prober will be executed to detect other bootable partitions.
4471   │ [2024-06-23T13:54:13+0200] [ALPM-SCRIPTLET] Its output will be used to detect bootable binaries on them and create new boot entries.
4472   │ [2024-06-23T13:54:13+0200] [ALPM-SCRIPTLET] Adding boot menu entry for UEFI Firmware Settings ...
4473   │ [2024-06-23T13:54:13+0200] [ALPM-SCRIPTLET] Detecting snapshots ...
4474   │ [2024-06-23T13:54:13+0200] [ALPM-SCRIPTLET] Found snapshot: 2024-06-23 13:47:08 | timeshift-btrfs/snapshots/2024-06-23_13-47-08/@ | ondemand | {timeshift-autosnap} {created before upgrade} |
4475   │ [2024-06-23T13:54:13+0200] [ALPM-SCRIPTLET] Found snapshot: 2024-06-22 23:49:10 | timeshift-btrfs/snapshots/2024-06-22_23-49-10/@ | ondemand | After restore (mkinitcpio problems)           |
4476   │ [2024-06-23T13:54:13+0200] [ALPM-SCRIPTLET] Found 2 snapshot(s)
4477   │ [2024-06-23T13:54:13+0200] [ALPM-SCRIPTLET] Unmount /tmp/grub-btrfs.0KlT1XLhwp .. Success
4478   │ [2024-06-23T13:54:13+0200] [ALPM-SCRIPTLET] Found memtest86+ image: /boot/memtest86+/memtest.bin
4479   │ [2024-06-23T13:54:13+0200] [ALPM-SCRIPTLET] Found memtest86+ EFI image: /boot/memtest86+/memtest.efi
4480   │ [2024-06-23T13:54:14+0200] [ALPM-SCRIPTLET] done

Ok, i was able to genererate the initram image doing the following:

  1. Making a script to generate the mkinitcpio presets taking the functions from /usr/share/libalpm/scripts/mkinitcpio (that is the script runned by the hook)

  2. Manually coping the vmlinuz kernel image from /usr/lib/moudes/* to /boot (since after the pacman installation the vmlinuz image in not present in /boot)

  3. Running mkinitcpio -P and grub-mkconfig -o /boot/grub/grub.cfg

This is the script that I am running to generate presets and work well:

install_preset() {
    local pkgbase="$1" preset="$2"

    if [[ ! -e "$preset" ]]; then
        if [[ -e "$preset.pacsave" ]]; then
            # move the pacsave to the template
            mv -- "${preset}.pacsave" "$preset"
        else
            # create the preset from the template
            sed "s|%PKGBASE%|${pkgbase}|g" /usr/share/mkinitcpio/hook.preset \
                | install -Dm644 /dev/stdin "$preset"
        fi
    fi
}

for pkgbase_path in /usr/lib/modules/*/pkgbase; do
    if read -r pkgbase &>/dev/null <"$pkgbase_path"; then
        preset="/etc/mkinitcpio.d/${pkgbase}.preset"
        install_preset "$pkgbase" "$preset"
    fi
done

The weird thing is that the mkinitcpio-remove hook works fine when I remove a kernel. An it is the same script, just with a different argument

Install hook

Exec = /usr/share/libalpm/scripts/mkinitcpio install

remove hook

Exec = /usr/share/libalpm/scripts/mkinitcpio remove

I tried to replace the hook script with just a simple script like that

echo "It works!"

so now both the mkinitcpio-install and the mkinitcpio-remove hooks execute the same thing.
Still, the hooks print “It works!” just when I remove a kernel and fail when I install a kernel, so something must be wrong in the hook configuration /usr/share/libalpm/hooks/90-mkinitcpio-install.hook

There is mine:

───────┬──────────────────────────────────────────────────────────────────────────────────
       │ File: 90-mkinitcpio-install.hook
───────┼──────────────────────────────────────────────────────────────────────────────────
   1   │ [Trigger]
   2   │ Type = Path
   3   │ Operation = Install
   4   │ Operation = Upgrade
   5   │ Operation = Remove
   6   │ Target = usr/lib/initcpio/*
   7   │ Target = usr/lib/firmware/*
   8   │ Target = usr/src/*/dkms.conf
   9   │ Target = usr/lib/systemd/systemd
  10   │ Target = usr/bin/cryptsetup
  11   │ Target = usr/bin/lvm
  12   │ 
  13   │ [Trigger]
  14   │ Type = Path
  15   │ Operation = Install
  16   │ Operation = Upgrade
  17   │ Target = usr/lib/modules/*/vmlinuz
  18   │ 
  19   │ [Trigger]
  20   │ Type = Package
  21   │ Operation = Install
  22   │ Operation = Upgrade
  23   │ Target = mkinitcpio
  24   │ Target = mkinitcpio-git
  25   │ 
  26   │ [Action]
  27   │ Description = Updating linux initcpios...
  28   │ When = PostTransaction
  29   │ Exec = /usr/share/libalpm/scripts/mkinitcpio install
  30   │ NeedsTargets
───────┴──────────────────────────────────────────────────────────────────────────────────

Ok I found the problem. There was a weird mkinitcpio-install hooks in /etc/pacman.d/hooks/ that was overriding the hook in /usr/share/libalpm/hooks/.

Deleting it solved the problem.
Many thanks anyway.