Fixing A Linux Box with no kernel (from GRUB 2)

This is not a chroot magic session. This is borrowing a kernel to get to a native system with a networking stack, and reinstalling your kernel from your distribution’s repositories. Takes about 10 minutes. This is aimed at someone who does not need their hand held every step of the way. You’re a grown man, you can figure it out.

You’re going to need a way to get a kernel on the machine. GRUB does not have a networking stack, so the easiest option to boot from a live USB (like Debian Standard DVD/USB Hybrid) and copy the vmlinuz and initrd.img from the root directory of your live USB to a folder you mounted your hard disk root on. Rufus is a good tool for Windows for doing USB imaging. You could also pull the hard disk/SSD if you wanted and do that on a host machine.

After you put the kernel on the disk’s root, reboot to get to the GRUB menu. Tell Grub where to find the kernel and initrd.img, with something like this below to boot:

linux (hd0,1)/vmlinuz root=/dev/sda1
initrd (hd0,1)/initrd.img
boot

You will probably have issues with mounting any filesystem type other than what your root disk is, among other issues. That’s because no kernel modules were loaded alongside the one we copied, but that’s fine because we don’t want to clutter the host’s filesystem if we don’t have to. You may end up in “Maintenance mode” and have to type your root password, after you log in, update grub again and reboot. Reinstall your kernel with whatever package manager you use (or compile it if you want), and run update-grub.

If all those programs exited properly, then you should be safe to reboot and your machine will load your freshly installed kernel. If it’s still having issues with all your kernel modules working, reinstall the kernel again, and update grub. For me it takes 2x because of some issue with filesystems not syncing with the liveUSB donor kernel. You should be good until it happens again!

My case was in Debian 10, with the 5.10 kernel. My filesystem is kind of a frankenstein because I early adopted BTRFS before I understood the performance limitations, as well as an inability of my BIOS to recognize a PCIE NVME storage medium as a bootable disk. So, my BTRFS volume is overwritten with bind mounts to my ‘fast’ NVME storage array in EXT4 to overcome my situation. It’s fast, but it does not always successfully reboot for some reason…. at least until I can upgrade my hardware to run only the NVME disk. One day…

Leave a Reply