Skip to content

Commit d759c4a

Browse files
committed
Update centos75-hpc.ks to support Gen2 VMs
1 parent 54a4f46 commit d759c4a

File tree

1 file changed

+61
-12
lines changed

1 file changed

+61
-12
lines changed

ks/azure/centos75-hpc.ks

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,26 @@ services --enabled="sshd,waagent,dnsmasq,NetworkManager"
3131
# System timezone
3232
timezone Etc/UTC --isUtc
3333

34-
# Partition clearing information
35-
clearpart --all --initlabel
36-
37-
# Clear the MBR
34+
# Partitioning and bootloader configuration
35+
# Note: biosboot and efi partitions are pre-created %pre to work around blivet issue
3836
zerombr
39-
40-
# Disk partitioning information
37+
bootloader --location=mbr --timeout=1
38+
# part biosboot --onpart=sda14 --size=4
39+
part /boot/efi --onpart=sda15 --fstype=vfat --size=500
4140
part /boot --fstype="xfs" --size=500
4241
part / --fstype="xfs" --size=1 --grow --asprimary
4342

44-
# System bootloader configuration
45-
bootloader --location=mbr --timeout=1
43+
%pre --log=/var/log/anaconda/pre-install.log --erroronfail
44+
#!/bin/bash
45+
46+
# Pre-create the biosboot and EFI partitions
47+
sgdisk --clear /dev/sda
48+
sgdisk --new=14:2048:10239 /dev/sda
49+
sgdisk --new=15:10240:500M /dev/sda
50+
sgdisk --typecode=14:EF02 /dev/sda
51+
sgdisk --typecode=15:EF00 /dev/sda
4652

47-
# Add OpenLogic repo
48-
repo --name=openlogic --baseurl=http://olcentgbl.trafficmanager.net/openlogic/7/openlogic/x86_64/
53+
%end
4954

5055
# Firewall configuration
5156
firewall --disabled
@@ -86,6 +91,10 @@ redhat-lsb
8691
-hypervkvpd
8792
-hyperv-daemons
8893
-dracut-config-rescue
94+
nfs-utils
95+
# enable rootfs resize on boot
96+
cloud-utils-growpart
97+
gdisk
8998

9099
%end
91100

@@ -96,9 +105,12 @@ redhat-lsb
96105
# Disable the root account
97106
usermod root -p '!!'
98107

108+
# Set these to the point release baseurls so we can recreate a previous point release without current major version updates
99109
# Set OL repos
100110
curl -so /etc/yum.repos.d/CentOS-Base.repo https://raw.githubusercontent.com/szarkos/AzureBuildCentOS/master/config/azure/CentOS-Base-7.repo
101111
curl -so /etc/yum.repos.d/OpenLogic.repo https://raw.githubusercontent.com/szarkos/AzureBuildCentOS/master/config/azure/OpenLogic.repo
112+
sed -i -e 's/$releasever/7.5.1804/' /etc/yum.repos.d/CentOS-Base.repo
113+
sed -i -e 's/$releasever/7.5.1804/' /etc/yum.repos.d/OpenLogic.repo
102114

103115
# Import CentOS and OpenLogic public keys
104116
curl -so /etc/pki/rpm-gpg/OpenLogic-GPG-KEY https://raw.githubusercontent.com/szarkos/AzureBuildCentOS/master/config/OpenLogic-GPG-KEY
@@ -112,14 +124,46 @@ sed -i 's/^\(GRUB_CMDLINE_LINUX\)=".*"$/\1="console=tty1 console=ttyS0,115200n8
112124
echo 'GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"' >> /etc/default/grub
113125
sed -i 's/^GRUB_TERMINAL_OUTPUT=".*"$/GRUB_TERMINAL="serial console"/g' /etc/default/grub
114126

127+
# Enable BIOS bootloader
128+
grub2-mkconfig --output /etc/grub2-efi.cfg
129+
grub2-install --target=i386-pc --directory=/usr/lib/grub/i386-pc/ /dev/sda
130+
grub2-mkconfig --output=/boot/grub2/grub.cfg
131+
132+
# Grab major version number so we can properly adjust grub config.
133+
# Should work on both RHEL and CentOS reliably
134+
majorVersion=$(rpm -E %{rhel})
135+
136+
# Fix grub.cfg to remove EFI entries, otherwise "boot=" is not set correctly and blscfg fails
137+
[ "$majorVersion" = "7" ] && {
138+
EFI_ID=`blkid -s UUID -o value /dev/sda15`
139+
EFI_ID=`blkid -s UUID -o value /dev/sda1`
140+
sed -i 's|$prefix/grubenv|(hd0,gpt15)/efi/centos/grubenv|' /boot/grub2/grub.cfg
141+
sed -i 's|load_env|load_env -f (hd0,gpt15)/efi/centos/grubenv|' /boot/grub2/grub.cfg
142+
143+
# Required for CentOS 7.x due to no blscfg: https://bugzilla.redhat.com/show_bug.cgi?id=1570991#c6
144+
#cat /etc/grub2-efi.cfg | sed -e 's|linuxefi|linux|' -e 's|initrdefi|initrd|' > /boot/grub2/grub.cfg
145+
sed -i -e 's|linuxefi|linux|' -e 's|initrdefi|initrd|' /boot/grub2/grub.cfg
146+
}
147+
[ "$majorVersion" = "8" ] && {
148+
EFI_ID=`blkid --match-tag UUID --output value /dev/sda15`
149+
BOOT_ID=`blkid --match-tag UUID --output value /dev/sda1`
150+
sed -i 's|${config_directory}/grubenv|(hd0,gpt15)/efi/centos/grubenv|' /boot/grub2/grub.cfg
151+
}
152+
sed -i 's/gpt15/gpt1/' /boot/grub2/grub.cfg
153+
sed -i "s/${EFI_ID}/${BOOT_ID}/" /boot/grub2/grub.cfg
154+
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
155+
115156
# Blacklist the nouveau driver
116157
cat << EOF > /etc/modprobe.d/blacklist-nouveau.conf
117158
blacklist nouveau
118159
options nouveau modeset=0
119160
EOF
120161

121-
# Rebuild grub.cfg
122-
grub2-mkconfig -o /boot/grub2/grub.cfg
162+
# Ensure Hyper-V drivers are built into initramfs
163+
echo '# Ensure Hyper-V drivers are built into initramfs' >> /etc/dracut.conf.d/azure.conf
164+
echo -e "\nadd_drivers+=\"hv_vmbus hv_netvsc hv_storvsc\"" >> /etc/dracut.conf.d/azure.conf
165+
kversion=$( rpm -q kernel | sed 's/kernel\-//' )
166+
dracut -v -f "/boot/initramfs-${kversion}.img" "$kversion"
123167

124168
# Enable SSH keepalive
125169
sed -i 's/^#\(ClientAliveInterval\).*$/\1 180/g' /etc/ssh/sshd_config
@@ -217,6 +261,11 @@ echo "http_caching=packages" >> /etc/yum.conf
217261
yum history sync
218262
yum clean all
219263

264+
# Download these again after the HPC build stage so we can recreate a previous point release without current major version updates
265+
# Set OL repos
266+
curl -so /etc/yum.repos.d/CentOS-Base.repo https://raw.githubusercontent.com/szarkos/AzureBuildCentOS/master/config/azure/CentOS-Base-7.repo
267+
curl -so /etc/yum.repos.d/OpenLogic.repo https://raw.githubusercontent.com/szarkos/AzureBuildCentOS/master/config/azure/OpenLogic.repo
268+
220269
# Set tuned profile
221270
echo "virtual-guest" > /etc/tuned/active_profile
222271

0 commit comments

Comments
 (0)