Possible to migrate from grub.efi to rEFInd?

I shrunk my Windows partition, created an unencrypted “boot”
partition, and installed Manjaro and Pentoo on two other partitions
and chose the “encrypt” option.

As part of Manjaro’s install, a “grub.efi” file was created. I copied
that file to my unencrypted boot partition.

rEFInd finds it, and I’m able to launch the grub.efi from rEFInd, get
prompted for the LUKS password, then launch Manjaro from its grub
menu.

I want to cut out the middle man and just launch Manjaro straight from
rEFInd without going through grub.efi.

  1. Is this possible? I am figuring Manjaro’s install did all the work
    of setting up initramfs with mkinitcpio and the right encrypt hooks
    since it’s working through grub.efi. I assume it’s just a matter of
    getting the right kernel options/parameters into rEFInd.

  2. Do these options look correct?

The volume is correct. I was initially getting an error about not being able to find the loader. Once I got the volume correct, that error went away. The location of the initrd and cryptdevices should be correct. I copied them from the options of the working grub config. I got them by launching into the grub.efi and then pressing “e” to edit/view the parameters. So it’s the same cryptdevice and root that the working grub is using.

menuentry "Manjaro Custom" {
    icon     /EFI/refind/icons/os_arch.png
    volume   BOOT
    loader   /boot-manjaro/vmlinuz-5.10-x86_64
    initrd   "/boot-manjaro/intel-ucode.img /boot-manjaro/initramfs-5.10-x86_64.img"
    options  "cryptdevice=UUID=45a39ae3-123e-4e09-9167-ef88868fe90c:cryptroot root=UUID=16995cba-cabe-4dd1-8220-6b00d93df5fa rw add_efi_memmap"
}

Now, I see a few lines during boot that say it’s loading. The last line prints out the options that it’s loading with, the kernel parameters I guess, that it’s using that initrd and those options, and then it just freezes. I have to re-power the machine to get out of the freeze.

Thanks for any pointers in the right direction.

1 Like

I dropped rEFInd a while ago because it wasn’t giving me enough options and moved to grub, but, have you had a look at the Wiki Dual boot instractions yet? That uses rEFInd too!

:crossed_fingers:

If that doesn’t help, shout out again!

Install refind and manjaro-refind-installer - reboot to test - then you can remove grub

I have no need for the advanced features of grub and have chosen refind because I can have a nice splash matching my display manager.

2 Likes

First I’ve heard of manjaro-refind-installer. Thanks for pointing it out.

I’m looking at the code for it and I don’t think it will work for my use-case.

https://gitlab.manjaro.org/ste74/manjaro-refind-installer/-/blob/master/manjaro-refind-installer

I don’t see it anything about it decrypting a luks partition and mounting it as root.

1 Like

Looking at those Wiki Dual Boot instructions and I have everything described on that page working. I have the Manjaro/grubx64.efi file and rEFInd finds it and boots it and decrypts my luks partition and everything is good.

I don’t see any notes about what grubx64.efi does, what parameters it launches the linux kernel with, so that I can use those parameters to launch straight from rEFInd.

I don’t know about LUKS but I imagine you can achieve this by mounting the the efi partition at /boot - then assure you have the required modules in your your initramfs - by adding them to mkinitcpio.con and rebuild the images.

I did a quick search for you

1 Like

Thanks. By “…mounting the efi partition at /boot…” do you mean the partition with the grubx64.efi file? Because that already is mounted on an unencrypted partition at /boot, it gets found, and it boots. I’m trying to actually skip that grub efi and boot directly from refind. If that’s not the efi file you’re referencing, then which one are you talking about?

I’ll continue reading the links from that search and update this thread if I find anything that helps.

This is something I see in grubx64.efi when I view it in ghex:

cryptomount -u 45a39ae3123e4e099167ef88868fe90c
(cryptouuid/45a39ae3123e4e099167ef88868fe90c)/boot/grub

That’s the grub config that got baked into grubx64.efi. Maybe I could find the config file itself by looking at what the Manjaro install does. But this gives me a lot of info. I assume there’s a way to translate that grub config to something that works with rEFInd. I just can’t figure out what. I’m trying every combination of config parameters I can with custom rEFInd boot options.

I also see that Manjaro creates a /crypto_keyfile.bin when it performs its encryption during install. I assume Manjaro did basically what is described here, loading the crypto_keyfile.bin into initramfs using mkinitcpio: https://wiki.archlinux.org/title/dm-crypt/Device_encryption#With_a_keyfile_embedded_in_the_initramfs

Yes

I cannot figure out whether you are seasoned trying to complicate things or noob so instead of tangling myself I recommend Arch boot process - ArchWiki

Haha. Sometimes I can’t figure that out myself. I guess I’m a seasoned noob.

I just got it working so I’m going to post an update so that it gets cataloged in the internet’s archives for future seasoned noobs.

Notes:

  • Use mkrlconf (included with refind package) to detect your currently running linux kernel and generate a refind-linux.conf file. That file will have the options that you can copy to any manual rEFInd menuentry that you want to customize.
  • If you installed Manjaro to a single partition (didn’t create a separate /boot partition) and you encrypted the entire thing, then the initramfs that you see in /boot when you launch will include a crypto_keyfile.bin that can be used to unlock the luks partition. Don’t put that initramfs on an unencrypted drive! You’ll need to edit /etc/mkinitcpio.conf and remove that crypto_keyfile.bin from the FILES list and regenerate the initramfs with mkinitcpio.
  • Put your linux image (vmlinuz-5.10-x86_64) and your initramfs (initramfs…img) on an unencrypted drive. Those will get automatically found by rEFInd or you can manually point to them. You’ll probably also need a intel-ucode.img or amd-ucode.img as well.
  • Make sure your partition labels and file paths are correct. Since this is specific to your computer, there’s not much I can help with. How do you make sure something is correct if you don’t know what correct is? Some parts of rEFInd treat forward slashes and backward slashes equivalently. I think other parts of UEFI require backslashes. Try to work backwards from automatically-generated known-working configs to know what’s “correct”.

X-post with notes from the author of rEFInd: https://sourceforge.net/p/refind/discussion/general/thread/7a3e129b7f/

1 Like

I’ve marked this answer as the solution to your question as it is by far the best answer you’ll get.

However, if you disagree with my choice, please feel free to take any other answer as the solution to your question or even remove the solution altogether: You are in control! (If you disagree with my choice, just send me a personal message and explain why I shouldn’t have done this or :heart: or :+1: if you agree)

:innocent:
P.S. In the future, please don’t forget to come back and click the 3 dots below the answer to mark a solution like this below the answer that helped you most:
Solution
so that the next person that has the exact same problem you just had will benefit from your post as well as your question will now be in the “solved” status.

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