Restoring the GRUB bootloader on LVM-encrypted Debian 12

From SolaceWiki
Revision as of 13:01, 25 January 2025 by Kc (talk | contribs) (Created page with "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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.


1. Boot Debian 12 install media, Advanced Options, "Rescue Mode"

2. Follow the prompts but then "continue with no root filesystem", drop to an installer shell

3. 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

5. Double check /mnt/etc/fstab to 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.

6. fdisk -l /dev/nvme0n1  (or whatever your drive is) to find the /boot and /boot/EFI partitions

7. mount them under the new rootfs:

mount /dev/nvme0n1p4 /mnt/boot
mount /dev/nvme0n1p1 /mnt/boot/efi

8. 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

9. chroot /mnt 10. Mount efivarfs under efivars

mount -t efivarfs none /sys/firmware/efi/efivars

11. Reinstall grub on the drive (not on one of the partitions) substitute your primary drive device for nvme0n1

grub-install /dev/nvme0n1

12. exit chroot and reboot to get back into your orphaned Debian OS.

Note:  I wasn't able to get grub-prober to find the Windows boot manager in rescue mode, so this returns the system to being able to boot Debian but not to the original multiboot.

13. Boot into Debian 12 14. Re-enable os-prober in /etc/default/grub

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.