[SOLVED] UEFI Kickstart

General support questions
Post Reply
Thraex
Posts: 51
Joined: 2019/05/14 19:50:28

[SOLVED] UEFI Kickstart

Post by Thraex » 2019/07/10 18:29:15

How can I configure a CentOS 7 kickstart script to install for both BIOS and EFI systems?

Right now my kickstart only works on non-EFI systems but I'd like it to work on both and choose whether to use EFI or not. I'm assuming I need to add an if statement in the %pre section but I can't find any documentation or examples anywhere. CentOS' DVD iso works for either and I'm not entirely sure how it does that.

My other issue is that I can't create an iso image that can boot on uefi systems even without the kickstart configurations.
This is how I made the ISO:

Code: Select all

mkisofs -J -T -o /ISOs/rhel-ks.iso -b isolinux/isolinux.bin \
-c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table \
-R -m TRANS.TBL -graft-points -V "CentOS 7 x86_64"  \
/opt/ISOs/testing.iso
Thanks!
Last edited by Thraex on 2019/07/11 19:33:44, edited 1 time in total.

Thraex
Posts: 51
Joined: 2019/05/14 19:50:28

Re: UEFI Kickstart

Post by Thraex » 2019/07/10 19:21:01

Alright, I was able to get the iso to boot on a uefi and a BIOS virtual machine with the following:

Code: Select all

xorriso -as mkisofs -o /ISOs/gptest.iso -V "CentOS 7 x86_64" -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -R -J .
So now that the ISO works on both, I just need to tell it to choose the correct kickstart based on which installation it's using.
Last edited by Thraex on 2019/07/11 12:24:49, edited 1 time in total.

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: UEFI Kickstart

Post by jlehtone » 2019/07/10 19:44:38

Can you use PXE boot server? It can supply appropriate command line for each client type.


Edit: If you do have a DVD/USB with both legacy and UEFI bootloaders, then each can have its own kickstart in the image.
Last edited by jlehtone on 2019/07/10 19:46:32, edited 1 time in total.

Thraex
Posts: 51
Joined: 2019/05/14 19:50:28

Re: UEFI Kickstart

Post by Thraex » 2019/07/10 19:45:53

Unfortunately I can't :( These installs are on remote standalone systems so the most convenient way has been ISO's

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: UEFI Kickstart

Post by jlehtone » 2019/07/10 19:59:55

It seems that CentOS's ISOs have both grub.conf (for UEFI) and isolinux.fcg (for legacy). Two configs that could differ.

Thraex
Posts: 51
Joined: 2019/05/14 19:50:28

Re: UEFI Kickstart

Post by Thraex » 2019/07/10 20:10:43

That's correct, I've already changed the menu entries to point to the correct kickstart files so the only hang up I'm running into is the partitioning and possibly the bootloader being MBR. I don't know for sure if that works for EFI or not. Everything in the %post section should work for BIOS or EFI. I'm thinking about having an EFI kickstart that points to a separate file for the %post section and a BIOS kickstart that points to that same %post section. That seems like it'll be the easiest solution

Thraex
Posts: 51
Joined: 2019/05/14 19:50:28

Re: UEFI Kickstart

Post by Thraex » 2019/07/11 19:11:02

I got it all working exactly how I want it and wanted to provide the steps for anyone else attempting this.

Mount DVD iso

Code: Select all

mount -o loop /dev/cdrom /mnt
Copy it's contents to a local folder

Code: Select all

mkdir /ISO
cp -r /mnt/. /ISO/kickstart.iso
Unmount the CD

Code: Select all

umount /mnt
Create kickstart script in /ISO/kickstart.iso/isolinux

Code: Select all

 cp kickstart.cfg /ISO/kickstart.iso/isolinux/ks.cfg
Add kickstart to BIOS boot options

Code: Select all

sed -i '/append\ initrd/s/$/ inst.ks=cdrom:\/isolinux\/ks.cfg/' /ISO/kickstart.iso/isolinux/isolinux.cfg
Add kickstart to EFI boot options

Code: Select all

sed -i '/linuxefi/s/$/ inst.ks=cdrom:\/isolinux\/ks.cfg/' /ISO/kickstart.iso/EFI/BOOT/grub.cfg
Edit grub.cfg inside the efiboot.img

Code: Select all

mount -o loop /ISO/kickstart.iso/images/efiboot.img /mnt
sed -i '/linuxefi/s/$/ inst.ks=cdrom:\/isolinux\/ks.cfg/' /mnt/EFI/BOOT/grub.cfg
umount /mnt
Create the ISO **Output went to /ISOs/test.iso - Change as needed**

Code: Select all

xorriso -as mkisofs -o /ISOs/test.iso -V "CentOS 7 x86_64" \
-c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 \
-boot-info-table -eltorito-alt-boot \
-e images/efiboot.img -no-emul-boot -R -J /ISO/kickstart.iso/
To have your kickstart file change the partitioning for EFI vs BIOS, add the following:

Code: Select all

%include /tmp/uefi
%include /tmp/legacy

%pre --logfile /tmp/kickstart.install.pre.log

clearpart --all --initlabel

if [ -d /sys/firmware/efi ] ; then

 cat >> /tmp/uefi <<END

part /boot --fstype="ext4" --size=512
part /boot/efi --fstype="vfat" --size=1024
part swap  --size=100  --fstype=swap
part pv.13 --size=1 --grow 
volgroup VolGroup00 pv.13
logvol / --fstype xfs --name=rootsys --vgname=VolGroup00 --size=3000

END

else

 cat >> /tmp/legacy <<END
 
part /boot  --fstype=ext4 --size=300 
part pv.6 --size=1000 --grow --ondisk=$d1
part swap  --size=100  --fstype=swap
part pv.13 --size=1 --grow 
volgroup VolGroup00 pv.13
logvol / --fstype xfs --name=rootsys --vgname=VolGroup00 --size=3000

END

fi 

if [ -d /sys/firmware/efi ] ; then
touch /tmp/legacy
else 
touch /tmp/uefi
fi
chvt 1

%end
Sources used -
https://access.redhat.com/solutions/3081331
https://www.redhat.com/en/blog/building ... hypervisor

Hope this helps!!

Post Reply