This problem may appear at the boot when GRUB tries to load the kernel and you will have a black screen with the following lines on it:
error: file '/boot/vmlinuz-X.X-x86-64' not found.
error: you need to load the kernel first.
Basically, GRUB can't find the kernel. Why ? Because it doesn't exist anymore, or GRUB doesn't look for the good one. In my case, the kernel was not here anymore after an update and I still don't know why. So I just install a new one to make GRUB happy again.
First of all, I will say that you should try to change the GRUB configuration to load an other kernel than the one it tries to, sometimes it is just a GRUB configuration that is not working
But for me, I diagnotised that my kernel was deleted and so even 'mkinitcpio' command can't do anything to help me...
That said, let's dive into what I have found !
Prerequisite:
- Linux distro live on a USB or HDD or anything to boot on
- Internet connection to install a new kernel via pacman
-
Open a terminal
-
We need to have the super user privileges, so we enter the following command:
su
- We create a new directory in the '/mnt' directory. You can name it whatever you want. For the following help, I called it 'Manjaro'. So you will need to change the directory name 'Manjaro' with the one you choose. Then you need to change your working directory for the newly created. Here is the command to do so:
mkdir /mnt/Manjaro && cd /mnt/Manjaro
OR this one if you prefer to have auto-completion:
mkdir /mnt/Manjaro
cd /mnt/Manjaro
- Then we need to know where is installed the broken OS.
os-prober
You will have one or more lines, if you have multiple OSes installed. Every line will be like this, more or less:
/dev/sdXY:Manjaro
X is for the drive name, and Y for the number of it. Instead of 'sdXY', it can also look like 'nvme.....' or other things.
- After that, we need to mount the system directories to fix them. Replace 'sdXY' with the one for your OS.
mount /dev/sdXY /mnt/Manjaro
mount -t proc proc proc/
mount --rbind /sys sys/
mount --rbind /dev dev/
- We change the root directory so we are in the broken OS, like this:
chroot /mnt/Manjaro
- If there is a file 'db.lck' in the '/var/lib/pacman' directory, we need to remove it to enable the updates via pacman:
rm -f /var/lib/pacman/db.lck
- Then we update the databases and packages already installed:
pacman -Syu
An timeout error might occur, if so, you need to change the '/etc/resolv.conf' file to enable the network. To do so, we need to exit the 'chroot' and then copy the '/etc/resolv.conf' file from the live OS to the broken OS :
exit
cp /etc/resolv.conf /mnt/Manjaro/etc/resolv.conf
chroot /mnt/Manjaro
Now we should be able to update the databases and packages installed with:
pacman -Syu
- We can try to install a new kernel (for me it was 'linux54' but you can change it for whatever kernel in the next commands) with the following command:
mhwd-kernel -i linux54
- If the previous command worked without error, then you can reboot your computer. Otherwise, if you have an error 'no targets specified', like I had, you need to install the kernel linux from pacman like so:
pacman -S linux54
Finally, you can see that GRUB should be updated, and you can now reboot your computer and enjoy.
reboot
If you find any typos or that it is unclear, do not hesitate to tell.