Efi boot linux

From CECS wiki
Jump to navigation Jump to search

Between buggy EFI firmware, buggy grub, and other issues, it seems to be very hard to dual boot linux on an EFI system. Here is a list of hints...

Installing linux[edit]

It seems to be important to EFI boot linux for the install if you want the installed copy to boot efi (why?). Suggest making a fresh USB stick with an EFI bootable distribution. Do NOT install an MBR boot sector on the usb stick; EFI doesn't need a boot sector.

Note that linux efi tools mount the efi boot partition on /boot/efi but if you install linux as MBR this is not set up, and may need to be done manually for some tools to work correctly.

Convert ubuntu MBR into efi[edit]

  1. convert MBR to gpt if necessary
  2. create EFI boot partition (ID EF00)
  3. add efi boot partition to fstab as /boot/efi
  4. boot machine using efi (refind may work)
    • apt-get install grub-efi grub-efi-amd64-signed shim-signed linux-signed-generic
    • yum install grub2-efi shim gdisk efibootmgr grub2-efi grub2-efi-x64-modules.noarch
  5. grub-setup / grub install (note: this may be automatically done by previous step, but make sure there are no errors)
  6. (optional) install refind

Additional information and references:

Installing efi on a Mac[edit]

  1. Install refind.
  2. Get the Ubuntu 13+ mac specific disk
  3. reboot and wait for refind; then hit REFRESH until the cd shows up
  4. install normally...

If you use the option or C keys to boot the cd, it will install in legacy mode.

Installing grub[edit]

Most of this applies to Ubuntu with grub2 but some applies to all systems.

grub-probe seems buggy, and at least on some systems, does not correctly detect the EFI boot partition. If you have this problem, Let grub-install create /boot/grub instead, and then manually copy it to /boot/efi/EFI/grub (or /EFI/grub on the efi partition if you also have to manually mount it.)

Grub creates a grub.efi and a core.efi which appear to be identical; it should be OK to delete one.

Note that grub2 embeds the root partition UUID into grub.efi, so if the disk UUID changes, you will have to rerun grub-install and recopy the file to the efi directory. Also, if grub is updated to a new version, you may want to recopy this file.

Possibly only the grub.efi file is needed as grub embeds most of its modules into this image. However, if it leaves modules out (bug?), it might be helpful to have a copy of the entire /boot/grub directory in the efi partition.

Grub seems to still read its config file off the root partition, not off the efi partition.


NOTE: it appears that the grub.efi file contains everything needed to boot if all goes well. However, those pieces come from /boot/grub so if something goes wrong, having all of /boot/grub in the efi partition might let you manually boot.

Adjusting grub[edit]

If this is a dual boot machine, edit /etc/default/grub

  • comment out both GRUB_HIDDEN_TIMEOUT* lines so the grub menu is shown
  • if windows is the desired boot OS, change GRUB_DEFAULT to the index of windows in the menu (typically 4 in ubuntu)
  • think about changing GRUB_TIMEOUT as per user preferences
  • if video issues on booting linux (see below) adjust appropriate options

To make these changes effective, run

 update-grub

Make sure you boot linux in efi mode before running update-grub or it will not correctly detect EFI windows.

Alternatives to the grub boot loader[edit]

If you are lucky, grub-install might run efibootmgr correctly and install itself in the bios EFI boot list. If not, here are some alternatives:

  • use windows bcdedit to add the boot entry and use the windows boot manager to select OS at boot
  • (if linux is efi booted) manually run efibootmgr to add the boot entry (example?)
  • install a third party boot loader, like rEFInd' rEFInd along with an EFI shell is also very helpful in assisting debugging of boot issues, and in general has good documentation of the EFI boot process.
  • If you spend any time in the EFI shell (or need the shell), try the tianocore EFI Toolkit which makes the EFI shell a decent usable operating system.

using windows boot manager[edit]

This from [1]

Mount EFI ESP

mountvol S: /S

find the linux boot loader and set it

bcdedit /set {bootmgr} path \EFI\ubuntu\shimx64.efi

optional

bcdedit /set {bootmgr} description "Ubuntu"

grub2 blank screen issues[edit]

Some video cards don't take kindly to grub and kernel video mode changes. Here's how to disable all that goo and make text booting just work:

Edit /etc/default/grub as follows:

  1. (optionally) comment out GRUB_HIDDEN_TIMEOUT so you actually see the grub menu
  2. edit GRUB_CMDLINE_LINUX_DEFAULT and replace "quiet splash" with "nomodeset" (or just add nomodeset)
  3. add GRUB_GFXPAYLOAD_LINUX=auto

then run update-grub

This might not be limited to EFI issues. I've found that without the above changes, text mode is unusuable on my system and I can't see any of the boot debug messages.

(SEO keywords...) This probably affects intel HD3000 and HD4000, many nVidia systems, noveau, etc...

Other things to try:

 video=800x600 
 nomodeset 
 vga=791 forcevesa nomodeset
 nouveau.modeset=0 rd.driver.blacklist=nouveau video=vesa:off vga=normal
systemd.unit=multi-user.target
plymouth.enable=0
systemd.confirm_spawn=true
systemd.log_level=debug
systemd.debug-shell=1

secure boot[edit]

Ubuntu 16 requires signed drivers if secure boot is in use.

Options:

  • Disable secure boot: sudo mokutil --disable-validation
  • sign the driver [2]

Additional links: (untested)