Ubuntu 16.04 UEFI

20170213 jean@huens.be

Since some hardware (acer revo one?) only supports GPT disk partitioning. It may be time to leave the MBR partitioning and switch to UEFI boot and GPT partitioning

Ubuntu EFI operations

Ubuntu 16.04 and later can handle UEFI boot.
You need

Ubuntu programs

The main program to manipulate EFI booting is efibootmgr. It can be used to verfy and adapt information in the EFI system partition.

Display EFI boot information:

# efibootmgr -v
BootCurrent: 0005
Timeout: 10 seconds
BootOrder: 0000,0001,0002,0003,0004,0005,0007
Boot0000* Diskette Drive BBS(Floppy,,0x0)
Boot0001* P0: ST3250312AS BBS(HD,,0x0)P0: ST3250312AS .
Boot0002* USB Storage Device BBS(USB,,0x0)
Boot0003* CD/DVD/CD-RW Drive BBS(CDROM,,0x0)P2: TSSTcorp CD-RW/DVD-ROM TS-.
Boot0004 Onboard NIC BBS(Network,,0x0)
Boot0005* ubuntu HD(1,GPT,081dd417-d80f-40a1-a36d-f3a76d0c0db0,0x800,0x100000)/File(\EFI\ubuntu\shimx64.efi)
To create a new boot entry (this example was used to create 0005 above)
# efibootmgr --create --disk /dev/sda --part 1 --label ubuntu --loader \\EFI\\ubuntu\\shimx64.efi

Ubuntu boot loaders

Boot loaders live on the \EFI\ubuntu EFI system partition (mounted on /boot/efi):

Solving EFI problems

When replacing/ changing disk you should make sure every disk uses GPT and has a EFI system disk.
Even then there may be no bootable config.

I do use a UEFI bootable USB stick with EFInd to verify what is on disk and boot it.
For general information see   http://www.rodsbooks.com/refind/
To find a USB flashdrive image file http://www.rodsbooks.com/refind/getting.html

Dell Optiplex 790

Dell optiplex 790, running ubuntu  16.04, installed from a USB stick.

Convert disk using Ubuntu

Based on http://askubuntu.com/questions/84501/how-can-i-change-convert-a-ubuntu-mbr-drive-to-a-gpt-and-make-ubuntu-boot-from.

resize and move disk partitions

The needed  space for a EFI (= fat 32) partition. Gparted or parted van be used:

BUT gparted refuses to work on mounted partitions, and since we use /dev/sda1 as / it will not work.

Workaround is to boot a  gparted-live (tested with gparted-live-0.26.1-1-amd64.iso).
Use of gparted is here.

  1. Hardware Dell Optiplex 790 with ubuntu 14.04 on MBR /dev/sda
  2. Bios setup : UEFI enabled
  3. Boot and enter PF12, you will see the USB stick as UEFI device, select, enter
  4. Flashy screen select gparted failsafe (or other). It takes some time te start.
  5. started gparted
    • /dev/sda1  freed 400Mb at begin (moving partition takes 15-20 min)
    • /dev/sda1 freed 2G at end
    • /dev/sda2 (swap) recreated 
    • created a new fat32 partition at start of disk. I did not find what to do to make this a EFI partition ?
  6. I did quit here since reinstalling ubuntu with a disk erase (next) is easier.

Reinstall Ubuntu

change Bios options

  1. Change in the bios => general => boot sequence => UEFI

    One can try to add boot options but the BIOS does not find a GPT disk with EFI...

    I did "load defaults" and got a greyed out boot list option with UEFI selected
    And a description of the default boot  including SATA USB ....
    Rebooted => BIOS is back to legacy
  2. Change in the bios => general => boot sequence => UEFI
    Save and reboot:
    "no bootable devices"
  3. Change in the bios => general => boot sequence =>
  4. ONE can select both Legacy and UEFI
    And then the USB installation stick is recognized.

Install ubuntu from USB

  1. The ubuntu desktop install detects that there is UEFI but the disk does contain MBR bootable software.You get a warning screen and I did select "continue with UEFI"
  2. selected erase disk.
    it warns:
    • partition #1 of SCSI1(0.0.0) as ESP
    • partition #2 of SCSI1(0.0.0) (sda) as ext4
    • partition #3 of SCSI1(0.0.0) (sda) asswap
  3. keyboard US with euro on 5
  4. installation goes on without problems
  5. removed usb stick and rebooted

Check installed system

After installing openssh-server.

  1. disk
    root@emilia:~# df -h
    Filesystem Size Used Avail Use% Mounted on
    udev 1.9G 0 1.9G 0% /dev
    tmpfs 384M 6.1M 377M 2% /run
    /dev/sda2 225G 4.7G 209G 3% /
    tmpfs 1.9G 212K 1.9G 1% /dev/shm
    tmpfs 5.0M 4.0K 5.0M 1% /run/lock
    tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
    /dev/sda1 511M 3.6M 508M 1% /boot/efi
    tmpfs 384M 92K 383M 1% /run/user/1000
    root@emilia:~# gdisk /dev/sda
    GPT fdisk (gdisk) version 1.0.1

    Partition table scan:
    MBR: protective
    BSD: not present
    APM: not present
    GPT: present

    Found valid GPT with protective MBR; using GPT.

    Command (? for help): p
    Disk /dev/sda: 488397168 sectors, 232.9 GiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): 8F41788B-9F6D-45C0-8CC3-90EB9A49A234
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 488397134
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 2349 sectors (1.1 MiB)

    Number Start (sector) End (sector) Size Code Name
    1 2048 1050623 512.0 MiB EF00 EFI System Partition
    2 1050624 480253951 228.5 GiB 8300
    3 480253952 488396799 3.9 GiB 8200

    Command (? for help): i
    Partition number (1-3): 1
    Partition GUID code: C12A7328-F81F-11D2-BA4B-00A0C93EC93B (EFI System)
    Partition unique GUID: 081DD417-D80F-40A1-A36D-F3A76D0C0DB0
    First sector: 2048 (at 1024.0 KiB)
    Last sector: 1050623 (at 513.0 MiB)
    Partition size: 1048576 sectors (512.0 MiB)
    Attribute flags: 0000000000000000
    Partition name: 'EFI System Partition'

    Command (? for help): i
    Partition number (1-3): 2
    Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
    Partition unique GUID: 6D5B45BF-A768-4460-92AF-3BF2BFA7DDA9
    First sector: 1050624 (at 513.0 MiB)
    Last sector: 480253951 (at 229.0 GiB)
    Partition size: 479203328 sectors (228.5 GiB)
    Attribute flags: 0000000000000000
    Partition name: ''

    Command (? for help): i 3
    Partition number (1-3): 3
    Partition GUID code: 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F (Linux swap)
    Partition unique GUID: DE30F507-E371-4727-BC49-389176174C7B
    First sector: 480253952 (at 229.0 GiB)
    Last sector: 488396799 (at 232.9 GiB)
    Partition size: 8142848 sectors (3.9 GiB)
    Attribute flags: 0000000000000000
    Partition name: ''
  2. EFI
    root@emilia:~# efibootmgr -v
    BootCurrent: 0006
    Timeout: 1 seconds
    BootOrder: 0000,0001,0002,0003,0004,0006
    Boot0000* Diskette Drive BBS(Floppy,,0x0)
    Boot0001* P0: ST3250312AS BBS(HD,,0x0)P0: ST3250312AS .
    Boot0002* USB Storage Device BBS(USB,,0x0)
    Boot0003* CD/DVD/CD-RW Drive BBS(CDROM,,0x0)
    Boot0004 Onboard NIC BBS(Network,,0x0)
    Boot0006* ubuntu HD(1,GPT,081dd417-d80f-40a1-a36d-f3a76d0c0db0,0x800,0x100000)/File(\EFI\ubuntu\shimx64.efi)
    root@emilia:~#
    Boot 0-4 seem to be legacy boot devices (4 NIC is not enabled in BIOS)
    Boot 6 is on EFI partition.

  3. EFI partition
    root@emilia:~# cd /boot/efi
    root@emilia:/boot/efi# ls -lR EFI
    EFI:
    total 4
    drwx------ 3 root root 4096 Jun 20 13:33 ubuntu

    EFI/ubuntu:
    total 3620
    drwx------ 2 root root 4096 Jun 20 13:31 fw
    -rwx------ 1 root root 64352 Jun 20 13:31 fwupx64.efi
    -rwx------ 1 root root 126 Jun 20 13:33 grub.cfg
    -rwx------ 1 root root 1067896 Jun 20 13:33 grubx64.efi
    -rwx------ 1 root root 1271672 Jun 20 13:33 MokManager.efi
    -rwx------ 1 root root 1289424 Jun 20 13:33 shimx64.efi

    EFI/ubuntu/fw:
    total 0

Test UEFI boot

Reboot and change bios to UEFI
The bios VIEW option now shows:

Boot Option Name:
ubuntu
File System List:
HD(1,GPT,081dd417-d80f-40a1-a36d-f3a76d0c0db0)
File Name:
\EFI\ubuntu\shimx64.efi

Apply and exit
Reboot (boots ubuntu)

Test UEFI booted ubuntu

Every thing is as in the first test.
efibootmgr still shows the legacy devices 0-4 ?

Added another boot entry:

root@emilia:~# efibootmgr -b 5 -c -d /dev/sda1 -L "ubuntu grub" -l "\EFI\ubuntu\grubx64.efi"
BootCurrent: 0006
Timeout: 1 seconds
BootOrder: 0005,0000,0001,0002,0003,0004,0006
Boot0000* Diskette Drive
Boot0001* P0: ST3250312AS
Boot0002* USB Storage Device
Boot0003* CD/DVD/CD-RW Drive
Boot0004 Onboard NIC
Boot0006* ubuntu
Boot0005* ubuntu grub
root@emilia:~# root@emilia:~# efibootmgr -t 10
BootCurrent: 0006
Timeout: 10 seconds
BootOrder: 0005,0000,0001,0002,0003,0004,0006
Boot0000* Diskette Drive
Boot0001* P0: ST3250312AS
Boot0002* USB Storage Device
Boot0003* CD/DVD/CD-RW Drive
Boot0004 Onboard NIC
Boot0005* ubuntu grub
Boot0006* ubuntu
root@emilia:~# efibootmgr -v
BootCurrent: 0006
Timeout: 10 seconds
BootOrder: 0005,0000,0001,0002,0003,0004,0006
Boot0000* Diskette Drive BBS(Floppy,,0x0)
Boot0001* P0: ST3250312AS BBS(HD,,0x0)P0: ST3250312AS .
Boot0002* USB Storage Device BBS(USB,,0x0)
Boot0003* CD/DVD/CD-RW Drive BBS(CDROM,,0x0)
Boot0004 Onboard NIC BBS(Network,,0x0)
Boot0005* ubuntu grub HD(1,GPT,081dd417-d80f-40a1-a36d-f3a76d0c0db0,0x800,0x100000)/File(\EFI\ubuntu\grubx64.efi)
Boot0006* ubuntu HD(1,GPT,081dd417-d80f-40a1-a36d-f3a76d0c0db0,0x800,0x100000)/File(\EFI\ubuntu\shimx64.efi)
Rebooted

Boots into Ubuntu, nothing seen from timeout of 10 seconds, nothing seen from grubx64.efi.
Puzzled, but it works

Dell Optiplex 7020

Dell Optiplex 7020 running ubuntu 14.04

Change BIOS options

After these changes and MBR formated disk is not bootable, but using PF12 you will get some devices, among them:
Both PXE boots did fail and only a ubuntu16.04_amd USB stick was usable.

Install ubuntu from USB

Instalation done without problems; system reboots without problem.

Check installed system

The system was booted using EFI and the efibootmgr ouput looks OK:
root@dellzebub2:/root# efibootmgr -v
BootCurrent: 0001
Timeout: 2 seconds
BootOrder: 0001,0012,0013
Boot0000* Windows Boot Manager HD(1,GPT,16fcb1e6-9e58-4aff-b2c4-104e15c46d9f,0x800,0xfa000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)\
WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}\
...d................
Boot0001* ubuntu HD(1,GPT,e84c57da-10a0-4f40-9ddc-4ba50686319b,0x800,0x100000)/File(\EFI\ubuntu\shimx64.efi)
Boot0012* Onboard NIC(IPV4) PciRoot(0x0)/Pci(0x19,0x0)/MAC(3417ebaab7b0,0)/IPv4(0.0.0.0:0<->0.0.0.0:0,0,0)AMBO
Boot0013* Onboard NIC(IPV6) PciRoot(0x0)/Pci(0x19,0x0)/MAC(3417ebaab7b0,0)/IPv6([::]:<->[::]:,0,0)AMBO

Then we did  install fwts   (ubuntu FirmWareTeSt) to test/view UEFI variables. The installation requests a password
as shown in
  1. The install script.
  2. and this screenshot
    fwts installation needs a password
  3. After the installation fwts can be used to dump UEFI variables and related stuff.
    Results.log contains some examples (long).

  4. At the next reboot you will get a blue screen (not the windows one ) and MOKmanager will show some selections. If you choose to enable SecureBoot (I did) You will need the password given at the previous step.
    It will ask for password char X , to answer you need to type one char followed by a RETURN

Test Disk exchanges

A disk with  GPT partitioning contains a "backup" MBR at the start.
This did give me hope that a GPT partitioned disk could be used on a machine with only MBR firmaware=BIOS.

Test machines :

  1. Dell optiplex 790, running ubuntu  16.04, BIOS with EFI, Disk with GPT
  2. Dell optiplex 755, running ubuntu 16.04. BIOS with MBR, Disk with MBR

Dell 790 with MBR disk

Started with PF12 :
No boot devices found !

When BIOS is switched to Legacy (was UEFI), the Disk can be used to boot.
(PF12 shows boot devices and UEFI, but UEFI cannot be used and freeze the system.


Dell 755 with GPT disk

Started with PF12 :

Shows onboard SATA disk