Two versions of linux and UEFI

In my previous post, I described how I handle two or more versions of linux on the same box, where legacy/MBR booting is used.  In this post, I say a little about what I do with UEFI.

My partitioning decisions are similar to what I described in the previous post.  So I’ll discuss only booting here.  This will be a relatively short post.

The problem

The main problem, if we are discussing opensuse versions, is that opensuse wants to install so that you use either the “opensuse” or “opensuse-secureboot” UEFI name for booting.  So two or more installs want to use the same name, and that can cause problems.  You will end up booting the most recently installed.

I should note that I have not completely settled on how best to deal with this problem.  My views have been changing.  So I’ll present my current opinions, though I might change those over time.

The Distributor solution

My first way of dealing with this was with the Distributor field.  In the boot setup screens of the installer, or in the Yast Bootloader screens, there is a field “Distributor”.  That defaults to containing “openSUSE” or “openSUSE 13.1” or similar.

I changed the string “openSUSE” to another name such as “Tumbleweed” or “betaSUSE”.  Then, when booting is installed, the UEFI name for booting comes from the first word of that “Distributor” field.  So the boot name might be “tumbleweed” or “tumbleweed-opensuse”.  This solution was suggested to me by Michael Chang, who maintains the booting setup for SUSE and openSUSE.

You can also set that “Distributor” in “/etc/default/grub”, where it is the value of the shell variable “GRUB_DISTRIBUTOR”.

This works pretty well.  I ran into two things that I don’t like:

  1. On my Dell UEFI box, the firmware deletes UEFI boot names if there are too many.  So a name is likely to disappear.
  2. On my ThinkServer box, the firmware seems to change the boot order by itself, so more entries causes more confusion.

My alternative solution

I have not completely switched from using the Distributor field.  But I am now experimenting with an alternative, and it seems to be working better.

I am leaving the Distributor field at its default.  And then I am creating a backup copy of the boot files for each install.

For example, if I have both opensuse 13.2 and Tumbleweed installed, then the UEFI boot files go in the directory “/boot/efi/EFI/opensuse”.  I create subdirectories:

# cd /boot/efi/EFI/opensuse
# mkdir 13.2 tumbleweed

and then I copy the files from the opensuse directory to the appropriate subdirectory. After installing 13.2, I copy the files to the 13.2 subdirectory. Then, if I later install Tumbleweed, that overwrites the file in the opensuse directory, but does not affect the copy that I made. So I now copy the changed files to the tumbleweed subdirectory.

Whichever system I want to handle the UEFI part of booting, I can copy the files from its subdirectory back to the parent “opensuse” directory.

I also add entries to the grub menu, so that no matter which is in charge of booting, I can boot the other system.  I do this with a few lines in “/etc/grub.d/40_custom”.

### Entry to boot opensuse_alt on sdc1
menuentry "configfile for linux on /dev/sdc1"  {
        set bootdir='hd3,gpt1'
        search --fs-uuid --set=bootdir cb44c7f1-143f-41ee-b24d-034a528ca6d2
        configfile (${bootdir})/boot/grub2/grub.cfg
}

This entry boots the Tumbleweed on my main desktop, where I mainly use 13.2.  I use similar lines on my Tumbleweed system, so that if it is in control of booting I can still boot 13.2.

Note that “set bootdir=’hd3,gpt1′” tell grub2-efi to use partition 1 on the third disk.  There’s a problem with multiple disks.  The order might change.  If I boot with a USB drive plugged in, then the USB drive might become disk2 or disk3, causing other disks to renumber.  That’s why there’s a “search” line there.  It finds the partition by UUID, and overrides the previous “set”.  I use the “blkid” command to find the UUID of the partition containing “/boot”.

There’s a downside to this scheme.  A system update might reinstall booting.  That is more likely to happen with Tumbleweed than with 13.2.  When that happens, I need to recopy the newly installed boot files to their correct subdirectory, and then perhaps copy the files from the subdirectory back to the parent if needed.

If I forget to copy, it is not a disaster.  The files are available elsewhere.  The file “grubx64.efi” is identical to “/boot/grub2/x86_64-efi/core.efi, and both “shim.efi” and “grub.efi” can be found in “/usr/lib64/efi”.

Advertisements

Tags:

About Neil Rickert

Mathematician and computer scientist who dabbles in cognitive science.

One response to “Two versions of linux and UEFI”

  1. eigenvision says :

    Thanks for the info. I like both solutions. I would have been satisfied with either one. But the first one seems simpler.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: