Kernel panic after broken update, pacman not working inside chroot

I was able to solve the issue so I’m just posting this if it happens to anyone else, I’m seeing lot of other posts already, sadly I forgot to take logs while I was in the live usb so I cannot give specific details but they were similar to the ones in the linked discussions anyway.

Please be careful as this was an emergency fix and you may break your system even more, so don’t follow these steps blindly especially without being ready to reformat everything.

After running yay to update some packages (nothing big actually) the system freezed and I had to reboot it with the power button. I’m on a Lenovo laptop with an AMD cpu and NVIDIA GPU running kernel 6.6.23-1-lts with windows in dual boot

  1. the boot menu works fine and windows works correctly
  2. endeavour will not start with the normal or fallback kernel, giving various errors

I downloaded the latest ISO and booted it live, entered the main installation with arch-chroot and noticed a lot of weird behaviour, some libraries inside /usr/lib and /usr/lib32 got corrupted, making it impossible to run pacman, nano, inxi and almost everything else.

Long story short:

  • I updated the live system with pacman -Syu to match the libraries version with the installed linux
  • installed on the live system the packages which were broken on the main installation but missing on the live system
  • copied the valid libraries from \usr\lib and \usr\lib32 on the live system to the main one, using cp -p to preserve permissions etc, overwriting the broken ones. I did not need to copy them all, but just enough to make pacman work. Start from liblzma
  • at this point I was able to run pacman inside the chrooted system and reinstall all the packages with pacman -S $(pacman -Qnq)
  • the system now boots fine and everything is working again

Weird behaviours on the chrooted system:

  • ls did not work, it always gave empty results, but if I used tab to trigger the automatic completion it did show the correct results
  • creating and copying files did not work, as if the changes were not applied to the disk

Workarounds:

  • copying/editing/creating or deleting files must be done from the live usb on and not directly from the chrooted system. Be careful to use the correct paths starting with /mnt to avoid breaking the live usb!
  • pacman-static can be downloaded and run as a standalone pacman. As with the user in the linked discussion there were various permissions errors, just copy it from the live usb to /mnt/usr/bin (or where you mounted it) and give it a chmod +x pacman-static for good measure. At this point the chrooted system was able to see and run it but it was still too broken to work. This can probably be done with other binaries too
  • broken signatures: I temporarily set in /etc/pacman.conf SigLevel = Never to try and skip them but it did not work, I just realized that the one I set it is the default value but it gets overwritten below, so maybe it would have worked if I set it everywhere. Anyway nothing worked until the correct libraries were copied. In the meanwhile I had tried to recreate them deleting /mnt/etc/pacman.d/gnupg from the live usb, and then using from the chrooted system pacman-key --init which worked and pacman-key --populate which failed (arch wiki link). After copying the libraries pacman still failed because of the signatures but I was able to follow the key reset procedure again and it worked, allowing pacman to update

Some links on this forum related to my issue:

Some error messages for easier searching:

error while loading shared libraries: /usr/lib/liblzma.so.5: file too short
bash: ./pacman-static: Permission denied

The system got broken again in the same way so I’m adding some more logs:

chrooted system

[root@EndeavourOS /]# yay
yay: error while loading shared libraries: /usr/lib/libassuan.so.0: file too short

[root@EndeavourOS /]# ls -la /usr/lib/libassuan.so*
lrwxrwxrwx 1 root root 18 Apr  1 12:15 /usr/lib/libassuan.so -> libassuan.so.0.8.7
lrwxrwxrwx 1 root root 18 Apr  1 12:15 /usr/lib/libassuan.so.0 -> libassuan.so.0.8.7
-rwxr-xr-x 1 root root  0 Apr  1 12:15 /usr/lib/libassuan.so.0.8.7


# we can use this to check for missing files but this was not the issue since the files are available but empty
[root@EndeavourOS /]# pacman -Qk 2>/dev/null | grep -v ' 0 missing files' | cut -d: -f1

# not sure if this is correct

[root@EndeavourOS /]# find /usr/lib -name files -size 0

live system

[liveuser@eos-2024.01.25 ~]$ ls -la /usr/lib/libassuan.so*
lrwxrwxrwx 1 root root    18 Jun 20  2023 /usr/lib/libassuan.so -> libassuan.so.0.8.6
lrwxrwxrwx 1 root root    18 Jun 20  2023 /usr/lib/libassuan.so.0 -> libassuan.so.0.8.6
-rwxr-xr-x 1 root root 84072 Jun 20  2023 /usr/lib/libassuan.so.0.8.6

# different version so lets check what the related packages are:

[liveuser@eos-2024.01.25 ~]$ pacman -Qi libassuan
Name            : libassuan
Version         : 2.5.6-1
Description     : IPC library used by some GnuPG related software
Architecture    : x86_64
URL             : https://www.gnupg.org/related_software/libassuan/
Licenses        : GPL3
Groups          : None
Provides        : libassuan.so=0-64
Depends On      : glibc  libgpg-error  sh
Optional Deps   : None
Required By     : gnupg  pinentry
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 220.92 KiB
Packager        : David Runge <dvzrv@archlinux.org>
Build Date      : Tue 20 Jun 2023 12:03:40 AM CEST
Install Date    : Thu 25 Jan 2024 07:25:45 PM CET
Install Reason  : Installed as a dependency for another package
Install Script  : No
Validated By    : Signature

# update the packages list

[liveuser@eos-2024.01.25 ~]$  sudo pacman -Syy
:: Synchronizing package databases...

# install the correct package version

[liveuser@eos-2024.01.25 ~]$ sudo pacman -S gnupg
resolving dependencies...
looking for conflicting packages...

Package (1)  Old Version  New Version  Net Change  Download Size

core/gnupg   2.4.3-2      2.4.5-1        0.17 MiB       2.68 MiB


# if installing packages throws a 404 error update them

[liveuser@eos-2024.01.25 ~]$ eos-rankmirrors
==> eos-rankmirrors: info: fetching https://gitlab.com/endeavouros-filemirror/PKGBUILDS/-/raw/master/endeavouros-mirrorlist/endeavouros-mirrorlist ...
==> eos-rankmirrors: info: ranking EndeavourOS mirrors, please wait ...

# copy the files

[liveuser@eos-2024.01.25 ~]$ sudo cp -p /usr/lib/libassuan.so* /mnt/usr/lib

back on the chrooted system

[root@EndeavourOS /]# ls -la /usr/lib/libassuan.so*
lrwxrwxrwx 1 root root    18 Apr  1 12:15 /usr/lib/libassuan.so -> libassuan.so.0.8.7
lrwxrwxrwx 1 root root    18 Apr  1 12:15 /usr/lib/libassuan.so.0 -> libassuan.so.0.8.7
-rwxr-xr-x 1 root root 84072 Jun 20  2023 /usr/lib/libassuan.so.0.8.6
-rwxr-xr-x 1 root root 84072 Jun 20  2023 /usr/lib/libassuan.so.0.8.7

[root@EndeavourOS /]# pacman -Qi libassuan
Name            : libassuan
Version         : 2.5.7-2
Description     : None
Architecture    : None
URL             : None
Licenses        : None
Groups          : None
Provides        : None
Depends On      : None
Optional Deps   : None
Required By     : gnupg  pinentry
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 0.00 B
Packager        : None
Build Date      : Thu 01 Jan 1970 01:00:00 AM CET
Install Date    : Thu 01 Jan 1970 01:00:00 AM CET
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Unknown

# broken db lock

[root@EndeavourOS /]# sudo pacman -Sy endeavouros-keyring
:: Synchronizing package databases...
error: failed to synchronize all databases (unable to lock database)

[root@EndeavourOS /]# rm /var/lib/pacman/db.lck

# reinstall all the packages again
# if we get  "exists in filesystem" errors we need to clean the pacman cache
[root@EndeavourOS /]# pacman -S $(pacman -Qnq)
...
node-gyp: /usr/lib/node_modules/node-gyp/node_modules/ip-address/dist/address-error.js exists in filesystem
node-gyp: /usr/lib/node_modules/node-gyp/node_modules/ip-address/dist/address-error.js.map exists in filesystem

# cache cleaning with this and the run the reinstall again, everything should work
[root@EndeavourOS /]# pacman -Scc


Sadly updating the live image is now a problem with the switch to kde6 + new kernels and it broke the mount so I’m doing this without updating
I also noticed the kernel name switched to arch

Anyway if it breaks again I’d like to fix it permanently instead of reinstalling

Exact same configuration. I am on a Yoga Pro 7 14ARP8. I have been experiencing some freezes and kernel panics in the last few months. Not sure since when precisely. I had issues resuming from suspend in integrated graphics mode. They’re gone now that I use only hybrid mode, but still getting crashes from time to time. Especially on shutdown. And twice while updating.
Any idea why, or if the issue/bug has been identified?

After kernel panic during the update, I also managed to solve in a similar way. Since chrooted pacman was broken also in my case, instead of pacman-static I figured that it’s possible to launch pacman from the live system but with the --root /mnt flag so that it affects packages on the mounted (broken) system.

You can find more details on my post here

Damn I missed your post it would have spared me a couple of hours of search.
Anyway I checked the manjaro forum and it seems they have the same issues (a bit less, if I’m not wrong manjaro is slower to update stuff so maybe that’s the reason).
If I wanted to try anything I would switch to an older kernel, either 6.4 or 6.1, and then wait for 6.7 (or maybe 6.8) to be stable, since from the posts on the manjaro forum it seems 6.5 and 6.6 are problematic.
In the meanwhile I’ll just avoid updating the system until at least kernel 6.7 stable is available or I’ll move from lts to directly use it.

browsing endeavour, arch and nvidia forums and reddit threads all day :face_with_spiral_eyes: :face_with_spiral_eyes: :face_with_spiral_eyes: has yielded 2 possible solutions to this:

1: its a systemd issue. solved by executing

sudo touch /etc/systemd/do-not-udevadm-trigger-on-update

2: its an nvidia driver issue with the 550 beta series drivers. downgrading to 545 and 535 is suggested.

For now I tried creating the file, I tried downgrading nvidia-dkms to 545 but it whines about nvidia-utils and another one not being on the right version (of course). Don’t have time to switch to another driver or investigate how to downgrade correctly (it seems I just need to uninstall them and then install the 545 version). I will report after rebooting and running yay since I can see a kernel update, finger crossed

$ sudo downgrade nvidia-dkms                                                                                                                        
loading packages...
warning: downgrading package nvidia-dkms (550.67-1 => 545.29.06-4)
resolving dependencies...
warning: cannot resolve "nvidia-utils=545.29.06", a dependency of "nvidia-dkms"
:: The following package cannot be upgraded due to unresolvable dependencies:
      nvidia-dkms

:: Do you want to skip the above package for this upgrade? [y/N] 
error: failed to prepare transaction (could not satisfy dependencies)
:: unable to satisfy dependency 'nvidia-utils=545.29.06' required by nvidia-dkms
$  yay
:: Synchronizing package databases...
 endeavouros is up to date
 core is up to date
 extra                                                              8,1 MiB  2,40 MiB/s 00:03 [-------------------------------------------------------] 100%
 multilib is up to date
:: Searching AUR for updates...
:: Searching databases for updates...
:: 33 packages to upgrade/install.
33  endeavouros/eos-bash-shared      24.16.3-1            -> 24.16.4-1
32  endeavouros/eos-update-notifier  24.1-1               -> 24.4-1
31  endeavouros/nvidia-hook          1.5-1                -> 1.5-2
30  core/filesystem                  2024.01.19-1         -> 2024.04.07-1
29  core/gnutls                      3.8.4-1              -> 3.8.5-1
28  core/hwdata                      0.380-1              -> 0.381-1
27  core/libnghttp2                  1.60.0-1             -> 1.61.0-1
26  core/linux-lts                   6.6.24-1             -> 6.6.25-1
25  core/linux-lts-headers           6.6.24-1             -> 6.6.25-1
24  core/man-db                      2.12.0-1             -> 2.12.1-1
23  core/pciutils                    3.11.1-1             -> 3.12.0-1
22  core/pcre2                       10.43-2              -> 10.43-3
21  extra/ayatana-ido                0.10.1-1             -> 0.10.2-1
20  extra/containerd                 1.7.14-1             -> 1.7.15-1
19  extra/discord                    0.0.47-2             -> 0.0.48-1
18  extra/hwdetect                   2024.03.05-1         -> 2024.04.09.0801-1
17  extra/libproxy                   0.5.4-1              -> 0.5.5-1
16  extra/libunwind                  1.8.1-1              -> 1.8.1-2
15  extra/libx11                     1.8.8-3              -> 1.8.9-1
14  extra/libxmlb                    0.3.16-1             -> 0.3.17-1
13  extra/lutris                     0.5.16-1             -> 0.5.16-2
12  extra/mesa-utils                 9.0.0-3              -> 9.0.0-4
11  extra/nix                        2.21.1-2             -> 2.21.2-1
10  extra/pavucontrol                1:5.0+r64+geba9ca6-1 -> 1:5.0+r66+gc330506-1
 9  extra/python-argcomplete         2.0.0-2              -> 3.1.1-1
 8  extra/python-pikepdf             8.14.0-1             -> 8.15.0-1
 7  extra/qca-qt5                    2.3.8-2              -> 2.3.8-3
 6  extra/qca-qt6                    2.3.8-2              -> 2.3.8-3
 5  extra/qt5-base                   5.15.13+kde+r142-1   -> 5.15.13+kde+r145-1
 4  extra/rsync                      3.2.7-6              -> 3.3.0-1
 3  extra/soundtouch                 2.3.2-1              -> 2.3.3-1
 2  extra/upower                     1.90.2-1             -> 1.90.4-1
 1  multilib/lib32-libnghttp2        1.60.0-1             -> 1.61.0-1
==> Packages to exclude: (eg: "1 2 3", "1-3", "^4" or repo name)
 -> Excluding packages may cause partial upgrades and break systems

It seems to work but I also noticed an update to endeavouros/nvidia-hook that may also have been a fix? Looking for a changelog or something now…

$ cat /usr/share/libalpm/hooks/eos-nvidia-fix.hook 
[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = nvidia
Target = nvidia-lts

[Action]
When = PostTransaction
Exec = /usr/bin/eos-nvidia-fix

without looking at the eos-nvidia-fix file, i would say keep the file you created earlier and stay on the 545 drivers. also did you need to downgrade your kernel when you installed the 545 drivers?

edit: i havent updated in a few days but i do have the file present on my system and it just rebuilds kernels after nvidia driver installs. not a fix for this issue :frowning:

I just used the file, did not downgrade the nvidia drivers or kernel, I should still have the 550 for nvidia and 6.6 for the kernel. I had 2 updates, both working with no issues,

1 Like

Just did a third update and it worked

i havent updated in a few days but i do have the file present on my system and it just rebuilds kernels after nvidia driver installs.

this fixes the problem of the system breaking down on updates, is this still happening to you? Nvidia drivers are “kernel modules”, which need to be embedded in the kernel when a new version is out.

A kernel module (or loadable kernel mode) is an object file that contains code that can extend the kernel functionality at runtime (it is loaded as needed); When a kernel module is no longer needed, it can be unloaded. Most of the device drivers are used in the form of kernel modules.

the do-not-udevadm-trigger-on-update option just stops udev from reloading devices after a driver update

When system updates or changes occur, such as installing or updating device drivers, udevadm might be triggered to reload device information or perform other actions related to device management.

The “do-not-udevadm-trigger-on-update” directive could serve to prevent udevadm from being triggered during specific update operations. This might be necessary to avoid potential conflicts or unintended consequences, especially when updating critical system components like drivers or kernel modules.

i meant that the file did not contain any udev option to prevent the trigger or any other fixes pertaining to udev issue. sorry for the confusion :sweat_smile:

I think what’s applying the option is the file existing or not