X
Business

Hands-On: Linux UEFI multi-boot, my way

How I set up multi-boot for Linux (and Windows) on systems with UEFI firmware.
Written by J.A. Watson, Contributor

Let's start by clearly stating what this post is, and what it isn't. It is a description of how I set up multi-boot for Linux systems, sometimes including Windows, using the GRUB bootloader.

It is not intended to be a complete guide to Linux on UEFI firmware. There are certainly other ways to configure UEFI multi-boot - this is simply the way that I have found most useful and reliable to do it. OK? Good, here we go...

The UEFI boot process and disk layout

In order to boot a UEFI firmware system, there has to be an EFI boot partition on the disk. This is a relatively small (100MB or so is enough) FAT partition where various boot files are stored. Exactly what is there depends on the specific operating system. Some Linux distributions put nothing but a single GRUB executable image there; most also put a 'shim' executable which enables UEFI secure boot; and some also put a variety of other configuration and support files there. (Windows puts a lot more cruft in this partition, and various OEMs add even more on top of that.)

An EFI boot partition will always have a top-level directory named '/EFI' (no bonus points for originality in this area). Beneath that directory, each operating system or distribution will have its own sub-directory, with a name that (hopefully) indicates what distribution it is used for, and which is (hopefully) unique to that distribution.

For example, when you install openSuSE, it creates /EFI/opensuse/, when you install Fedora it creates /EFI/fedora, when you install Ubuntu it creates /EFI/ubuntu/, and when you install Linux Mint it creates /EFI/ubuntu/. Uh-oh, yes, you read that correctly - there is a name conflict between Ubuntu and Linux Mint. The second post in this series will have information on getting around this.

If you have Windows installed, there will also be /EFI/Boot/ and /EFI/Microsoft/, and depending on the OEM there may also be something like /EFI/ASUS/ or /EFI/HP/. Ugh. Yeah, it can get a bit crowded and a bit messy in there...

If you are creating a Linux-only system, this EFI partition is all you will need beyond the normal Linux partitions you choose to deal with (root, var, home, swap and such). If you install a UEFI-compatible Linux distribution from scratch on a blank disk, it will create the necessary partitions, including the EFI boot partition.

The only thing you will have to watch out for, if you want to create a multi-boot system, is to reduce the partition sizes because most Linux installers will use all of the free disk space available - which means the entire disk, if you are installing from scratch. I generally set the root partition to 8GB, and then size /home and/or /var according to what I am planning to use the specific installation for.

In the simplest case, if I am only testing a distribution to see if it installs and runs properly, and I don't intend to use it for anything significant, I don't even bother with var or home. I just set up EFI, root and swap. This takes second place on the 'completely lame and mindless disk partitioning' competition; if you want to win first prize, don't bother with a swap partition - or set up Windows with nothing but a 1TB C: partition.

If you are starting with a UEFI system which already has Windows installed, there will be quite a few more partitions already created. Once again, the details vary by OEM, but this ASUS system I was using right now is pretty typical, and in addition to the EFI partition (type FAT32) it has a 'Recovery' partition (type NTFS), a 'Microsoft Reserved' partition (type unknown), an 'OS' partition (type NTFS), an unlabeled partition (type NTFS), and a 'Restore' partition (type NTFS). In order to create your Linux multi-boot system, you will have to make room on the disk for the LInux root, var, home, whatever... but you can share the existing EFI boot partition with Windows if you want.

The most common way to make space is by shrinking the Windows 'C:' partition. Most of the Linux disk/partition management programs are able to shrink an NTFS partition, but I am rather paranoid about this, so I prefer to use the Windows disk management utility.

One other option, if you are very lucky, is that the Windows system might already have the disk partitioned into C: and D: drives, and the C: partition is not ridiculously large. In this case you can simply delete the D: partition and create your Linux installations in the resulting free space. Do I need to say here, make sure that there is nothing you want/need in D: before deleting it?

Installing Linux on UEFI systems

For purposes of this discussion, I am going to assume that UEFI Secure Boot is disabled. This is primarily because trying to manage a Secure/Multi-Boot setup is way more complicated than I want to get into here, and second because I consider UEFI Secure Boot to be the most massive overkill implementation of a ridiculously complex solution to a problem which is in fact vanishingly small in the real world. But that last part is just my opinion.

The first step in Linux UEFI installation is to determine whether the distribution you want to install supports UEFI firmware (duh). The release announcement or release notes generally mention this, but believe me, saying that they have UEFI support and actually being able to boot and install on a UEFI system are two very different things. The most reliable way that I know to find out is to just create the installation media (CD/DVD/USB) and try to boot it. If the Live system or Installer comes up, you're in business; if it refuses to boot, go find another distribution to try.

The next step is actually dealing with the necessary EFI disk partitioning. Any Linux distribution which supports UEFI installation will be able to read and analyze the disk partitioning, and will in some way handle the EFI boot partition requirement. Exactly how they do that, and what they tell you about it during the installation process, varies quite a lot between distributions. Here are a few examples:

  • openSuSE will find the EFI boot partition (or the first such partition if there is more than one on the disk), and will show you that it will be mounted as /boot/efi/ automatically.
  • Fedora will create a new FAT32 partition, even if there is already one, and set that to be mounted as /boot/efi/ automatically.
  • Ubuntu (and Mint) will find and use an existing EFI boot partition, but they will not tell or show you anything about it, and they will still display the old dialog that says GRUB will be installed on /dev/sda (or whatever disk). Well, I guess that is technically correct, it is going to be installed somewhere on that disk, but giving a bit of a hint that itis really going to the EFI boot partition, not to the old MBR location, would make for a lot less uncertainty and worry during installation.

Both openSuSE and Fedora will allow you to modify the layout, and either use an existing EFI boot partition you want, or create a new FAT partition to use for EFI boot. The new LMDE 2 (Betsy) RC release also tries to let you change the EFI partition, but then it insists that the 'boot' flag be set on that partition, which is pretty silly and might require you to go back to the expert partitioning utility and set that flag. But it's progress.

Partitioning for Multi-Boot

Other than getting the EFI boot partition right, you are pretty much on your own as far as the rest of the disk partitioning goes - as is usual with Linux installations. If your intent is to set up Linux multi-boot, you just have to make sure that you leave enough room for however many distributions you want to install. For 'trivial' installations, such as a I mentioned above, I have found that an 8GB partition is usually enough. There are a few very large distributions which require more (Makulu is an extreme case).

One of my netbooks has a 128GB SSD, and I am able to make one 'useful' Linux installation along with at least eight or nine 'trivial' installations on that disk. You can figure this out as you go - remember, installing Linux from scratch takes something like 15 minutes, so if you find you don't have enough space, just do it over.

One other thing about disk partitioning - sharing partitions between multiple distributions. It can be done, and it isn't even all that difficult. But there are a number of different ways to do it, depending on what you want to share, and who you want to share it with. The part which causes the most trouble is getting the permissions right.

One thing I would specifically recommend not to do is try to actually 'mount' the same /home partition for on multiple distributions. First, this is dangerous because if you reinstall one of the distributions which is mounting that home partition, it might get formatted during the installation. And if you are sharing files with another distribution, that can be... unfortunate.

Perhaps one of the simplest ways to share is to create an independent partition, which is not part of the initial installation of any of the distributions which will be sharing it. Then after each distribution is installed, add that partition to /etc/fstab with some new mount point (/shared or /data are common choices). You can then access that partition explicitly, or if you want it to be a bit easier or more transparent, you can add symlinks from your home directory to whatever directories you want in that partition.

If you want to share a partition with Windows, it will have to be a FAT format (duh). Then, again, mount it to some new directory (believe me, you really, really don't want a FAT partition for your /home), and either access it explicitly or symlink to it. Personally I would recommend against linking to it, because that can tend to 'hide' the fact that you are really working with a Windows/FAT partition, and that is something that I always want to be aware of.

Summary (and preview)

So far we have just gotten the basics out of the way, so we can all start the discussion in the next article from approximately the same point. To recap:

  • Booting UEFI systems requires an EFI partition on the disk.
  • One EFI partition can be shared by multiple operating systems.
  • Multiple EFI partitions can be created on the same system.
  • Loading multiple operating systems on the same disk requires making sufficient free space for each one (duh).
  • Sharing data between multiple operating systems is possible, but don't try to literally share the /home partition.

In the next post, I will look at the details of configuring GRUB for multi-boot, both for Linux-only installations and for mixed Linux/Windows installations.

I will not discuss attempting to use the Windows bootloader or boot manager to multi-boot with Linux, and I will not discuss multi-boot with UEFI Secure Boot. I will look at some unusual/difficult situations (such as Ubuntu and Linux Mint together), and I will look at adding non-UEFI Linux distributions alongside an existing UEFI-compatible Linux distribution.

Read more of my blog

Editorial standards