Skip to content

Commit 54a4f46

Browse files
committed
Update centos77-hpc-sriov.ks to support Gen2 VMs
1 parent c9d4ddc commit 54a4f46

File tree

1 file changed

+56
-11
lines changed

1 file changed

+56
-11
lines changed

ks/azure/centos77-hpc-sriov.ks

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,26 @@ services --enabled="sshd,waagent,dnsmasq,NetworkManager"
3434
# System timezone
3535
timezone Etc/UTC --isUtc
3636

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

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

5058
# Firewall configuration
5159
firewall --disabled
@@ -66,16 +74,20 @@ poweroff
6674
%packages
6775
@base
6876
@console-internet
69-
@development
7077
chrony
7178
cifs-utils
7279
sudo
7380
python-pyasn1
7481
parted
7582
WALinuxAgent
7683
hypervkvpd
84+
gdisk
85+
#cloud-init
86+
cloud-utils-growpart
87+
azure-repo-svc
7788
-dracut-config-rescue
7889
nfs-utils
90+
7991
%end
8092

8193
%post --log=/var/log/anaconda/post-install.log
@@ -101,14 +113,46 @@ sed -i 's/^\(GRUB_CMDLINE_LINUX\)=".*"$/\1="console=tty1 console=ttyS0,115200n8
101113
echo 'GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"' >> /etc/default/grub
102114
sed -i 's/^GRUB_TERMINAL_OUTPUT=".*"$/GRUB_TERMINAL="serial console"/g' /etc/default/grub
103115

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

110-
# Rebuild grub.cfg
111-
grub2-mkconfig -o /boot/grub2/grub.cfg
151+
# Ensure Hyper-V drivers are built into initramfs
152+
echo '# Ensure Hyper-V drivers are built into initramfs' >> /etc/dracut.conf.d/azure.conf
153+
echo -e "\nadd_drivers+=\"hv_vmbus hv_netvsc hv_storvsc\"" >> /etc/dracut.conf.d/azure.conf
154+
kversion=$( rpm -q kernel | sed 's/kernel\-//' )
155+
dracut -v -f "/boot/initramfs-${kversion}.img" "$kversion"
112156

113157
# Enable SSH keepalive
114158
sed -i 's/^#\(ClientAliveInterval\).*$/\1 180/g' /etc/ssh/sshd_config
@@ -183,6 +227,7 @@ cd && rm -rf /tmp/azhpc-images-${CENTOS_HPC_VERSION}
183227

184228
# Modify yum
185229
echo "http_caching=packages" >> /etc/yum.conf
230+
yum history sync
186231
yum clean all
187232

188233
# Set tuned profile

0 commit comments

Comments
 (0)