I update my Linux servers regularly. What I do less regularly is restarting them. So I was not really surprised when one of them failed to boot with "
you need to load the kernel first" message. What I usually do is: select the old kernel, boot the darn thing up, and then refresh grub. However, this time I overdid it so even the attempt to boot the old kernel produced the same message. It was time for troubleshooting.
While I knew which kernels wouldn't boot, I didn't actually know which kernels I have available. Fortunately,
grub has a command line mode hidden behind '
c' key press. There I selected my disk and listed all files:
It helps if you know how your partitions are setup for this to work but, in the worst case scenario, you can also go over each partition to find
vmlinuz files. This is also the reason why I leave the boot partition unencrypted. Had my boot partition been encrypted, this step would be impossible and more involved recovery would be needed.
In this case, I was able to find
vmlinuz files and I saw that the newest kernel I had installed was
18.104.22.168. Armed with that knowledge I went back to the main
On the main screen I went to the edit option hidden behind '
e' keypress. There it was simple to edit existing commands (both
initrd) to update the kernel version to match the one I had on my disk, followed by
F10 keypress. Voila! My linux was booting.
Mind you, this wasn't a permanent solution since the next reboot would leave me with the same issue. What I needed was to update
grub (and I might as well update
initramfs while I'm at it).
From the prompt, two commands were enough to make my next reboot a boring affair.
sudo update-initramfs -k all -u
And that's it. Now my
grub and my kernels are back in sync. At least for a while.