Published on

Recovering your linux Kernel

Authors
  • avatar
    Name
    Johnny Liang
    Twitter

boot/vmlinuz error: kernel not found

Update 9/14/2024: To prevent this issue in the future, ensure your computer doesn't shut down/restart during a package upgrade.

What do you do?

I jumped through a lot of hoops to fix this, my greeting for Christmas Eve, and hopefully you don't have to!

The essential idea of this guide is to chroot into your linux installation from a live usb, and to reinstall the kernel as if you were in your actual machine.

Warning: you should have some idea of what you are doing, if you are not running an arch based distro or have a different issue with not being able to boot, this guide is not for you

To begin, my machine was running EndeavourOS, an arch based distro that comes with a cool installer, but I plan on switching to Arch or Artix soon, as well as switching to Hyprland.

I am assuming that your Linux installation is is the only one on your drive, but this guide also works for dual boot drives like I have myself. If you are running a Windows/Linux dual boot, it may help to open the disk utility before beginning the process. It should be called something along the lines of Create and Format Disk Partitions or something along those lines.

You must also have a live usb installation with something like Arch or the EndeavourOS live usb. I will be using the EndeavourOS live installation simply because theres a live desktop environment and you can make web browser searches, connect to the internet via gui, and open multiple terminal windows easily. I am assuming you already know how to do this because you were running linux in the first place.

Do not do these steps until you have read the guide completely, and it may help to have a backup if you're dual booted in case something goes wrong

Step 1: Restart your device

Hold down or repeatedly press the key that will open your boot menu. This is different for all computers, and for me personally it was F12. Search this up if you cannot find it.

Step 2: Setup chroot

Once you are in your live user terminal, type

sudo fdisk -l or sudo lsblk -l to find the boot and efi Partitions

Usually its /dev/sda1 for the efi and /dev/sda2 for the boot, but again this is completely dependent on how you setup your partitions

Because mine was dual booted, my linux partition was /dev/nvme0n1p6 and my efi was /dev/nvme0n1p5

I ran sudo mount /dev/nvme0n1p6 /mnt and sudo mount /dev/nvme0n1p5 /mnt/boot/efi

After this you can finally run sudo arch-chroot /mnt

Ensure you have an internet connection

When you are in chroot, you will most likely be able to run ping but when you try to access the aur using pacman you will get errors because of an unresolved DNS.

To fix this, try to run echo nameserver 1.1.1.1 | sudo tee -a /etc/resolv.conf and if this doesn't work try to copy the /etc/resolv.conf file from your live install to the chroot environment You can also use your own DNS in place of 1.1.1.1 such as 8.8.4.4 or 8.8.8.8 for google or the config generated in the live environment from connecting to the internet.

Next, if you are using EndeavourOS, try running eos-rankmirrors and hopefully you do not get an error message relating to internet. eos-rankmirrors should also resolve problems with accessing the endeavouros mirrors.

Step 4: Reinstalling the Kernel

Test that you have mkinitcpio installed. If not, run pacman -S mkinitcpio for a quick workaround.

If when you run mkinitcpio -P or mkinitcpio -p linux, you receive an error stating that the config is blank, delete the config file and directory in /etc/. Search up your terminal output if this happens. Next run pacman -S linux, and not only should this restore your kernel hopefully but also restore the config files.

Now you can finally run mkinitcpio -p linux in your chroot environment and it should work, and ignore the large verbose outputs. This goes for pacman -S linux as well. On EndeavourOS dracut will spit out a bunch of install errors.

THIS IS AN IMPORTANT STEP

YOU MUST UNMOUNT EVERTHING AS THE LIVEUSER, NOT IN THE CHROOT ENVIROMENT

If in the chroot environment, a simple exit should suffice.

Unmount /boot/efi first sudo umount /mnt/boot/efi

Next

sudo umount /mnt/

Check that /mnt is empty by cd into /mnt and running ls

Step 6: Restart!

You did it! Restart your machine and boot into your linux install, whether it be through the grub menu, the normal boot menu, or if it boots into linux by default. If /boot/vmlinuz is still gone, please consult forum posts or try to backtrack your way through this post. Hopefully I have saved you pain through this guide and not blown up your system for you.

Merry Christmas!