[Solved] Restoring GRUB after BIOS/UEFI reset with dual-boot Windows & (LUKS encrypted) Manjaro

I have been browsing around the wiki and forums looking for a solution to the problem stated in the title, but I have had no such luck with the provided solutions.

As it stands right now my computer boots directly into Windows, with no GRUB, no option for Manjaro in my boot devices, etc. I would like to get GRUB back with Windows and Manjaro entries as I had it before.

I am currently on a Manjaro live CD.

fdisk -l tells me the following:
/dev/sdb2 is a 100mb "EFI System"
/dev/sdb4 is my Windows 10 partition
/dev/sdb5 is my (LUKS encrypted, but I don't think it uses LVM) Manjaro partition

I have tried the following steps adapted from the "Restore the GRUB Bootloader" wiki page.

  1. Mount the Manjaro system partition:
    Since my partition is encrypted, I executed the following command
    sudo cryptsetup luksOpen /dev/sdb5 encrypted-volume
    I then mounted it by doing the following:
    sudo mkdir /run/media/my-device
    sudo mount /dev/mapper/encrypted-volume /run/media/my-device

  2. Mount the GRUB EFI (bootloader?) partition
    I'm assuming that my sdb2 is the GRUB EFI partition, so I also mount that:
    sudo mount /dev/sdb2 /run/media/my-device/boot

  3. chroot mounted partition(s?) (Do I need to worry about sdb2?)
    cd /run/media/my-device
    sudo mount -t proc proc /run/media/my-device/proc
    sudo mount -t sysfs sys /run/media/my-device/sys
    sudo mount -o bind /dev /run/media/my-device/dev
    sudo mount -t devpts pts /run/media/my-device/dev/pts/
    sudo chroot /run/media/my-device/

  4. Create the /boot/EFI directory
    I already have a /boot/EFI directory that has an entry for Manjaro and Windows
    Is there a difference between efi and EFI here? The wiki uses the lowercase version, but I only have an uppercase one.

  5. Mount the EFI partition as /boot/EFI
    I'm assuming that since I already have /boot/EFI, I'll do the following:
    sudo mount /dev/sdb2 /boot/EFI

  6. Re-install GRUB
    sudo grub-install --target=x86_64-efi --efi-directory=/boot/EFI --bootloader-id=manjaro --recheck

Installing for x86_64-efi platform.
EFI variables are not supported on this system.
EFI variables are not supported on this system.
Installation finished. No error reported.

And here's where our story begins to get a bit rocky. I follow the advice of the wiki but get stuck.

sudo modprobe efivarfs
sudo chroot /run/media/my-device/
mount -t efivarfs efivarfs /sys/firmware/efi/efivarfs
returns: mount: /sys/firmware/efi/efivarfs: mount point does not exist.

Probably because there is no efi folder in /run/media/my-device/sys/firmware/ or on the live CD file system /sys/firmware folder.

I'd appreciate it if someone can help me get unstuck from here. Please let me know if any clarification is necessary and I'll respond ASAP.

Your livecd is not booted up in uefi mode.

I don't use encryption but see if this can help. No need to boot up livecd and chroot but you must still start the liveusb in uefi mode.

Thanks, I had actually just stumbled upon that thread and it looks promising. Is it clear at all if the simple first start has any likelihood of working (given encryption and separate boot partition)?

If you have a separate boot partition, then you have to use the complicated setup section. That's because the target grub has to be in boot and the grub 'root' has to be in the OS partition.

As for encryption, I have no idea as I don't use it. I'm not sure about the 'mapper' or how to point to it. This may be the point where I don't know how to get into it.

But since you use encryption, you may know how and if you can get into it, will be good if you can write a detailed (with getting mapping ...whatever) framework how you get tinto the installed OS. Maybe I can include it into the topic to help others with encryption.

Good luck.

You did not say you have a separate boot partition

If you mean sdb2, that is /boot/efi $esp partition and is not a separate boot partition.

I also noted partitions listed are sdb, not sda.
What is sda? sda should always be the 'booting' disk.
Change cables if so.

If sdb is an external drive (I think not), then grub-install command must have a "--removable" parameter otherwise you will have this problem again.

@jonathon, I've not mentioned this before but this discourse forum makes double dashes in apostrophes look like a single dash. So --removable in apostrophes look like "--removable" and each time I have to put that in <code> like this "--removable".
It's a hassle on the phone and I don't reply then when I could.

1 Like

Thanks for clarifying that /boot/efi $esp (sdb2 in my case) is not a separate boot partition. That should reduce some of the complexity.

sda is an additional internal hard drive (to the tune of 1TB) that doesn't hold any OSes. Flipping the SATA connections will flip their order? Will I need to change any software configurations? I'm also curious how that might affect my Windows installation.

Yes, if you have only 2 internal drives.
There's no need for any software configurations (caveat - unless you manually override to use device mapping rather than to use UUID's, and not sure if encryption mapping does that). So best you're sure first before doing it.

The trouble would be the bios. Normally, for most uefi bios, the boot entries will be regenerated. But that would apply to sda. That's why I suspect it did not regenerate in your case because your $esp is in sdb and the bios may not search for it there. But there is this matter of encryption, so...

Alright, I have some good news.

The encryption wasn't actually that much of a problem.

Here's how I handled it:
I used the graphical file manager to decrypt and mount the encrypted Manjaro partition. I would have used cryptsetup luksOpen but I had already mounted it graphically. The chosen path was something along the lines of /run/media/manjaro/(UUID of /dev/mapper/luks-[actual-encrypted-partition-uuid]). Tab autocomplete is a friend for long paths like these.

With that out of the way. I tried to use manjaro-chroot and sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Manjaro --recheck to install it. But this failed because /boot/efi doesn't look like an EFI partition.

Okay then. So after mounting the encrypted partition, you have to also mount the $esp. To accommodate the mounting shenanigans underway with our encrypted partition, this might look something like:
sudo mount /dev/sdb2 /run/media/manjaro/(uuid)/boot/efi
(Where /dev/sdb2 is of course the path to your own EFI system partition)

With this out of the way, you can go back into manjaro-chroot and try the same grub-install command mentioned above. This worked for me. After that, you'll want to run update-grub too.

It's worth noting that upon testing there is no entry for Windows in GRUB (which I don't mind, tbh), but is probably a relatively simple fix once you're back in Manjaro.

Marking as solved, thanks for the help @gohlip

1 Like

so if you need a /boot/efi you have to add in /etc/fstab

This Discourse typography feature is stupid for a tech forum. I've disabled it now.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by