Restoring the GRUB bootloader on LVM-encrypted Debian 12
Microsoft's latest Windows 11 update decided to blow away my dual-boot config because Microsoft apparently hasn't been involved in an antitrust lawsuit recently enough. (Seriously, I liken this to buying a Ford vehicle and then discovering that it actively disables any non-Ford vehicles also parked in your driveway. Not cool, Microsoft.)
Anyhow, since I run Debian 12 with LVM and an encrypted root filesystem, recovering the grub bootloader was a very manual process. I'm adding the steps I used here for my own future reference. Yours will probably be different. This assumes you know your way around Linux, hardware device mappings, &etc. Please don't ask me for help recovering your own system unless you're also offering me $200/hr for my time.
- Boot Debian 12 install media, Advanced Options, "Rescue Mode"
- Follow the prompts but then "continue with no root filesystem", drop to an installer shell
- The encrypted LVM logical volume should already be in /dev/mapper. Open it with: (substitude the Logical Volume name for $LVNAME)
cryptsetup luksOpen /dev/mapper/$LVNAME $LVNAME_crypt mount /dev/mapper/$LVNAME_crypt /mnt
- Double check
/mnt/etc/fstabto make sure the root fs name you used in cryptsetup is the one also here. If not,unmount /mnt, close the luksCrypt mapping, and go back to step 3 but use the correct root mount point name for the mapping. fdisk -l /dev/nvme0n1(or whatever your drive is) to find the /boot and /boot/EFI partitions- mount them under the new rootfs:
mount /dev/nvme0n1p4 /mnt/boot mount /dev/nvme0n1p1 /mnt/boot/efi
- Attach all the virtual filesystems needed to make everything function:
mount --bind /proc /mnt/proc mount --bind /dev /mnt/dev mount --bind /dev/pts /mnt/dev/pts mount --bind /sys /mnt/sys
chroot /mnt9. Mount efivarfs under efivarsmount -t efivarfs none /sys/firmware/efi/efivars
- Reinstall grub on the drive (not on one of the partitions) substitute your primary drive device for nvme0n1
grub-install /dev/nvme0n1 - exit chroot and reboot to get back into your orphaned Debian OS.
- Boot into Debian 12
- Re-enable os-prober in
/etc/default/grub - Rebuilt grub.cfg and reinstall it:
grub-mkconfig >/boot/grub/grub.cfg
grub-install
Now everything should be back to the way it was. Bill, I'll send you an invoice for the two hours of my morning you just stole from me.