Inspired by https://wiki.debian.org/GrubEFIReinstall
Useful for UEFI-GPT-SecureBoot-LVM-Grub-DebianInstaller 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 abou 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 techs 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-installed installs in the mode it is actually being run (sort of gotcha as manu 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
- 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 got next? Unbootable system unfortunately. But never mind there is a solution - just reboot and reinstall the grub. But how if the system's unbootable? I can recommend using netinst's rescue mode, mounting relater partitions, chrooting the target and running the actual reinstall.
- boot the netinst USB stick - should have it ready from the installation process
- make sure you go through network and disk subsystem detection (otherwise the freshly prepared partitions will not be available)
- 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 EFI setup
- then do 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
Just pull the USB stick before the
reboot command and you should be rebooting to the fixed system now.