使用 kickstart 安装 BIOS 和 UEFI 引导加载程序

使用 kickstart 安装 BIOS 和 UEFI 引导加载程序

我正在尝试建立一个Koji 的磁盘映像。为此,您需要指定要使用的 kickstart 文件。由于 QEMU 正在生成 BIOS VM,因此我的 kickstart 仅执行与 BIOS 相关的内容。

我的问题是,我希望这个映像也能在仅支持 UEFI 的机器上运行。我如何才能仅使用一个 kickstart 文件来实现这一点?请记住,构建总是在 BIOS 机器上进行,所以我的想法是,是否可以为 BIOS 和 UEFI“安装两个引导加载程序”,以便无论使用什么,这个映像都可以在每台机器上运行。

这是我正在使用的 Kickstart 文件:

(...)
ignoredisk --only-use=vda
# System bootloader configuration
bootloader --append="console=ttyS0,115200 console=tty0 inst.gpt" --location=mbr --timeout=5 --boot-drive=vda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --disklabel gpt

part biosboot --fstype=biosboot --size=1 --ondisk=vda
partition /boot/efi --fstype=efi --label EFI  --size=200
partition /         --fstype=xfs --ondisk=vda --label ROOT --size=2800 --mkfsoptions="-n ftype=1"

(...)

/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg
/usr/sbin/grub2-mkconfig --o /etc/grub2-efi.cfg
# We are installing bootloader with the bootloader command, but this only adds bios compatible, so we force both: https://unix.stackexchange.com/questions/273329/can-i-install-grub2-on-a-flash-drive-to-boot-both-bios-and-uefi
# Should not be necessary to add --directory=/usr/lib/grub/x86_64-efi/ /dev/vda
/usr/sbin/grub2-install --target x86_64-efi
/usr/sbin/grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

相关内容