Light At The End Of The Tunnel

systems administration meanderings

Kickstart overcoming UEFi or converting from MBR

Recently I had the opportunity to install CentOS 7 onto a new Intel Skylake based machine. The system using legacy bios mode installed via kickstart without any issues, repeatedly.

I should say that the system had two 500Gb msata drives and an M.2 1Tb drive. The two msata would hold CentOS and would use Raid 1. Unfortunately, the system needed to be in UEFi mode, and this change meant a new kickstart file. Under legacy BIOS mode the disk partitioning looked like :-

# Disk partitioning
part raid.01 --fstype="raid" --ondisk=sda --size=500
part raid.02 --fstype="raid" --grow --ondisk=sda --size=1
part raid.03 --fstype="raid" --ondisk=sdb --size=500
part raid.04 --fstype="raid" --grow --ondisk=sdb --size=1

raid /boot --device=md0 --fstype="xfs" --level=1 raid.01 raid.03
raid pv.01 --device=md1 --level=1 raid.02 raid.04

Therefore, it should be a simple matter of adding an EFi partition like so:-

part /boot/efi --fstype="efi" --size=200 --ondisk=sda
part raid.01 --fstype="raid" --ondisk=sda --size=500
part raid.02 --fstype="raid" --grow --ondisk=sda --size=1
part raid.03 --fstype="raid" --ondisk=sdb --size=500
part raid.04 --fstype="raid" --grow --ondisk=sdb --size=1


raid /boot --device=md0 --fstype="xfs" --level=1 raid.01 raid.03
raid pv.01 --device=md1 --level=1 raid.02 raid.04

It failed with anaconda reporting that it was unable to find a suitable stage1 device. Over several iterations I ended up manually creating the required EFi partition and it still failed with the following error in the anaconda.log:-

06:08:54,828 DEBUG anaconda: new disk order: []
06:08:54,832 DEBUG anaconda: new disk order: []
06:08:54,851 DEBUG anaconda: stage1 device cannot be of type disk
06:08:54,865 DEBUG anaconda: _is_valid_disklabel(sda1) returning True
06:08:54,867 DEBUG anaconda: _is_valid_size(sda1) returning True
06:08:54,867 DEBUG anaconda: _is_valid_location(sda1) returning True
06:08:54,867 DEBUG anaconda: _is_valid_format(sda1) returning False
06:08:54,867 DEBUG anaconda: is_valid_stage1_device(sda1) returning False
06:08:54,867 ERR anaconda: BootLoader setup failed: failed to find a suitable stage1 device

I even included a section in the

%pre

section of the kickstart that wiped all the partition information, as shown below:-

%pre --log /tmp/pre-install.log
echo "Starting Kickstart Pre-Installation..."

vgchange -a n
test -b /dev/md0 && wipefs -a /dev/md0 && mdadm --stop /dev/md0
test -b /dev/md1 && wipefs -a /dev/md1 && mdadm --stop /dev/md1
wipefs -a /dev/sda[1,2,3]
wipefs -a /dev/sdb[1,2,3]
wipefs -a /dev/sd[a,b]
%end

I wish to mention that the system would install perfectly under an interactive install but unfortunately the ability to create Raid 1 devices in this mode has been removed from anaconda .

In researching the answer to this issue I came across the following information. For UEFi the disks need to use gpt partitions, but under legacy BIOS mode, gpt partitions would not be used unless the disks were greater than 2Tb. To force legacy BIOS to use gpt partitions on smaller disks the installer needs to be booted with the inst.gpt kernel option. Now for legacy BIOS mode to boot gpt partitions it needs a partition called biosboot

Time for a change in tack. I changed the system back to legacy BIOS and changed the kickstart file as follows:-

# Disk partitioning
part biosboot --fstype=biosboot --size=1 --ondisk=sda
part /boot/efi --ondisk=sda --fstype="efi" --size=200

part raid.02 --fstype="raid" --ondisk=sda --size=500
part raid.03 --fstype="raid" --grow --ondisk=sda --size=1
part raid.05 --fstype="raid" --ondisk=sdb --size=500
part raid.06 --fstype="raid" --grow --ondisk=sdb --size=1

raid /boot --device=md1 --fstype="xfs" --level=1 raid.02 raid.05
raid pv.01 --device=md2 --level=1 raid.03 raid.06

The system installed but under legacy BIOS the efi variables required to install the bootlader into the /boot/efi partition does not exist.

The solution to this is to create a PXE option to boot into rescue mode, change the system to UEFi mode and then delete the biosboot partition, install the bootloader and ensure the system is ready to boot:-

# Remove the biosboot partition

parted /dev/sda
(parted) rm
Partition number? 1                                                       
(parted)
# When the biosboot partition was created it also added a disk flag called pmbr_boot

(parted) disk_set pmbr_boot off
(parted) quit

Make sure that UEFi can use the CentOS boot loader

efibootmgr --create --gpt --disk /dev/sda --part 3 --write-signature --label "CentOS" --loader "\\EFI\\centos\\grubx86.efi"

Install grub

grub2-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id="CentOS7" -recheck --verbose /dev/sda 

Now check grub2.cfg As we installed under legacy BIOS the boot command in grub2.cfg is linux16 or linux64. This needs to change to linuxefi same needs to occur for initrdefi

Now just reboot and away you go.


Share

#