Skip to content

Commit 1fb2462

Browse files
committed
Update centos74-hpc.ks to support Gen2 VMs
1 parent 70ce5ff commit 1fb2462

File tree

1 file changed

+64
-14
lines changed

1 file changed

+64
-14
lines changed

ks/azure/centos74-hpc.ks

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ lang en_US.UTF-8
1919
network --bootproto=dhcp
2020

2121
# Use network installation
22-
url --url=http://olcentgbl.trafficmanager.net/centos/7.4.1708/os/x86_64/
23-
repo --name="CentOS-Updates" --baseurl=http://olcentgbl.trafficmanager.net/centos/7.4.1708/updates/x86_64/
22+
url --url=http://olcentgbl-masters.trafficmanager.net/centos/7.4.1708/os/x86_64/
23+
repo --name="CentOS-Updates" --baseurl=http://olcentgbl-masters.trafficmanager.net/centos/7.4.1708/updates/x86_64/
24+
repo --name="openlogic" --baseurl="http://olcentgbl.trafficmanager.net/openlogic/7.4.1708/openlogic/x86_64/"
2425

2526
# Root password
2627
rootpw --plaintext "to_be_disabled"
@@ -31,21 +32,26 @@ services --enabled="sshd,waagent,dnsmasq,NetworkManager"
3132
# System timezone
3233
timezone Etc/UTC --isUtc
3334

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

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

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

5056
# Firewall configuration
5157
firewall --disabled
@@ -85,6 +91,10 @@ libstdc++.i686
8591
redhat-lsb
8692
-hypervkvpd
8793
-dracut-config-rescue
94+
nfs-utils
95+
# enable rootfs resize on boot
96+
cloud-utils-growpart
97+
gdisk
8898

8999
%end
90100

@@ -95,9 +105,12 @@ redhat-lsb
95105
# Disable the root account
96106
usermod root -p '!!'
97107

108+
# Set these to the point release baseurls so we can recreate a previous point release without current major version updates
98109
# Set OL repos
99110
curl -so /etc/yum.repos.d/CentOS-Base.repo https://raw.githubusercontent.com/szarkos/AzureBuildCentOS/master/config/azure/CentOS-Base-7.repo
100111
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.4.1708/' /etc/yum.repos.d/CentOS-Base.repo
113+
sed -i -e 's/$releasever/7.4.1708/' /etc/yum.repos.d/OpenLogic.repo
101114

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

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+
114156
# Blacklist the nouveau driver
115157
cat << EOF > /etc/modprobe.d/blacklist-nouveau.conf
116158
blacklist nouveau
117159
options nouveau modeset=0
118160
EOF
119161

120-
# Rebuild grub.cfg
121-
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"
122167

123168
# Enable SSH keepalive
124169
sed -i 's/^#\(ClientAliveInterval\).*$/\1 180/g' /etc/ssh/sshd_config
@@ -209,6 +254,11 @@ echo "http_caching=packages" >> /etc/yum.conf
209254
yum history sync
210255
yum clean all
211256

257+
# Download these again after the HPC build stage so we can recreate a previous point release without current major version updates
258+
# Set OL repos
259+
curl -so /etc/yum.repos.d/CentOS-Base.repo https://raw.githubusercontent.com/szarkos/AzureBuildCentOS/master/config/azure/CentOS-Base-7.repo
260+
curl -so /etc/yum.repos.d/OpenLogic.repo https://raw.githubusercontent.com/szarkos/AzureBuildCentOS/master/config/azure/OpenLogic.repo
261+
212262
# Set tuned profile
213263
echo "virtual-guest" > /etc/tuned/active_profile
214264

0 commit comments

Comments
 (0)