From df4153c46c2891d09bcef3e8027c81e63f49a9fb Mon Sep 17 00:00:00 2001 From: Daniel Juarez Gonzalez Date: Wed, 6 May 2020 15:01:34 +0000 Subject: [PATCH 1/2] Add comments, notes --- CHANGELOG.md | 11 +++++++++++ README.md | 2 ++ c8-cloud.ks | 8 +++++++- cc7-cloud.ks | 16 ++++++++++------ 4 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b32a11a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# CHANGELOG + +Unless otherwise stated, newer images do not include changes compared to previous versions. + +## 04-05-2020 + +`CC7 - x86_64 [2020-05-04]` + +* Build image against CC7.8 tree +* Dual booting image: it can be now used for both BIOS and UEFI machines, both [virtual](https://clouddocs.web.cern.ch/advanced_topics/uefi_support.html) or physical. + * This change implies that nodes will now have a mounted EFI partition even on BIOS machines. diff --git a/README.md b/README.md index 17becd7..2f7aeab 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Cloud images +Refer to [CHANGELOG](./CHANGELOG.md) to see the latest changes + ### Image building note: docker images moved to separate projects (linuxsupport/{cc7-base,slc6-base,slc5-base}) diff --git a/c8-cloud.ks b/c8-cloud.ks index 286a56b..e7cbb0e 100644 --- a/c8-cloud.ks +++ b/c8-cloud.ks @@ -170,17 +170,23 @@ sed -i -e 's/crashkernel=auto/rd.auto net.ifnames=0 crashkernel=auto/g' /etc/def # Enable BIOS bootloader grub2-mkconfig --output /etc/grub2-efi.cfg grub2-install --target=i386-pc --directory=/usr/lib/grub/i386-pc/ /dev/vda +# Notes regarding dual booting and grub configuration!!! +# On a BIOS machine grub configuration will be /boot/grub2/grub.cfg, on a UEFI one, /boot/efi/EFI/centos/grub.cfg +# Grub Environmental Block (grubenv) on a BIOS machine is /boot/grub2/grubenv and /boot/efi/EFI/centos/grubenv on UEFI, BUT since +# we are building on a UEFI VM, /boot/grub2/grubenv will always be a symlink to /boot/efi/EFI/centos/grubenv, i.e. both booting modes +# will be using the same file which is on the EFI partition. This means we will need this EFI partition (#15) even on BIOS machines! grub2-mkconfig --output=/boot/grub2/grub.cfg # Fix grub.cfg to remove EFI entries and adapt them to BIOS -# blkid --match-tag UUID --output value /dev/vda15 on C8!!!!! +# We need to adapt grub configuration in the case of BIOS config as it is preloaded with the UEFI partition ID instead of the BIOS partition ID EFI_ID=`blkid -s UUID -o value /dev/vda15` BOOT_ID=`blkid -s UUID -o value /dev/vda1` sed -i 's/gpt15/gpt1/' /boot/grub2/grub.cfg sed -i "s/${EFI_ID}/${BOOT_ID}/" /boot/grub2/grub.cfg +# Force Grub Environmental Block to come from our common grubenv location sed -i 's|${config_directory}/grubenv|(hd0,gpt15)/efi/centos/grubenv|' /boot/grub2/grub.cfg sed -i '/^### BEGIN \/etc\/grub.d\/30_uefi/,/^### END \/etc\/grub.d\/30_uefi/{/^### BEGIN \/etc\/grub.d\/30_uefi/!{/^### END \/etc\/grub.d\/30_uefi/!d}}' /boot/grub2/grub.cfg diff --git a/cc7-cloud.ks b/cc7-cloud.ks index ebc2b4f..f151279 100644 --- a/cc7-cloud.ks +++ b/cc7-cloud.ks @@ -81,8 +81,6 @@ dracut-config-generic dracut-norescue firewalld grub2 -grub2-efi-x64-modules -efibootmgr parted gdisk iptables-services @@ -240,22 +238,28 @@ rm -rf /var/cache/yum/* # Ironic fix rd.auto sed -i -e 's/crashkernel/rd.auto net.ifnames=0 crashkernel/g' /etc/default/grub -# We are installing bootloader with the bootloader command, but this only adds uefi compatible (as we are building in a UEFI VM), so we force both:https://unix.stackexchange.com/questions/273329/can-i-install-grub2-on-a-flash-drive-to-boot-both-bios-and-uefi +# We are installing bootloader with the bootloader command, but this only adds uefi compatible (as we are building in a UEFI VM), so we force both: https://unix.stackexchange.com/questions/273329/can-i-install-grub2-on-a-flash-drive-to-boot-both-bios-and-uefi # Enable BIOS bootloader grub2-mkconfig --output /etc/grub2-efi.cfg grub2-install --target=i386-pc --directory=/usr/lib/grub/i386-pc/ /dev/vda +# Notes regarding dual booting and grub configuration!!! +# On a BIOS machine grub configuration will be /boot/grub2/grub.cfg, on a UEFI one, /boot/efi/EFI/centos/grub.cfg +# Grub Environmental Block (grubenv) on a BIOS machine is /boot/grub2/grubenv and /boot/efi/EFI/centos/grubenv on UEFI, BUT since +# we are building on a UEFI VM, /boot/grub2/grubenv will always be a symlink to /boot/efi/EFI/centos/grubenv, i.e. both booting modes +# will be using the same file which is on the EFI partition. This means we will need this EFI partition (#15) even on BIOS machines! grub2-mkconfig --output=/boot/grub2/grub.cfg - # Fix grub.cfg to remove EFI entries and adapt them to BIOS -# blkid --match-tag UUID --output value /dev/vda15 on C8!!!!! +# We need to adapt grub configuration in the case of BIOS config as it is preloaded with the UEFI partition ID instead of the BIOS partition ID EFI_ID=`blkid -s UUID -o value /dev/vda15` BOOT_ID=`blkid -s UUID -o value /dev/vda1` sed -i 's/gpt15/gpt1/' /boot/grub2/grub.cfg sed -i "s/${EFI_ID}/${BOOT_ID}/" /boot/grub2/grub.cfg -sed -i 's|${config_directory}/grubenv|(hd0,gpt15)/efi/centos/grubenv|' /boot/grub2/grub.cfg +# Force Grub Environmental Block to come from our common grubenv location +sed -i 's|$prefix/grubenv|(hd0,gpt15)/efi/centos/grubenv|' /boot/grub2/grub.cfg +sed -i 's|load_env|load_env -f (hd0,gpt15)/efi/centos/grubenv|' /boot/grub2/grub.cfg sed -i '/^### BEGIN \/etc\/grub.d\/30_uefi/,/^### END \/etc\/grub.d\/30_uefi/{/^### BEGIN \/etc\/grub.d\/30_uefi/!{/^### END \/etc\/grub.d\/30_uefi/!d}}' /boot/grub2/grub.cfg # Required for CentOS 7.x due to no blscfg: https://bugzilla.redhat.com/show_bug.cgi?id=1570991#c6 sed -i -e 's|linuxefi|linux|' -e 's|initrdefi|initrd|' /boot/grub2/grub.cfg -- GitLab From 8fc8760e5014e208c66c97ced19c209cddc2d737 Mon Sep 17 00:00:00 2001 From: Daniel Juarez Gonzalez Date: Wed, 6 May 2020 15:07:34 +0000 Subject: [PATCH 2/2] Add references about dual booting, so we do not lose track of what CentOS is doing --- c8-cloud.ks | 1 + cc7-cloud.ks | 1 + 2 files changed, 2 insertions(+) diff --git a/c8-cloud.ks b/c8-cloud.ks index e7cbb0e..022ec3c 100644 --- a/c8-cloud.ks +++ b/c8-cloud.ks @@ -30,6 +30,7 @@ zerombr # Partitioning and bootloader configuration # Note: biosboot and efi partitions are pre-created in %pre. +# Based on https://github.com/CentOS/sig-cloud-instance-build/blob/98aa8c6f0290feeb94d86b52c561d70eabc7d942/cloudimg/CentOS-8-x86_64-Azure.ks bootloader --location=mbr --timeout=1 --append="console=ttyS0,115200 console=tty0" --boot-drive=vda # This is replaced by the pre-creation of partitions by sgdisk diff --git a/cc7-cloud.ks b/cc7-cloud.ks index f151279..c85893e 100644 --- a/cc7-cloud.ks +++ b/cc7-cloud.ks @@ -34,6 +34,7 @@ zerombr # Partitioning and bootloader configuration # Note: biosboot and efi partitions are pre-created in %pre. +# Based on https://github.com/openlogic/AzureBuildCentOS/blob/8f46a34e6fceed41030ef4611ca85a272f0abbe4/ks/azure/centos77.ks bootloader --location=mbr --timeout=1 --append="console=ttyS0,115200 console=tty0" --boot-drive=vda # This is replaced by the pre-creation of partitions by sgdisk -- GitLab