ZhoubaWiki:FixGrubUsingRescueMode

From ZhoubaWiki
Revision as of 16:34, 22 May 2021 by Garak (talk | contribs) (Created page with "Inspired by https://wiki.debian.org/GrubEFIReinstall Useful for UEFI-GPT-SecureBoot-LVM-Grub-Debian-Installer hell. So what to do? For T470p I had to upgrade BIOS setup uti...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Inspired by https://wiki.debian.org/GrubEFIReinstall

Useful for UEFI-GPT-SecureBoot-LVM-Grub-Debian-Installer hell.

So what to do?

For T470p I had to upgrade BIOS setup util first. Not really sure it is actually necessary; but it is heavily recommended. I have installed the system about 8 times today, so I am not gonna doublecheck whether this is one of the dealbreakers or not. Do it just to be sure.. (Actually it would be very nice if Lenovo would offer other possibilities to flash the UEFI BIOS using some more recent tech than from windows or CD)

Then, at least for Debian 10 (Buster) Secure boot feature is said to be supported. So drop the usual MBR+BIOS boot stuff and set up the newfangled shiny options in BIOS setup. Which?

  • Secure boot ENABLED
  • UEFI mode NATIVE
  • CSM OFF (legacy boot support)
  • Also enable UEFI mode for USB sticks as debian-installer installs in the mode it is actually being run (sort of gotcha as many machines have USB UEFI disabled by default - so one would install unbootable system very easily)

Make sure the disk is partitioned to have

  • standard non-LVM /boot partition
  • EPS (EFI partition stub) again in a non-LVM way
  • rest of the partitions can be configured as LVM as usual

Then run the installation as usual.

What do we get next? Unbootable system unfortunately. But never mind there is a solution - just reboot and reinstall the grub. But how since the system's unbootable? I recommend using netinst's rescue mode, mounting related partitions, chrooting the mount point and running the actual reinstall.

  1. boot the netinst USB stick - should have it ready from the installation process
  2. make sure you go through network and disk subsystem detection (otherwise the freshly prepared partitions will not be available)
  3. the rescue-mode installer should offer you root-system selection - use the installer's root as your /boot partition ain't part of the root partition due to the LVM setup
  4. mount all the partitions relevant for grub reinstall
mount /dev/mapper/<vg-name--root-lv-name> /mnt
mount /dev/mapper/<vg-name--home-lv-name> /mnt/home
mount /dev/mapper/<vg-name--var-lv-name> /mnt/var
mount /dev/mapper/<vg-name--usr-lv-name> /mnt/usr
mount /dev/nvme0n1p<x> /mnt/boot
mount /dev/nvme0n1p<x-1> /mnt/boot/efi

for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -o bind $i /mnt$i; done

chroot /mnt

grub-install /dev/nvme0n1

update-grub

^D

reboot

Don't forget to pull the USB stick before the reboot command and you should be rebooting to the fixed system now.


P.S. And one good tip before saying bye: Unplug all SD cards and unnecessary removable media before grub (re)install. I found out to have EFI boot parts of the grub setup installed to a 256M SD card (plugged into a laptop slot) to my great surprise!