When you install openSUSE from DVD (not from live CD!) on a UEFI system, the preselected (and only advisable) bootmanager is elilo. The other choices, Grub and Lilo, don't support EFI boot, and Grub2 is not availalble in setup. The boot options are different and the question of writing Grub to MBR does NOT apply here. Furthermore, the live CD doesn't include UEFI setup. Thus to install openSUSE (such as 12.1) using a GUID partition table on a UEFI motherboard, you have to install from DVD (or net install).
Although it is not explicitly specified by the use of sudo or absolute path, commands in this tutorial must be run as root.
NOTICE
Some newer UEFI motherboards - such as those using the latest ASUS UEFI BIOS - do not have an option to set the BIOS mode between UEFI and Legacy (MBR) but switch automatically according to the selected boot device. If you boot an openSUSE live CD on such machines and proceed with the default installation, you will end up with a perfectly working Linux system that uses a traditional MBR partition scheme. If that's all you want, that's fine. But of course you won't benefit from GPT features, such as the ability to fully utilize hard disks larger than 2 TB.
When you call the BIOS setup to set the boot priority with a Linux install medium inserted that includes a UEFI setup procedure, you should see two boot devices instead of one. The ASUS UEFI BIOS (EZ MOde) shows two cd icons. You should drag and drop the one which has a UEFI stripe into the first position to run the UEFI setup. See picture below.
Which type of setup is running?
You can easily tell that you're running a legacy MBR setup by looking at the Installation Settings:
- Under Partitioning:
There is no mention of the EFI partition. - Under Booting:
The Boot Loader Type is Grub and the other settings are specific to Grub and MBR based systems.
Installing openSUSE on legacy BIOS with MBR partitioning is outside the scope of this article, which focuses on UEFI and GPT.
Installing and Booting with ELILO
Either set your BIOS to UEFI (if this option is available) or set the UEFI DVD as the first boot device. You should see:
Code:
ELILO Boot: ........Loading kernel linux... done
and the details of the boot process in console instead of the spash screen.
The suggested partitioning – as in the example below - should include a small vfat boot volume on /dev/sda1 for the EFI system partition (ESP), and usually swap, / and /home.
- Create boot volume /dev/sda1 (156.88MB) with vfat
- Create swap volume /dev/sda2 (2.01 GB)
- Create root volume /dev/sda3 (20.00 GB) with ext4
- Create volume /dev/sda4 (443.60 GB) for /home with ext4
You can accept this layout by clicking “Next”, modify it (“Edit Partition Setup”) or create a new layout (“Create Partition Setup”). But I do not recommend writing a partition layout from scratch here to avoid changing the type or offset of the EFI system partition.
To modify the suggested partioning so as to increase the size of the EFI system and root partition, add two extra partitions for further installations, and take the rest for /home, you can proceed as follows:
- Click on “Edit Partition Setup”.
- Using right click and the context menu, delete all partitions except the first one, the EFI boot partition. You may increase the size of this partition if you intend to use ELILO with many kernels.
- create a 2 GB swap partition
- create a 40 GB partiton for openSUSE, mount in “/”, format with ext4 and label SUS_ROOT.
- Optionally create 2 other 40 GB partitions, format with ext4 and do not mount. We'll use them to illustrate multibooting later.
- create a partition with the remaining space, mount in “/home”, format with ext4 and label HOME.
Now the installation settings look like this:
- under Partitioning:
- Create boot volume /dev/sda1 (509.88 MB) with vfat
- Create swap volume /dev/sda2 (2.00 GB)
- Create root volume /dev/sda3 (40.00 GB) with ext4
- Create volume /dev/sda4 (40.00 GB)
- Create volume /dev/sda5 (40.00 GB)
- Create volume /dev/sda6 (343.25 GB) for /home with ext4
- under Booting:
- Boot loader type: ELILO
- Create EFI Boot Manager Entry openSUSE 12.1
- Sections:+ linux (default)+ failsafe
“Create EFI Boot Manager Entry” means that a boot entry will be added in the firmware. It will appear in UEFI BIOS setup as a boot device to which you could assign any boot priority.
After the installation has completed, openSUSE will use GUID partitioning and boot in UEFI. On the installed system, fdisk displays a warning and a single partition that spans the entire size of the disk.
Code:
# fdisk -l
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cyl
inders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sda1 1 976773167 488386583+ ee GPT
This MBR with a single partition entry of type 0xee is called protective MBR.
Notice that it is different from the "hybrid" MBR created by Apple's Boot Camp on Mac hardware to dual or triple boot OS X with Windows and Linux, which can contain 3 other primary partitions usable by non GPT aware OSes (such as Windows XP).
In our example, parted displays 6 primary partitions:
Code:
# parted -l
Model: ATA WDC WD5000AAKX-0 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 535MB 534MB fat32 primary boot
2 535MB 2681MB 2146MB linux-swap(v1) primary
3 2681MB 45.6GB 43.0GB ext4 primary
4 45.6GB 88.6GB 43.0GB ext4 primary
5 88.6GB 132GB 43.0GB ext4 primary
6 132GB 500GB 369GB ext4 primary
This output clearly illustrates the difference between GUID and MBR partitioning. GUID partitioning doesn't have extended + logicals partitions, but up to 128 primary partitions.
Finally efibootmgr shows the boot entry that has been added in the EFI embedded bootmanager. It is the last entry since it is the only one we added, but it is the first to boot according to Bootorder.
Code:
# efibootmgr
BootCurrent: 0000Timeout: 3 secondsBootOrder: 0000,0003,0001,0002
Boot0000* openSUSE 12.1
Boot0001* Hard Drive
Boot0002* Removable Drive
Boot0003* CD/DVD Drive
Installing Grub2
Grub2 has many features, is able to boot other OSes besides Linux, and has become the default boot manager on most distros. It is not handled by YaST nor officially supported and has to be installed manually.
For the impatient...
I added a script called
updateGrub2 to the
updategrub package. It will install grub2-efi on UEFI systems and grub2 on BIOS systems and modify Grub's default to allow the use of a background image. It also builds the missing font which prevents Grub2 from entering graphic mode. To use this script - do I need to say at your own risk? - type the following commands in a root terminal:
Code:
# zypper ar http://download.opensuse.org/repositories/home:/please_try_again/openSUSE_12.1/ PTA
# zypper -n --gpg-auto-import-keys refresh -r PTA
# zypper -n in updategrub
# updateGrub2 -ni
Option “n” is straightforward. Don't use this option if you prefer the script to ask you for confirmation before installing packages or importing the GPG key (from my repo). In this case, just type:
* This script is intended primarily to install grub2-efi on UEFI systems.On BIOS systems, option “i” requires a partition device as argument (/dev/sdaX) or a disk (/dev/sda) to install the bootloader in MBR. Unless you know exactly what you are doing, do not use option “i” on BIOS systems. Use grub2-install instead!
Now the details...
You should install os-prober first. Although this package is not required for Grub2 to work and boot the current system, it makes it possible to scan for other Linux distros and automatically add their kernels to the menu. Without os-prober, Grub2 won't add boot entries for other distros. Version 1.47 is in the standard repo. Version 1.49 is available in factory and in my repo, but it is not the same package. I recommend installing the latest version.
Code:
# zypper ar http://download.opensuse.org/repositories/home:/please_try_again/openSUSE_12.1/ PTA
# zypper refresh -r PTA
# zypper in -r PTA os-prober
To install Grub2, apply the following steps:
- install the grub2-efi package:
Code:
# zypper in grub2-efi
Code:
# grub2-efi-install –bootloader-id=opensuse –no-floppy
BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0003,0001,0002
Boot0001* Hard Drive
Boot0002* Removable Drive
Boot0003* CD/DVD Drive
BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0000,0003,0001,0002
Boot0001* Hard Drive
Boot0002* Removable Drive
Boot0003* CD/DVD Drive
Boot0000* opensuse
Installation finished. No error reported.
If Grub2 installation removed the previous openSUSE boot entry from the EFI Boot Manager (I'm not sure why it does that), you can later add the elilo entry back using the efibootmgr command, as described at the end of the next section.
- Build the unicode.pf2 font.
This font is missing, causing the graphic mode to fail to start. You have to convert it from the gnu-unifont package or from the unifont Glyph bitmap (bdf).
Code:
# zypper in gnu-unifont
# grub2-mkfont -o /boot/grub2-efi/unicode.pf2 /usr/share/fonts/uni/unifont.pcf.gz
- Copy the background image you want to use to /boot/grub2-efi/ and rename it to splash.jpg, splash.png or splash.tga, according to the file type of the original. For example, to use one of openSUSE's default background images, you would type:
Code:
# cp /usr/share/backgrounds/upwind/morning-1280x1024.jpg /boot/grub2-efi/splash.jpg
- modify the file /etc/default/grub as shown below:
Code:
< #GRUB_GFXMODE=640x480---
> GRUB_GFXMODE=auto
> GRUB_BACKGROUND=/boot/grub2-efi/splash.jpg
> GRUB_GFXPAYLOAD_LINUX=keep
- Write the file /etc/grub.d/05_menu_color with the following content:
Code:
#!/bin/sh -e
set -e
prefix=/usr
exec_prefix=/usr
libdir=/usr/lib
. ${libdir}/grub/grub-mkconfig_lib
COLOR_NORMAL="black/black"
COLOR_HIGHLIGHT="white/black"
if [ "${GRUB_TERMINAL_OUTPUT}" = "gfxterm" ] ; then
cat <<EOF
set color_normal=${COLOR_NORMAL}
set color_highlight=${COLOR_HIGHLIGHT}
EOF
else
cat << EOF
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
EOF
fi
- * make this file executable:
Code:
chmod 755 /etc/grub.d/05_menu_color
Code:
# grub2-efi-mkconfig -o /boot/efi/efi/opensuse/grub.cfg
# grub2-efi-mkconfig -o /boot/grub2-efi/grub.cfg
At the next boot - if everything went well - you should see Grub2 menu in graphic mode - with the picture you chose as background image.
* If you used updateGrub2:
UpdateGrub2 will use one of the system default backgrounds until you specify the path of a jpeg, png or tga file in the variable grub_bg.
Troubleshooting
If Grub2 leaves you with the Grub prompt:
- Type ls at the prompt to list the devices known by Grub:
Code:
grub> ls
(hd0) (hd1) (hd2) (hd3) (hd4) (hd5) (hd6,gpt6) (hd6,gpt5) (hd6,gpt4) (hd6,gpt3) (hd6,gpt2) (hd6,gpt1)
- Load the menu from the one that seems to be the EFI system partition - we already know that it is the first partition (gpt1). But the HDD number reported here might not be the one you would logically expect, as in this example.
Code:
grub> configfile (hd6,gpt1)/efi/opensuse/grub.cfg
- If it doesn't work, try to boot the kernel directly
Code:
grub> set root=(hd6,gpt3)
grub> linux /boot/vmlinuz root=/dev/sda3 ro
grub> initrd /boot/initrd
grub> boot
Code:
# efibootmgr
BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0000,0004,0003,0001,0002
Boot0000* opensuse
Boot0001* Hard Drive
Boot0002* Removable Drive
Boot0003* CD/DVD Drive
Boot0004* openSUSE 12.1 (elilo)
# efibootmgr -b 4 -B
BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0000,0003,0001,0002
Boot0000* opensuse
Boot0001* Hard Drive
Boot0002* Removable Drive
Boot0003* CD/DVD Drive
# elilo -v
## Using '/boot/efi/efi/SuSE'...
## filter '/etc/elilo.conf' to '/boot/efi/efi/SuSE/elilo.conf.tmp'
> unlink( /boot/efi/efi/SuSE/elilo.conf)
> rename( /boot/efi/efi/SuSE/elilo.conf.tmp, /boot/efi/efi/SuSE/elilo.conf)
## remove old files from '/boot/efi/efi/SuSE'
> rm /boot/efi/efi/SuSE/initrd-3.1.0-1.2-desktop
> rm /boot/efi/efi/SuSE/vmlinuz-3.1.0-1.2-desktop
## copy new files to '/boot/efi/efi/SuSE'
> cp --preserve=timestamps /usr/lib64/efi/elilo.efi /boot/efi/efi/SuSE
> cp --preserve=timestamps /boot/grub2/core.img /boot/efi/efi/SuSE
> cp --preserve=timestamps /boot/vmlinuz-3.1.0-1.2-desktop /boot/efi/efi/SuSE
> cp --preserve=timestamps /boot/initrd-3.1.0-1.2-desktop /boot/efi/efi/SuSE
# efibootmgr --create --gpt --disk /dev/sda --part 1 --write-signature --label "openSUSE 12.1 (elilo)" --loader "\\efi\\SuSE\\elilo.efi"
BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0004,0000,0003,0001,0002
Boot0000* opensuse
Boot0001* Hard Drive
Boot0002* Removable Drive
Boot0003* CD/DVD Drive
Boot0004* openSUSE 12.1 (elilo)
Installing other Linux distros
Installing another OS including bootmanager in a UEFI based system is safer, because you don't have to worry about who's going to snap up the MBR. Each bootloader is installed in its own directoy in the ESP partition and shows up in UEFI BIOS as a bootable disk. You don't need to call the BIOS setup to reorder boot manager entries. efibootmgr serves this purpose (See man efibootmgr).
Most Linux distro installation DVDs include a UEFI and a BIOS setup and present two different boot entries in UEFI BIOS. If your BIOS switches to UEFI mode automatically, make sure you boot from the UEFI CD/DVD device - which doesn't have the boot priority in most cases. Booting a UEFI-unaware installation or live system would have the same effect as setting the BIOS to Legacy and would install the OS with a traditional MBR partition scheme.
Don't forget to select the EFI system partition in some other setups - of course do NOT format it - or the installation of the bootloader will fail. In Fedora's setup, mount the ESP in /boot/efi. In Ubuntu's setup, if an EFI boot partition is found, it will be mounted automatically.
When installing multiple distros, always choose the option that sounds the most complicated (but is not). Under openSUSE, it is "Create Partition Setup". In Ubuntu, the magic option is called "Something else" and in Fedora "Create Custom Layout". You don't need to delete an existing partition before installing Linux in it, unless you want to modify its size. Thus you can create partitions in advance from an installed Linux, Linux setup or live system, and select and format them while installing in expert mode.
You can share swap and /home with other Linux installations. Sharing the /home partition between Linux distros is absolutely not a problem when you understand the difference between the filesystem (the partition) mounted in /home and the base home directory - that you can call as you like and put anywhere, though most logically in a subdirectory of your /home partition. But this is not the topic of this article, where we just intend to demonstrate UEFI (multi)booting. To keep it simple for now, choose a different login name in each distro's setup, so that user settings and configuration files won't interfere.
Ubuntu
Ubuntu's EFI Grub2 works out of the box, installs its bootloader in /boot/efi/efi/ubuntu/ and adds other distros' kernel to its boot menu.
Fedora
Fedora 16 doesn't install with Grub2 on UEFI systems but still uses its own patched Legacy Grub, which is UEFI compatible. grub2-efi conflicts with grub-efi, so that the latter has to be uninstalled first. updateGrub2 can be used to install Fedora's Grub2 too.
Relevant links
Grub2 - UEFI systems (ArchWiki)
UEFI Booting (Ubuntu)
Boot Fedora 15 Using UEFI and GRUB2
Booting from GPT
Repairing GPT Disks
Unified Extensible Firmware Interface (Wikipedia)
EFI system partition (Windows and GPT FAQ)
Understanding Disk Partitions (Windows TechCenter)
Recommended UEFI-Based Disk-Partition Configurations(Windows TechCenter)
Compatible/Incompatible mainboards
Since not all mainboards appear to be compatible with Linux, I'm starting a compatibility list here. Please report working and non working mainboards.