[GUIDE] How to restore GRUB after a BIOS reset with full-disk encryption and root on BTRFS whit snapshot

Introduction:

This process worked in my specific case, I thought I’d share it here in case anyone finds themselves in the same situation as me.

Problem:

After a hardware upgrade I had to reset the BIOS on my HP ENVY x360 15-ew000 (by holding the power button for 15 seconds with the power off). This re-enabled secure-boot and cleared the Linux boot entries.

Solution:

Premise: I’m not sure if this is the best solution, but I couldn’t reinstall grub with arch-chroot because the boot paths (/boot/efi) were not standard due to BTRFS snapshots. However in my case it worked.

Disclaimer: Follow this guide only if you know what you’re doing, otherwise you may delete your installation’s boot files. I assume no responsibility in case of data loss or problems with your PC!

  1. Install another EndeveourOS (normal configuration, ext4, etc…) with its boot partition. Check in the BIOS that it is the first boot entry.
  2. Once installed and started, open a terminal and type the following commands:
    · sudo fdisk -l Locate the encrypted installation’s boot partition (normally located before the root partition) and the root partition.
    · sudo cryptsetup luksOpen /dev/sda2 root to decrypt the root partition (replace /dev/sda2 with your partition), then enter the passcode.
    · sudo mount /dev/mapper/root /mnt/ to mount the root partition.
    · sudo mount /dev/sda1 /mnt/@/boot/efi/ to mount the boot partition in its correct location (replace /dev/sda1 with your partition).
    · sudo rm /boot/efi/EFI/boot/bootx64.efi to remove the efi file of the new installation
    · sudo rm /boot/efi/EFI/endeavouros/grubx64.efi to remove the efi file of the new installation
    · sudo rm -r /boot/grub/* to remove the grub configurations of the new installation
    · sudo cp /mnt/@/boot/efi/EFI/boot/bootx64.efi /boot/efi/EFI/boot/bootx64.efi copies the “correct” efi file to the boot location
    · sudo cp /mnt/@/boot/efi/EFI/endeavouros/grubx64.efi /boot/efi/EFI/endeavouros/grubx64.efi copies the “correct” efi file to the boot location
    · sudo cp /mnt/@/boot/grub/* /boot/grub/* copies the grub configuration files.
    · sudo umount /dev/sda1 to add the boot partition.
    · sudo umount /dev/mapper/root to populate the root partition.
    · reboot restarts the system
  3. After the reboot, the disk passcode request should appear, then the grub menu of our installation.
  4. If everything was done correctly you can delete the installation partition created for recovery (using gparted). Attention! However, do not delete the boot partition of the installation you just made, because it is the one used to boot your system and you would find yourself in the initial situation.

I hope this guide can be useful to someone.

simdll

Did you try disabling secure boot again?

Yes, but the EndeveourOS boot entry wasn’t restore. If Secure-boot is enable, Linux can’t boot.