REFInd Dual Boot

From Tech Tangents
Jump to navigation Jump to search

So you wanna dual boot with rEFInd? It’s actually really easy to set up now that EFI support has been mostly fully adopted now. But there are a few sticking points and getting some background knowledge on how EFI works can help you work through those. I’m dividing this guide up into sections so you can can work through the specific steps you need. And if you’re coming back to this for the commands the TL;DR is right there at the top.

TL;DR

# Linux
sudo apt install refind

# Windows Powershell (Admin)
bcdedit.exe /set "{bootmgr}" path \EFI\refind\refind_x64.efi
bcdedit.exe /set "{bootmgr}" description "rEFInd - WinSet"

EFI Background

I initially didn’t like the change over to EFI. As a linux user GRUB2 solved almost all the problems you could have with multibooting operating systems. And EFI didn’t have great linux support initially either. But it’s a very different situation now and EFI has actually become one of my favourite changes to the PC in recent years.

The biggest change that EFI made was making it more obvious how the system boot process works. Rather than having a mysterious Master Boot Record (MBR), the simultaneously introduce GUID Partition Table(GPT) make the lowest level boot files normal files on the storage drive. This is the EFI partition. On it you will likely find multiple *.efi files. These are more or less directly executed by the system and usually act as a boot shim to start an operating system.

From a configuration and administration standpoint EFI allows you to tell your computer to boot specific *.efi files with the UEFI configuration. Typically by setting a single file to be the default to silently boot. Manually dual booting isn’t tremendously hard if your computer gives you a nice boot option menu that lets you pick a file. But many computers don’t and setting up EFI dual boot using conventional tools like GRUB2 can be very difficult.

rEFInd

rEFInd steps in to solve the problems caused by having a single EFI file be the default. It has its own EFI file that becomes the new default, but rather than being a bootstrap to load an operating system it is a full program with sole purpose of allowing you to choose a different EFI file to run. For a typical dual boot setup, the EFI files you’ll care the most about will be the Windows Boot Manager and either GRUB or the kernel for Linux. This allows you much greater control over which EFI files are run on startup and as a consequence, which OS you boot.

Installs

If you are setting up your system from scratch then you may be wondering which operating system you should install first. With MBR this was a huge pain and Windows could be really picky about how it was set up. EFI isn’t as bad as that, but I still tend to follow some of the conventions you would use then. So I would recommend installing Windows first. Windows used to need to be near the boot area of the drive (I don’t think it does anymore but old habits die hard) so I like to make it the first major partition on the drive. Additionally installing Linux afterwards will likely change your default EFI boot choice to it which can make the rest of the steps easier.

The current Windows 10 installer will automatically create partitions for you on a blank/unformated drive. You can go with it’s automatic settings or change them to suit your config. On a system I recently set up, I had Windows create the partitions, then deleted the install partition and create two partitions of half the size so I could install Linux on the same drive. After creating the partitions you can go through the rest of the installer normally.

After getting Windows installed you can move on to installing Linux. There’s no real rush to get it done sooner, so if you want to let Windows update first you can let it. I will always recommend Ubuntu as a Linux distro. It is easy to use and has the most support for 3rd party applications. You can go through the normal install process but choose a custom drive setup. If you’re using a single drive you can select the separate partition after Windows. Or a another drive will be just fine. But be sure to set the boot installer to the drive you installed Windows on and will want to install rEFInd on and have your boot configuration. Once you have those set, you can go through the rest of the Linux install like normal.

Linux rEFInd Install

Windows doesn’t like to give you access to the EFI partition because it can be used to run code at a very low level when the system boots. Linux will allow you to access it with root permissions and is therefore the much easier OS to install rEFInd from. If you installed Windows after Linux you will have to go into your motherboard settings and choose your Linux install as the default boot option. Note that there is a difference between the default boot drive, and the default EFI boot option. So you’ll want to make sure you have both set to match your Linux install.

Once you are booted into Linux you can install rEFInd. On modern Ubuntu versions it’s as easy as sudo apt install refind . That will take care of writing the rEFInd files to the EFI partition and setting it up as the default boot option.

If you are going to be manually installing rEFInd (which isn’t really better or different, so the apt method is fine) then you’ll want to grab it from the site and extract and put the files in /boot/efi which should be the mount point for your EFI partition. Then you will need to do two more things.

First you need to add rEFInd to the EFI configuration so it knows the file is there. You can do this with efibootmgr with the following command as long as you installed rEFInd in the matching path

efibootmgr -c -l \EFI\refind\refind_x64.efi -L rEFInd

I’ll mention the -L parameter quickly because we’re going to be doing something similar again in the next section. This is the name of the EFI boot file that you will see in your motherboard’s UEFI choices. You can technically set that to anything you want, but I would recommend leaving it alone.

After that you need to set rEFInd as the default boot choice. You could do this from your motherboard’s configuration. But you can also use efibootmgr to do this. If you just run it without any parameters you’ll see a list similar to this:

$ efibootmgr
BootCurrent: 0004
Timeout: 1 seconds
BootOrder: 0004,0002,0022,0000,0001,0023,001E,000F,0020,0006
Boot0000* Fedora
Boot0001* ubuntu
Boot0002* Windows Boot Manager
Boot0004* rEFInd Boot Manager
Boot0006* UEFI: Built-in EFI Shell 
Boot000F* Hard Drive 
Boot001E* Unknown Device 
Boot0020* CD/DVD Drive 
Boot0022* UEFI OS
Boot0023* ubuntu

We’re going to change the BootOrder line. In this case we can see the rEFInd label next too Boot004. We can set it as the default with efibootmgr -o 4 . The EFI settings actually specify a boot priority more than a “default” but in practice you will almost always boot the first option. If you want to specify fallback boot files like Linux or Windows you can by adding more numbers specified to the command like this: efibootmgr -o 4,1,2

Windows vs. Linux (or, Everyone Else)

After you have everything setup up you will be able to easily switch between OS’es to your hearts content, unless Windows gets a funny look in its eye. I’m not sure what is the trigger for the process. But sometimes, Windows feels compelled to reset the EFI boot priority to favor it’s prefered EFI file, which is it’s own boot manager of course. If that happens you can go back into your motherboard settings and change it back to rEFInd. But in practice I’ve found it can happen almost every boot of Windows and it is a source of frustration with this process.

But, at the time I’m writing this(since Windows is now a live service product with rolling updates who knows if it will change in the future) you can change the EFI file Windows will reset the priory to. This process is documented on the Windows Hardware Developer page for bcdedit. You can change the boot file Windows will set to rEFInd. Windows will also change the name of the boot entry at the same time which is why I brought it up before. You’ll want to change that at the same time or you can run into the confusing situation where Windows will change the name for rEFInd to something like “Windows Boot Manager”. You can change both the EFI boot file path and the name with the following two commands:

bcdedit.exe /set "{bootmgr}" path \EFI\refind\refind_x64.efi
bcdedit.exe /set "{bootmgr}" description "rEFInd"

Exceptions and Troubleshooting

If you followed along with the guide up until now you will likely be done at this point. But I wanted to put out a few bits of other information that I’ve run into.

Bootx64.efi

I’ve seen some systems not respond well to *.efi files that aren’t explicitly named “Bootx64.efi”. This isn’t very common, but if you install rEFInd and it won’t boot or still won’t show up after adding it to the EFI config with efibootmgr you may want to try renaming the “refind_x64.efi” file to “Bootx64.efi” and update the boot path settings again to see if that works.

32 bit EFI

I have at least one system that has a 64 bit CPU but weirdly the UEFI firmware will only launch 32 bit EFI files. If you run into this you should set the EFI file paths to point to the refind_ia32.efi file instead of refind_x64.efi. This should be a usable 32 bit version of rEFInd for this systems.

Portable rEFInd

I have put rEFInd on a live Linux boot drive before, it is definitely possible but wasn’t the easiest thing. I believe this is when I found out about the “Bootx64.efi” file name problem. You may only be able to boot *.efi files named that on external/portable drives. I did the process a while ago and don’t remember if there were any other significant issues but it was an interesting project. I don’t think it was really worth the effort in the end though.

Conclusion

You can explore the rEFInd files from here and even customize it to get a fun or cool look on your system at boot. But for just a basic install, that’s it! You can do a similar configuration with GRUB , but I’ve never found that to work very well in the long run.

I’m going to be updating this article as I come across other information about this process as I plan to use it as a resource myself. If you have any questions about this, get in touch with me and I’ll see if it’s something I can add to this to make it better for more people.al tools like GRUB2 can be very difficult.