CentOS 6.8 UEFI installation - how's it supposed to work?

General support questions
Post Reply
stuartnlevy
Posts: 3
Joined: 2016/12/29 20:56:37

CentOS 6.8 UEFI installation - how's it supposed to work?

Post by stuartnlevy » 2016/12/30 04:37:51

I wanted to install CentOS 6.8 on an HP z820, to allow dual-booting with Windows 10 on a separate disk.

The HP boot setup happily boots either UEFI/GPT or BIOS/MBR disks. But, it looks like, if there's any UEFI-bootable disk in the system, that gets booted in preference to the MBR disk. The default CentOS installation creates an MBR-based boot setup, which worked fine if it was the only disk in the machine, but it never booted if the Windows disk was installed.

So I needed to make the CentOS system do the UEFI boot thing. It eventually worked - and I didn't even need to reload the CentOS filesystem from the backup - but it *can't* be intended to be this hard. And I'm not sure if future kernel upgrades will be properly seen by grub.efi. The CentOS wiki says that UEFI installation should work for CentOS >=6.5, but doesn't say how to make it happen. (I didn't worry about secureboot, it's turned off in the BIOS.)

Things I'd love to know (details below):
* is there a CentOS 6 way of asking for an install to use GPT, and to install the EFI version of Grub, rather than MBR + BIOS Grub?
* How on earth can grub.efi find its grub.conf? I hacked around this, copying grub.conf into the vfat partition and mount --bind'ing it while Linux is running, but it seems fragile and awkward.

What I did, in brief:
installed CentOS 6 on a disk, giving it a small vfat partition (for EFI) and a large CentOS root partition + etc. This creates an MBR (non-GPT) setup
used "unit s" and "print" in parted to determine exact partition locations
used parted to relabel the disk as GPT, and create new GPT partitions in exactly the same locations as the originals
used gdisk's "n" command to create a protective MBR instead of the original one. Not sure if this was necessary.

Copied the CentOS EFI version of Grub onto the EFI partition in efibootmgr's default location, like

Code: Select all

    mount /dev/sdX1  /mnt
    mkdir  -p /mnt/EFI/redhat
    cp /boot/efi/EFI/redhat/grub.efi  /mnt/EFI/redhat/grub.efi
Used efibootmgr to add an entry for this in UEFI's NVRAM (letting it use the default loader, -l '\EFI\redhat\grub.efi'):

Code: Select all

    efibootmgr -c -d /dev/sdX  -L centos
This lets me get as far as a grub shell, but it doesn't know how to find any grub.conf, and I don't know how to tell it where to look for one. I was able to boot by entering root/kernel/initrd commands by hand.

It did work to put a copy of grub.conf into the same directory (on the EFI partition) as grub.efi:

Code: Select all

   cp /boot/grub/grub.conf  /mnt/EFI/redhat/grub.conf 
This lets me boot CentOS (yay!). But, /boot/grub/grub.conf (on the Linux root partition) will get changed whenever there's a kernel update. A sym-link into the EFI partition didn't work - the link was replaced by a local copy when a new kernel was installed. It might work to say

Code: Select all

    mkdir /efiboot
    mount /dev/sdX1 /efiboot
    mount --bind /efiboot/EFI/redhat/grub.conf  /boot/grub/grub.conf
Is there an easier way? (Does CentOS 7 have a streamlined way of doing UEFI installs, and if so, how does grub.efi find grub.conf while letting grub.conf be modifiable by existing tools?)


Other tip: Windows 10 seems to reset the boot-next-time flag to boot Windows by default, every time it shuts down. This is a nuisance if you want to use Grub as an interactive boot manager. Found good advice here on turning off "Fast Startup", which makes Windows leave things alone.
http://askubuntu.com/questions/666631/h ... p-notebook

Post Reply