11

My reason for using LVM is that I reinstall, upgrade and generally mess around with my OS installs so much that I have found that LVM gives me fantastic flexibility in moving, expanding, cloning and backing up my OS partitions at my leasure without the risks assosiated with other partitioning methods. It does, however, make multibooting your OSes a little complicated and unpredictable at times, especially on newer hardware, where the process gains another level of complexity.

What I'm talking about are the new UEFI (as opposed to BIOS) motherboards, which allow you use the full potential of, and to boot from, 3TB+ hard drives (when formatted in GPT as opposed to MBR). Things can get incredibly complicated and messed up because each time that you install a new OS on your machine, it will overwrite the EFI bootloader (.efi) files of your previous install and you will end up with a series of broken entries in your EFI "BIOS" bootlist and a load of pretty much redundant grub bootloaders scattered about your partitions. This offends me on so many levels, not least of which aesthetically.

3 Answers 3

8

NOTE: This was the OP's answer. I moved it down here as CW so it didn't get closed. If a mod sees this, please reparent ownership to the OP as a self-answer.

Below, I will detail how to get this all to work somewhat harmoniously and to sort the mess out, to some extent.

Part One: Installing.

Please note that if you are going to have Windows 7 (or 8?) installed on your machine, you'll probably have to install it first, preferably on it's own hard drive, and you won't be able to put it in your logical volume group. This is because the Windows 7 GPT/EFI installer is very basic and won't let you do the sorts of things you'll be doing here. After the windows install, you can resize and repartition, adding the partitions you need for a multi-boot install. The EFI system partition which Windows creates can always be re-used for the Linux installs, using a variation of the method detailed below.

Firstly, it helps to wipe your intended system drive using gparted (or the like) and initialise it as a GPT disk, before doing anything else. If you're a bit nervous about using a non-graphical partitioner to set up your disk from scratch, then this is definitely worthwhile and is easly done from a standard live Desktop USB or CD installer. Don't do it in Windows. I'm not sure that this is absolutely necessary, but it's what I did. You can also carry out the basic partitioning for the non-LVM partitions at this stage too, as it wouldn't hurt and gives you a framework for the installation proper.

Now burn your installation CDs/USBs. If you are using the Ubuntu Alternate Desktop ISO (recommended), then you must burn this onto a CD, as it simply will not work off of a USB stick. When used for an LVM install, it stops with a critical error when it tries to start loading and installing software with aptitude/tasksel, so use a CD if you know what's good for you!

  • Ubuntu Server installs absolutely fine from a USB in all cases (AFAIK), but I find that if I want to build an Ubuntu/Mythbuntu desktop system on top of Server, it introduces all sorts of unintended quirks which then need time spent sorting out. So stick with Desktop, if that's what you're after.

  • Quantal (12.10) has LVM as an option in the graphical installer (which is great!) and so the Alternate ISO has been done away with. However, I found the manual partitioning interface inflexible, lacking in LVM options, and simply did not work for multi-boot. This may have been due to the USB problem mentioned earlier, but to be honest, I had so many problems with a Quantal system I tried, that I gave up pretty quickly and went back to Precise (12.04.1).

  • The other main option is to use the Net-boot installer, which I don't have any real experience of (except on my Raspberry Pi), but I believe that there are mini ISOs with text-based and GUI (GTK) installers, which can be burnt and booted from. These pull most of the installation files directly from a repository and are highly customisable.

Next, you should boot up your system from CD or USB using it's UEFI boot entry from within "BIOS" or the boot menu (usually one of [F8] - [F12] on the keyboard).

I'll leave it up to you to get through preliminaries of the installation process, but once you get to the partitioning part, choose Manual Partitioning and then create (or modify if you have already created some of them) these partitions:

  1. A single partition of size 200MB, FAT32, EFI System Partition, named/labelled "EFI", Boot-able, Format.

  2. Several partitions: Sized 256MB, EXT2, Boot-able, Format;

    • You should name/label them each for the OS they will represent, i.e. "OS_01_Boot"..."OS_03_Boot"...etc.

    • Start by mounting the first of these as "/boot" and all the others as "do not use".

    • Create one partition for each OS that you intend to install.

  3. One partition, taking up the rest of the space of the drive, as a volume for LVM.

    • Configure LVM on the volume that you have just partitioned, creating a volume group for all of your OSes, giving it a suitable name and plenty of space for all of them. I'd recommend factoring in at least 40GB for each, depending on the type of installation you're planning for each one.
  4. Create one logical volume the same size as the physical RAM in your system i.e. 8GB, name it "Swap", use as swap, format.

  5. Create one logical volume for each of the OSes within the volume group, sizing them as suggested above and giving them each a name i.e. "Ubuntu_12.04" etc.

    • Format each to EXT4, naming/labelling the partitions as you go.

    • Start by mounting the first of these as "/" (root) and all the others as "do not use".

That's it! Now you've got a swap, "/boot" and "/" (root) partition for your system and spares for your subsequent installations. You can now commit the changes to the partition table and continue with the rest of the installation.

When it comes to installing your next OS, just make sure that you mount the next "/boot" and "/" (root) partition, respectively. Please make sure that you mark all the others as "do not use", including the ones that you used last time.

Part Two: Backing up UEFI boot files.

As soon as you have booted into your new OS, you must backup your UEFI boot-loader for later use and to make sure that it is not overwritten in the next install. This can be found in "/boot/efi/EFI", within its own folder, usually named "ubuntu". The file in question will have a name similar to "grubx64.efi", depending on the architecture of your PC; so "/boot/efi/EFI/ubuntu/grubx64.efi", for my machine.

In my case, to back it up I copied it via the console, like so:

sudo cp -r /boot/efi/EFI/ubuntu /boot/efi/EFI/Ubuntu_12.04.1

It would definitely be worthwhile making a further copy in your home folder or somewhere else safe, just in case:

cp -r /boot/efi/EFI/ubuntu /home/user/Ubuntu_12.04.1

Once this is done, you can safely install your next operating system (following the advice above), which will most likely overwrite the original file and folder and also make itself the default UEFI boot entry in "BIOS". Repeat the process again and as many times as is necessary, giving each folder a different, but representative name:

sudo cp -r /boot/efi/EFI/ubuntu /boot/efi/EFI/Server_12.04.1
cp -r /boot/efi/EFI/ubuntu /home/user/Server_12.04.1

Part Three: Modifying the UEFI entries in your UEFI "BIOS".

From the terminal, enter:

sudo efibootmgr

You should get some output like this:

BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0000,0006,0007,0005
Boot0000* ubuntu
Boot0005* Hard Drive 
Boot0006* UEFI: MATSHITABD-MLT UJ240AS
Boot0007* CD/DVD Drive

It's pretty self-explanatory, really. It should mirror what you see in your BIOS boot list.

Have a read of:

man efibootmgr

to see what the commands do, then modify the example commands below in order to add and remove boot entries.

First, remove that "Boot0000* ubuntu" line with:

sudo efibootmgr -b 0000 -B

Output:

BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0006,0007,0005
Boot0005* Hard Drive 
Boot0006* UEFI: MATSHITABD-MLT UJ240AS
Boot0007* CD/DVD Drive

Then we'll add some entries for three operating systems.

OS #1:

sudo efibootmgr -c -g -d /dev/sda -p 1 -w -L "Ubuntu 12.04.1" -l \\EFI\\Ubuntu_12.04.1\\grubx64.efi

Output:

BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0000,0006,0007,0005
Boot0005* Hard Drive 
Boot0006* UEFI: MATSHITABD-MLT UJ240AS
Boot0007* CD/DVD Drive 
Boot0000* Ubuntu 12.04.1

OS #2:

sudo efibootmgr -c -g -d /dev/sda -p 1 -w -L "Ubuntu Server 12.04.1" -l \\EFI\\Server_12.04.1\\grubx64.efi

Output:

BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0001,0000,0006,0007,0005
Boot0000* Ubuntu 12.04.1
Boot0005* Hard Drive 
Boot0006* UEFI: MATSHITABD-MLT UJ240AS
Boot0007* CD/DVD Drive 
Boot0001* Ubuntu Server 12.04.1

OS #3:

sudo efibootmgr -c -g -d /dev/sda -p 1 -w -L "Mythbuntu 12.04.1" -l \\EFI\\Mythbuntu_12.04.1\\grubx64.efi

Output:

BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0002,0001,0000,0006,0007,0005
Boot0000* Ubuntu 12.04.1
Boot0001* Ubuntu Server 12.04.1
Boot0005* Hard Drive 
Boot0006* UEFI: MATSHITABD-MLT UJ240AS
Boot0007* CD/DVD Drive 
Boot0002* Mythbuntu 12.04.1

To change the boot order:

sudo efibootmgr -o 0000,0001,0002,0006,0007,0005

Output:

BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0000,0001,0002,0006,0007,0005
Boot0000* Ubuntu 12.04.1
Boot0001* Ubuntu Server 12.04.1
Boot0002* Mythbuntu 12.04.1
Boot0005* Hard Drive 
Boot0006* UEFI: MATSHITABD-MLT UJ240AS
Boot0007* CD/DVD Drive

Done!

There's some pretty strange syntax involved, especially around the file paths, but it's pretty straightforward if you have a good guide (which I hope this is).

Thanks for reading. :)

https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#efibootmgr

1
  • Thanks, AbrahamVanHelpsing. I was trying to self-answer, but I'm too much a noob here, I think. I'll try to tidy this up later; the formatting's terrible! It's 1:30am here, so I'll give up for the moment!
    – Rich.T.
    Dec 9, 2012 at 1:29
2

Any OS installer that erases previous or other OSes' EFI boot loader files is badly broken. Ubuntu had this problem in the past, but it was supposedly fixed with version 12.04. (I say "supposedly" because I've seen a couple of reports of problems along these lines that make me think the bug may still exist for a minority of systems.) That said, backing up your EFI System Partition (ESP) before a new OS installation is a useful insurance policy. A file-level backup should be sufficient, since EFI doesn't rely on code squirrelled away in boot sectors. (It does rely on the partition's GUID, though, so if something deletes the ESP and creates a new one, the EFI's boot loader entries might stop working.)

Broadly speaking, for your type of configuration, I recommend creating an ESP, as many /boot partitions as you think you might need, and a big LVM partition. If you expect to install Linux distributions alongside other OSes, make that three or four LVM partitions of varying size that you then merge into one volume group; that way, you can pull one partition (logical volume) out of your volume group and dedicate it to a non-Linux OS. The non-LVM /boot partitions give you the option to use boot loaders that don't understand LVM (that is, non-GRUB2 boot loaders).

When you install a new OS, it will probably install its own boot loader as the default. In a complex setup like yours, this is probably the wrong thing to do most of the time. To correct, it helps to have a USB flash drive or CD-R with your preferred boot loader installed on it. Something that can auto-detect other boot loaders, such as rEFIt or its derivative rEFInd, is likely to work well in this context. (Note that the binaries on the rEFIt Web site work only on Macs; rEFInd is a safer choice for UEFI-based PCs.) Alternatively or in addition, a way to launch an EFI shell can be helpful, since you can move files around, adjust boot options, and fix a number of problems from an EFI shell. Many EFI boot loaders and boot managers can launch EFI shells. (See this Arch Linux wiki for download links to some EFI shells.) Both the rEFIt and rEFInd CD images include EFI shells.

0
2

You don't have to use EFI to boot a 2+TB disk; you just have to use GPT and create a 1 MB bios_grub partition below the 2Tb mark. If you find EFI to be problematic this may work better for you.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .