i broke my bootloader at 1am and fixed it from a live usb, here is the exact rescue
Contents
classic arch evening. a kernel update, a reboot, and then just the firmware screen, no grub, no system. my fault, i had been messing with the EFI partition. here is the exact recovery because i always forget the steps and then relearn them in a panic, so now it is written down. distro: arch, systemd, grub, encrypted root. hardware: thinkpad, UEFI.
step 1: boot a live usb
any arch live usb. boot it, get to the shell. do not panic yet, your data is almost certainly fine, the bootloader is just a signpost and you knocked the signpost over.
step 2: find and mount your partitions
use lsblk to see your disks. mount your root partition (for me, unlock the encrypted one first with cryptsetup, then mount the logical volume) to /mnt, and crucially mount your EFI partition to /mnt/boot (or wherever yours lives). this is the step people forget and then wonder why the bootloader fix does nothing: grub lives on the EFI partition and if you did not mount it, you are reinstalling grub into thin air.
step 3: chroot in
arch-chroot /mnt. now you are "inside" your real system using the live usb's kernel. everything you run now affects your actual install.
step 4: reinstall and regenerate grub
grub-installpointed at your EFI directory, with the right target for UEFI.grub-mkconfig -o /boot/grub/grub.cfgto regenerate the config so it finds the new kernel.- if your root is encrypted, make sure the config and initramfs actually reference the right UUID, this is where i had gone wrong, i had a stale UUID after resizing.
step 5: exit, unmount, reboot, breathe
exit the chroot, unmount everything cleanly, pull the usb, reboot. grub came back. total time maybe 20 minutes, 15 of which was me being scared.
the actual lesson
keep a live usb in your bag, always. and the thing that saved me was not the commands, it was that i knew my disk layout, encrypted LVM on this partition, EFI there, because i set it up by hand and understood it. the person who follows a "just copy these commands" install guide and then hits this has no map. learn your own disk layout before you need it. also, maybe do not reboot into a kernel update at 1am. but we both know i will do it again.
Get the best of #linux_desktop_year weekly
One email each Monday with the most useful posts. No spam; unsubscribe in one click.
Comments
Sign in to join the conversation.
Sign in to comment