Another kernel panic - not syncing

tl;dr
Is there a recommended way of generating the initramfs in case the presets in /etc/mkinitcpio.d do not match the version in /boot ?


Today I booted my computer and got a

kernel panic - not syncing:
VFS: Unable to mount root fs on …

error. I investigated it and I am completely certain that the issue is that I don’t have an initramfs for the kernel 5.10.47-1-rt46.

I have an initramfs-5.4-x86_64.img so I can still login after rebooting and choosing the old version.

I understand that I need to generate a new initramfs. So I run

sudo pacman -S mkinitcpio

followed by (I don’t have another linux510 preset, so this is the only one I can run)

mkinitcpio -p linux510-rt

but I get the following error message

==> Building image from preset: /etc/mkinitcpio.d/linux510-rt.preset: ‘default’
→ -k /boot/vmlinuz-5.10-rt-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.10-rt-x86_64.img
==> ERROR: specified kernel image does not exist: /boot/vmlinuz-5.10-rt-x86_64' ==> Building image from preset: /etc/mkinitcpio.d/linux510-rt.preset: 'fallback' -> -k /boot/vmlinuz-5.10-rt-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.10-rt-x86_64-fallback.img -S autodetect ==> ERROR: specified kernel image does not exist: /boot/vmlinuz-5.10-rt-x86_64’

If I run

ls /boot

I get the following two versions of vmlinuz:

vmlinuz-5.10-x86_64
vmlinuz-5.4-x86_64

Furthermore

cat /etc/mkinitcpio.d/linux510-rt.preset

returns this

#mkinitcpio preset file for the ‘linux510-rt’ package

ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-5.10-rt-x86_64"

PRESETS=(‘default’ ‘fallback’)

#default_config="/etc/mkinitcpio.conf"
default_image="/boot/initramfs-5.10-rt-x86_64.img"
#default_options=""

#fallback_config="/etc/mkinitcpio.conf"
fallback_image="/boot/initramfs-5.10-rt-x86_64-fallback.img"
fallback_options="-S autodetect"

Clearly, the preset path to the kernel does not match what is in the /boot folder. I can imagine that just changing the name in the preset will allow me to run the mkinitcpio and produce the initramfs, but I am not sure whether that is the “correct” way of doing this and I would like to avoid breaking anything else.

My question is
Is there a recommended way of generating the initramfs in case the presets in /etc/mkinitcpio.d do not match the version in /boot ?

And if the answer is no, what should I do to minimize the chances of things getting screwed up again in the future?

EDIT:

I created another preset linux510.preset, which is the same as linux510-rt.preset except that I substituted 5.10-rt with 5.10. Then I ran mkinitcpio with root privileges and the initramfs was generated. Unfortunately, after booting, I still get the error.

I did more research earlier and I saw that one of the causes of this could be the lack of space in /boot. I don’t think that this can be the problem, since

df -sh

returns

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 511M 3.8M 508M 1% /boot/efi

among other things.

If that is the case, something got screwed up.
Each installed kernel package places its preset file in /etc/mkinitcpio.d.
If you have non-matching images and/or kernels in /boot: remove them manually. They do not belpng to installed kernels and will cause problems down the road.

To generate images for all currently installed kernels use:

$ sudo mkinitcpio -P

Again: remove kernel Images that did not get listed in that output.

1 Like

Thanks so much for this. I removed the 5.10 version. One last question. What do I do with this error:

ERROR: specified kernel image does not exist: /boot/vmlinuz-5.10-rt-x86_64
?

It’s trying to run linux510-rt.preset, but I have no such version. Should I also remove this preset or should I just ignore the error?

Thanks again!

Check if that file indeed does not belong to any package:

$ pacman -Qo /etc/mkinitcpio.d/linux510-rt.preset

If not, remove it else remove the package.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.