2 # Copyright (c) 2019 Wind River Systems, Inc.
3 # SPDX-License-Identifier: Apache-2.0
7 # This file defines functions that can be used in %pre and %post kickstart sections, by including:
8 # . /tmp/ks-functions.sh
11 cat <<END_FUNCTIONS >/tmp/ks-functions.sh
13 # Copyright (c) 2019 Wind River Systems, Inc.
15 # SPDX-License-Identifier: Apache-2.0
18 function get_by_path()
20 local disk=\$(cd /dev ; readlink -f \$1)
21 for p in /dev/disk/by-path/*; do
22 if [ "\$disk" = "\$(readlink -f \$p)" ]; then
31 echo \$(cd /dev ; readlink -f \$1)
34 function report_pre_failure_with_msg()
37 echo -e '\n\nInstallation failed.\n'
43 function report_post_failure_with_msg()
46 cat <<EOF >> /etc/motd
52 echo "\$msg" >/etc/platform/installation_failed
54 echo -e '\n\nInstallation failed.\n'
60 function report_post_failure_with_logfile()
63 cat <<EOF >> /etc/motd
66 Please see \$logfile for details of failure
69 echo \$logfile >/etc/platform/installation_failed
71 echo -e '\n\nInstallation failed.\n'
77 function get_http_port()
79 echo \$(cat /proc/cmdline |xargs -n1 echo |grep '^inst.repo=' | sed -r 's#^[^/]*://[^/]*:([0-9]*)/.*#\1#')
87 # This file defines functions that can be used in %pre and %post kickstart sections, by including:
88 # . /tmp/ks-functions.sh
91 cat <<END_FUNCTIONS >/tmp/ks-functions.sh
93 # Copyright (c) 2019 Wind River Systems, Inc.
95 # SPDX-License-Identifier: Apache-2.0
98 function get_by_path()
100 local disk=\$(cd /dev ; readlink -f \$1)
101 for p in /dev/disk/by-path/*; do
102 if [ "\$disk" = "\$(readlink -f \$p)" ]; then
111 echo \$(cd /dev ; readlink -f \$1)
114 function report_pre_failure_with_msg()
117 echo -e '\n\nInstallation failed.\n'
123 function report_post_failure_with_msg()
126 cat <<EOF >> /etc/motd
132 echo "\$msg" >/etc/platform/installation_failed
134 echo -e '\n\nInstallation failed.\n'
140 function report_post_failure_with_logfile()
143 cat <<EOF >> /etc/motd
146 Please see \$logfile for details of failure
149 echo \$logfile >/etc/platform/installation_failed
151 echo -e '\n\nInstallation failed.\n'
157 function get_http_port()
159 echo \$(cat /proc/cmdline |xargs -n1 echo |grep '^inst.repo=' | sed -r 's#^[^/]*://[^/]*:([0-9]*)/.*#\1#')
167 # Template from: pre_common_head.cfg
170 # Source common functions
171 . /tmp/ks-functions.sh
173 # First, parse /proc/cmdline to find the boot args
174 set -- `cat /proc/cmdline`
175 for I in $*; do case "$I" in *=*) eval $I 2>/dev/null;; esac; done
178 if [ -n "$console" ] ; then
179 append="console=$console"
182 if [ -n "$security_profile" ]; then
183 append="$append security_profile=$security_profile"
186 #### SECURITY PROFILE HANDLING (Pre Installation) ####
187 if [ -n "$security_profile" ] && [ "$security_profile" == "extended" ]; then
188 # IMA specific boot options:
189 # Enable Kernel auditing
190 append="$append audit=1"
192 # we need to blacklist the IMA and Integrity Modules
193 # on standard security profile
194 append="$append module_blacklist=integrity,ima"
196 # Disable Kernel auditing in Standard Security Profile mode
197 append="$append audit=0"
200 if [ -n "$tboot" ]; then
201 append="$append tboot=$tboot"
203 append="$append tboot=false"
207 if [ -n "$boot_device" ] ; then
208 boot_device_arg="--boot-drive=$(get_by_path $boot_device)"
211 echo "bootloader --location=mbr $boot_device_arg --timeout=5 --append=\"$append\"" > /tmp/bootloader-include
213 echo "timezone --nontp --utc UTC" >/tmp/timezone-include
220 %include /tmp/timezone-include
221 # set to 'x' so we can use shadow password
224 authconfig --enableshadow --passalgo=sha512
225 firewall --service=ssh
227 # The following is the partition information you requested
228 # Note that any partitions you deleted are not expressed
229 # here so unless you clear all partitions first, this is
230 # not guaranteed to work
233 # Disk layout from %pre
234 %include /tmp/part-include
235 # Bootloader parms from %pre
236 %include /tmp/bootloader-include
241 # Template from: pre_pkglist_lowlatency.cfg
245 -kernel-module-igb-uio
246 -kernel-module-wrs-avp
257 -mlnx-ofa_kernel-modules
259 @platform-controller-worker-lowlatency
260 @updates-controller-worker-lowlatency
264 # Template from: pre_disk_setup_common.cfg
267 # Source common functions
268 . /tmp/ks-functions.sh
270 # This is a really fancy way of finding the first usable disk for the
271 # install and not stomping on the USB device if it comes up first
273 # First, parse /proc/cmdline to find the boot args
274 set -- `cat /proc/cmdline`
275 for I in $*; do case "$I" in *=*) eval $I 2>/dev/null;; esac; done
277 # Find either the ISO or USB device first chopping off partition
278 ISO_DEV=`readlink /dev/disk/by-label/oe_iso_boot`
279 sdev=`echo $ISO_DEV | sed -e 's/.$//'`
280 if [ -e /dev/disk/by-label/$sdev ] ; then
283 USB_DEV=`readlink /dev/disk/by-label/wr_usb_boot`
284 sdev=`echo $USB_DEV | sed -e 's/.$//'`
285 if [ -e /dev/disk/by-label/$sdev ] ; then
289 # Temporary, until lab pxelinux.cfg files are updated to specify install devices
290 if [ -z "$rootfs_device" -o -z "$boot_device" ]
293 # Prefer a vd* device if this is kvm/qemu
294 for e in vda vdb sda sdb nvme0n1; do
295 if [ -e /dev/$e -a "$ISO_DEV" != "../../$e" -a "$USB_DEV" != "../../$e" ] ; then
301 # Set variables to $INST_HDD if not set
302 rootfs_device=${rootfs_device:-$INST_HDD}
303 boot_device=${boot_device:-$INST_HDD}
307 orig_rootfs_device=$rootfs_device
308 rootfs_device=$(get_by_path $rootfs_device)
310 orig_boot_device=$boot_device
311 boot_device=$(get_by_path $boot_device)
313 if [ ! -e "$rootfs_device" -o ! -e "$boot_device" ] ; then
314 # Touch this file to prevent Anaconda from dying an ungraceful death
315 touch /tmp/part-include
317 report_pre_failure_with_msg "ERROR: Specified installation ($orig_rootfs_device) or boot ($orig_boot_device) device is invalid."
320 # Ensure specified device is not a USB drive
321 udevadm info --query=property --name=$rootfs_device |grep -q '^ID_BUS=usb' || \
322 udevadm info --query=property --name=$boot_device |grep -q '^ID_BUS=usb'
323 if [ $? -eq 0 ]; then
324 # Touch this file to prevent Anaconda from dying an ungraceful death
325 touch /tmp/part-include
327 report_pre_failure_with_msg "ERROR: Specified installation ($orig_rootfs_device) or boot ($orig_boot_device) device is a USB drive."
330 # Deactivate existing volume groups to avoid Anaconda issues with pre-existing groups
331 vgs --noheadings -o vg_name | xargs --no-run-if-empty -n 1 vgchange -an
333 # Remove volumes and group for cgts-vg, if any
334 lvremove --force cgts-vg
335 pvs --select 'vg_name=cgts-vg' --noheadings -o pv_name | xargs --no-run-if-empty pvremove --force --force --yes
336 vgs --select 'vg_name=cgts-vg' --noheadings -o vg_name | xargs --no-run-if-empty vgremove --force
339 if [ "$(curl -sf http://pxecontroller:6385/v1/upgrade/$(hostname)/in_upgrade 2>/dev/null)" = "true" ]; then
340 # In an upgrade, only wipe the disk with the rootfs and boot partition
341 echo "In upgrade, wiping only $rootfs_device"
342 WIPE_HDD="$(get_disk $rootfs_device)"
343 ONLYUSE_HDD="$(basename $(get_disk $rootfs_device))"
344 if [ "$(get_disk $rootfs_device)" != "$(get_disk $boot_device)" ]; then
345 WIPE_HDD="$WIPE_HDD,$(get_disk $boot_device)"
346 ONLYUSE_HDD="$ONLYUSE_HDD,$(basename $(get_disk $boot_device))"
349 # Make a list of all the hard drives that are to be wiped
351 # Partition type OSD has a unique globally identifier
352 part_type_guid_str="Partition GUID code"
353 CEPH_OSD_GUID="4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D"
355 # Check if we wipe OSDs
356 if [ "$(curl -sf http://pxecontroller:6385/v1/ihosts/wipe_osds 2>/dev/null)" = "true" ]; then
357 echo "Wipe OSD data."
358 WIPE_CEPH_OSDS="true"
360 echo "Skip Ceph OSD data wipe."
361 WIPE_CEPH_OSDS="false"
364 for f in /dev/disk/by-path/*
366 dev=$(readlink -f $f)
367 lsblk --nodeps --pairs $dev | grep -q 'TYPE="disk"'
373 # Avoid wiping USB drives
374 udevadm info --query=property --name=$dev |grep -q '^ID_BUS=usb' && continue
376 # Avoid wiping ceph osds if sysinv tells us so
377 if [ ${WIPE_CEPH_OSDS} == "false" ]; then
379 part_numbers=( `parted -s $dev print | awk '$1 == "Number" {i=1; next}; i {print $1}'` )
380 # Scanning the partitions looking for CEPH OSDs and
381 # skipping any disk found with such partitions
382 for part_number in "${part_numbers[@]}"; do
383 sgdisk_part_info=$(flock $dev sgdisk -i $part_number $dev)
384 part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
385 if [ "$part_type_guid" == $CEPH_OSD_GUID ]; then
386 echo "OSD found on $dev, skipping wipe"
391 if [ "$wipe_dev" == "false" ]; then
396 # Add device to the wipe list
397 devname=$(basename $dev)
398 if [ -e $dev -a "$ISO_DEV" != "../../$devname" -a "$USB_DEV" != "../../$devname" ]; then
399 if [ -n "$WIPE_HDD" ]; then
400 WIPE_HDD=$WIPE_HDD,$dev
406 echo "Not in upgrade, wiping disks: $WIPE_HDD"
409 for dev in ${WIPE_HDD//,/ }
411 # Clearing previous GPT tables or LVM data
412 # Delete the first few bytes at the start and end of the partition. This is required with
413 # GPT partitions, they save partition info at the start and the end of the block.
414 # Do this for each partition on the disk, as well.
415 partitions=$(lsblk -rip $dev -o TYPE,NAME |awk '$1 == "part" {print $2}')
416 for p in $partitions $dev
418 echo "Pre-wiping $p from kickstart"
419 dd if=/dev/zero of=$p bs=512 count=34
420 dd if=/dev/zero of=$p bs=512 count=34 seek=$((`blockdev --getsz $p` - 34))
424 # Check for remaining cgts-vg PVs, which could potentially happen
425 # in an upgrade where we're not wiping all disks.
426 # If we ever create other volume groups from kickstart in the future,
427 # include them in this search as well.
428 partitions=$(pvs --select 'vg_name=cgts-vg' -o pv_name --noheading | grep -v '\[unknown\]')
431 echo "Pre-wiping $p from kickstart (cgts-vg present)"
432 dd if=/dev/zero of=$p bs=512 count=34
433 dd if=/dev/zero of=$p bs=512 count=34 seek=$((`blockdev --getsz $p` - 34))
436 let -i gb=1024*1024*1024
438 cat<<EOF>/tmp/part-include
439 clearpart --all --drives=$WIPE_HDD --initlabel
442 if [ -n "$ONLYUSE_HDD" ]; then
443 cat<<EOF>>/tmp/part-include
444 ignoredisk --only-use=$ONLYUSE_HDD
448 if [ -d /sys/firmware/efi ] ; then
449 cat<<EOF>>/tmp/part-include
450 part /boot/efi --fstype=efi --size=300 --ondrive=$(get_disk $boot_device)
453 cat<<EOF>>/tmp/part-include
454 part biosboot --asprimary --fstype=biosboot --size=1 --ondrive=$(get_disk $boot_device)
459 # Template from: pre_disk_aio.cfg
461 ## NOTE: updates to partition sizes need to be also reflected in
462 ## - stx-config/.../sysinv/conductor/manager.py:create_controller_filesystems()
463 ## - stx-config/.../sysinv/common/constants.py
465 ## NOTE: When adding partitions, we currently have a max of 4 primary partitions.
466 ## If more than 4 partitions are required, we can use a max of 3 --asprimary,
467 ## to allow 1 primary logical partition with extended partitions
469 ## NOTE: Max default PV size must align with the default controllerfs sizes
471 ## BACKUP_OVERHEAD = 20
473 ## Physical install (for disks over 240GB)
474 ## - DB size is doubled to allow for upgrades
476 ## DEFAULT_IMAGE_STOR_SIZE = 10
477 ## DEFAULT_DATABASE_STOR_SIZE = 20
478 ## DEFAULT_IMG_CONVERSION_STOR_SIZE = 20
479 ## BACKUP = DEFAULT_DATABASE_STOR_SIZE + DEFAULT_IMAGE_STOR_SIZE
480 ## + BACKUP_OVERHEAD = 50
481 ## LOG_VOL_SIZE = 8192
482 ## SCRATCH_VOL_SIZE = 8192
489 ## DOCKER_DIST = 16384
492 ## KUBELET_VOL_SIZE = 10240
493 ## RESERVED_PE = 16 (based on pesize=32768)
495 ## CGCS_PV_SIZE = 10240 + 2*20480 + 20480 + 51200 + 8196 + 8196 + 2048 +
496 ## 2048 + 1024 + 1024 + 5120 + 30720 + 16384 + 5120 +
497 ## 20480 + 10240 + 16 = 233496
499 ## small install - (for disks below 240GB)
500 ## - DB size is doubled to allow for upgrades
502 ## DEFAULT_SMALL_IMAGE_STOR_SIZE = 10
503 ## DEFAULT_SMALL_DATABASE_STOR_SIZE = 10
504 ## DEFAULT_SMALL_IMG_CONVERSION_STOR_SIZE = 10
505 ## DEFAULT_SMALL_BACKUP_STOR_SIZE = 40
507 ## LOG_VOL_SIZE = 8192
508 ## SCRATCH_VOL_SIZE = 8192
515 ## DOCKER_DIST = 16384
518 ## KUBELET_VOL_SIZE = 10240
519 ## RESERVED_PE = 16 (based on pesize=32768)
522 ## CGCS_PV_SIZE = 10240 + 2*10240 + 10240 + 40960 + 8192 + 8192 + 2048 +
523 ## 2048 + 1024 + 1024 + 5120 + 30720 + 16384 + 5120 +
524 ## 20480 + 10240 + 16 = 192528
526 ## NOTE: To maintain upgrade compatability within the volume group, keep the
527 ## undersized LOG_VOL_SIZE and SCRATCH_VOL_SIZE, but size the minimally size
528 ## physical volume correctly.
530 ## R4 AIO installations:
531 ## - R4 (case #1): /boot (0.5G), / (20G),
532 ## cgts-vg PV (239G), /local_pv (239G)
533 ## - R4 (case #2): /boot (0.5G), / (20G),
534 ## cgts-vg PV (239G), cgts-vg (239G)
536 ## Upgrade migration will start with R5 install and create a partition to align
537 ## above so filesystems within the volume group will be able to maintain their
539 ## - R5 install : /boot (0.5G), / (20G),
540 ## cgts-vg PV (142G), un-partitioned (336G)
541 ## - R5 (case #1): /boot (0.5G), / (20G),
542 ## cgts-vg PV (142G), cgts-vg PV (97G), unpartitioned (239G)
543 ## - R5 (case #2): /boot (0.5G), / (20G),
544 ## cgts-vg PV (142G), cgts-vg PV (336G)
547 sz=$(blockdev --getsize64 $(get_disk $rootfs_device))
548 if [ $sz -le $((240*$gb)) ] ; then
549 # Round CGCS_PV_SIZE to the closest upper value that can be divided by 1024.
550 # 192528/1024=188.01. CGCS_PV_SIZE=189*1024=193536. Using a disk with a
551 # size under 189GiB will fail.
554 # Round CGCS_PV_SIZE to the closest upper value that can be divided by 1024.
555 # 233496/1024=228.02. CGCS_PV_SIZE=229*1024=234496.
561 SCRATCH_VOL_SIZE=8000
563 ROOTFS_OPTIONS="defaults"
564 profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
565 if [ -n "$profile_mode" ]; then
566 # Enable iversion labelling for rootfs when IMA is enabled
567 ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
570 cat<<EOF>>/tmp/part-include
571 part /boot --fstype=ext4 --asprimary --size=500 --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
572 part pv.253004 --grow --size=500 --maxsize=$CGCS_PV_SIZE --ondrive=$(get_disk $rootfs_device)
573 volgroup cgts-vg --pesize=32768 pv.253004
574 logvol /var/log --fstype=ext4 --vgname=cgts-vg --size=$LOG_VOL_SIZE --name=log-lv
575 logvol /scratch --fstype=ext4 --vgname=cgts-vg --size=$SCRATCH_VOL_SIZE --name=scratch-lv
576 part / --fstype=ext4 --asprimary --size=$ROOTFS_SIZE --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
582 # Template from: post_platform_conf_aio_lowlatency.cfg
585 # Source common functions
586 . /tmp/ks-functions.sh
588 # Set the security profile mode
589 secprofile="standard"
590 profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
591 if [ -n "$profile_mode" ]; then
592 secprofile="extended"
595 mkdir -p -m 0775 /etc/platform
596 cat <<EOF > /etc/platform/platform.conf
598 subfunction=controller,worker,lowlatency
599 system_type=All-in-one
600 security_profile=$secprofile
606 # Template from: post_common.cfg
609 # Source common functions
610 . /tmp/ks-functions.sh
612 # Turn off locale support for i18n if is not installed
613 if [ ! -d /usr/share/i18n ] ; then
614 rm -f /etc/sysconfig/i18n
619 # If using a serial install make sure to add a getty on the tty1
620 conarg=`cat /proc/cmdline |xargs -n1 echo |grep console= |grep ttyS`
621 if [ -n "$conarg" ] ; then
622 echo "1:2345:respawn:/sbin/mingetty tty1" >> /etc/inittab
625 #### SECURITY PROFILE HANDLING (Post Installation) ####
626 # Check if the Security profile mode is enabled
627 # and load the appropriate kernel modules
628 secprofile=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
629 if [ -n "$secprofile" ]; then
630 echo "In Extended Security profile mode. Loading IMA kernel module"
631 systemctl enable auditd.service
632 # Add the securityfs mount for the IMA Runtime measurement list
633 echo "securityfs /sys/kernel/security securityfs defaults,nodev 0 0" >> /etc/fstab
635 # Disable audit daemon in the Standard Security Profile
636 systemctl disable auditd
639 . /etc/platform/platform.conf
640 # Configure smart package manager channels
641 rm -rf /var/lib/smart
643 /usr/bin/smart channel -y \
644 --add rpmdb type=rpm-sys name="RPM Database"
645 /usr/bin/smart channel -y \
646 --add base type=rpm-md name="Base" baseurl=http://controller:${http_port:-8080}/feed/rel-19.12
647 /usr/bin/smart channel -y \
648 --add updates type=rpm-md name="Patches" baseurl=http://controller:${http_port:-8080}/updates/rel-19.12
650 # Configure smart to use rpm --nolinktos option
651 /usr/bin/smart config --set rpm-nolinktos=true
653 # Configure smart to use rpm --nosignature option
654 /usr/bin/smart config --set rpm-check-signatures=false
656 # Delete the CentOS yum repo files
657 rm -f /etc/yum.repos.d/CentOS-*
659 # Persist the boot device naming as UDEV rules so that if the network device
660 # order changes post-install that we will still be able to DHCP from the
661 # correct interface to reach the active controller. For most nodes only the
662 # management/boot interface needs to be persisted but because we require both
663 # controllers to be identically configured and controller-0 and controller-1
664 # are installed differently (e.g., controller-0 from USB and controller-1 from
665 # network) it is not possible to know which interface to persist for
666 # controller-0. The simplest solution is to persist all interfaces.
668 mkdir -p /etc/udev/rules.d
669 echo "# Persisted network interfaces from anaconda installer" > /etc/udev/rules.d/70-persistent-net.rules
670 for dir in /sys/class/net/*; do
671 if [ -e ${dir}/device ]; then
672 dev=$(basename ${dir})
673 mac_address=$(cat /sys/class/net/${dev}/address)
674 echo "ACTION==\"add\", SUBSYSTEM==\"net\", DRIVERS==\"?*\", ATTR{address}==\"${mac_address}\", NAME=\"${dev}\"" >> /etc/udev/rules.d/70-persistent-net.rules
678 # Mark the sysadmin password as expired immediately
681 # Lock the root password
684 # Enable tmpfs mount for /tmp
685 # delete /var/tmp so that it can similinked in
687 systemctl enable tmp.mount
689 # Disable automount of /dev/hugepages
690 systemctl mask dev-hugepages.mount
693 systemctl disable firewalld
696 systemctl disable libvirtd.service
699 systemctl enable rsyncd.service
701 # Allow root to run sudo from a non-tty (for scripts running as root that run sudo cmds)
702 echo 'Defaults:root !requiretty' > /etc/sudoers.d/root
704 # Make fstab just root read/writable
707 # Create first_boot flag
708 touch /etc/platform/.first_boot
712 # Template from: post_kernel_aio_and_worker.cfg
715 # Source common functions
716 . /tmp/ks-functions.sh
718 # Source the generated platform.conf
719 . /etc/platform/platform.conf
721 # Update grub with custom kernel bootargs
722 source /etc/init.d/cpumap_functions.sh
723 n_cpus=$(cat /proc/cpuinfo 2>/dev/null | \
724 awk '/^[pP]rocessor/ { n +=1 } END { print (n>0) ? n : 1}')
725 n_numa=$(ls -d /sys/devices/system/node/node* 2>/dev/null | wc -l)
726 KERN_OPTS=" iommu=pt usbcore.autosuspend=-1"
728 KERN_OPTS="${KERN_OPTS} hugepagesz=2M hugepages=0 default_hugepagesz=2M"
730 # If this is an all-in-one system, we need at least 4 CPUs
731 if [ "$system_type" = "All-in-one" -a ${n_cpus} -lt 4 ]; then
732 report_post_failure_with_msg "ERROR: At least 4 CPUs are required for controller+worker node."
735 # Add kernel options for cpu isolation / affinity
736 if [ ${n_cpus} -gt 1 ]
738 base_cpulist=$(platform_expanded_cpu_list)
739 base_cpumap=$(cpulist_to_cpumap ${base_cpulist} ${n_cpus})
740 avp_cpulist=$(vswitch_expanded_cpu_list)
741 norcu_cpumap=$(invert_cpumap ${base_cpumap} ${n_cpus})
742 norcu_cpulist=$(cpumap_to_cpulist ${norcu_cpumap} ${n_cpus})
744 if [[ "$subfunction" =~ lowlatency ]]; then
745 KERN_OPTS="${KERN_OPTS} isolcpus=${norcu_cpulist}"
746 KERN_OPTS="${KERN_OPTS} nohz_full=${norcu_cpulist}"
748 KERN_OPTS="${KERN_OPTS} isolcpus=${avp_cpulist}"
750 KERN_OPTS="${KERN_OPTS} rcu_nocbs=${norcu_cpulist}"
751 KERN_OPTS="${KERN_OPTS} kthread_cpus=${base_cpulist}"
752 KERN_OPTS="${KERN_OPTS} irqaffinity=${base_cpulist}"
753 # Update vswitch.conf
754 sed -i "s/^VSWITCH_CPU_LIST=.*/VSWITCH_CPU_LIST=\"${avp_cpulist}\"/" /etc/vswitch/vswitch.conf
757 # Add kernel options to ensure an selinux is disabled
758 KERN_OPTS="${KERN_OPTS} selinux=0 enforcing=0"
760 # Add kernel options to set NMI watchdog
761 if [[ "$subfunction" =~ lowlatency ]]; then
762 KERN_OPTS="${KERN_OPTS} nmi_watchdog=0 softlockup_panic=0"
764 KERN_OPTS="${KERN_OPTS} nmi_watchdog=panic,1 softlockup_panic=1"
767 if [[ "$(dmidecode -s system-product-name)" =~ ^ProLiant.*Gen8$ ]]; then
768 KERN_OPTS="${KERN_OPTS} intel_iommu=on,eth_no_rmrr"
770 KERN_OPTS="${KERN_OPTS} intel_iommu=on"
773 # Add kernel option to disable biosdevname if enabled
774 # As this may already be in GRUB_CMDLINE_LINUX, only add if it is not already present
775 grep -q '^GRUB_CMDLINE_LINUX=.*biosdevname=0' /etc/default/grub
776 if [ $? -ne 0 ]; then
777 KERN_OPTS="${KERN_OPTS} biosdevname=0"
780 # Add kernel options to disable kvm-intel.eptad on Broadwell
781 # Broadwell: Model: 79, Model name: Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
782 if grep -q -E "^model\s+:\s+79$" /proc/cpuinfo
784 KERN_OPTS="${KERN_OPTS} kvm-intel.eptad=0"
788 #KERN_OPTS="${KERN_OPTS} cgroup_disable=memory"
789 KERN_OPTS="${KERN_OPTS} user_namespace.enable=1"
791 # Add kernel option to avoid jiffies_lock contention on real-time kernel
792 if [[ "$subfunction" =~ lowlatency ]]; then
793 KERN_OPTS="${KERN_OPTS} skew_tick=1"
796 # If the installer asked us to use security related kernel params, use
797 # them in the grub line as well (until they can be configured via puppet)
798 grep -q 'nopti' /proc/cmdline
799 if [ $? -eq 0 ]; then
800 KERN_OPTS="${KERN_OPTS} nopti"
802 grep -q 'nospectre_v2' /proc/cmdline
803 if [ $? -eq 0 ]; then
804 KERN_OPTS="${KERN_OPTS} nospectre_v2"
807 perl -pi -e 's/(GRUB_CMDLINE_LINUX=.*)\"/\1'"$KERN_OPTS"'\"/g' /etc/default/grub
809 if [ -d /sys/firmware/efi ] ; then
810 grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
812 grub2-mkconfig -o /boot/grub2/grub.cfg
818 # Template from: post_lvm_pv_on_rootfs.cfg
821 # Source common functions
822 . /tmp/ks-functions.sh
824 # uncomment the global_filter line in lvm.conf
825 perl -0777 -i.bak -pe 's:(# This configuration option has an automatic default value\.\n)\t# global_filter:$1 global_filter:m' /etc/lvm/lvm.conf
827 # Determine which disk we created our PV on (i.e. the root disk)
828 ROOTDISK=$(get_by_path $(pvdisplay --select 'vg_name=cgts-vg' -C -o pv_name --noheadings))
829 if [ -z "$ROOTDISK" ]; then
830 report_post_failure_with_msg "ERROR: failed to identify rootdisk via pvdisplay"
832 # Edit the LVM config so LVM only looks for LVs on the root disk
833 sed -i "s#^\( *\)global_filter = \[.*#\1global_filter = [ \"a|${ROOTDISK}|\", \"r|.*|\" ]#" /etc/lvm/lvm.conf
837 # Template from: post_system_aio.cfg
840 # Source common functions
841 . /tmp/ks-functions.sh
843 # Source the generated platform.conf
844 . /etc/platform/platform.conf
846 ## Reserve more memory for base processes since the controller has higher
847 ## memory requirements but cap it to better handle systems with large
849 TOTALMEM=$(grep MemTotal /proc/meminfo | awk '{print int($2/1024)}')
851 if [ -e /sys/devices/system/node/node0 ]; then
852 RESERVEDMEM=$(grep MemTotal /sys/devices/system/node/node0/meminfo | awk '{printf "%d\n", $4/1024}')
854 RESERVEDMEM=$(grep MemTotal /proc/meminfo | awk '{print int($2/1024/4)}')
857 if [ ${RESERVEDMEM} -lt 6144 ]; then
859 elif [ ${RESERVEDMEM} -gt 14500 ]; then
861 elif [ ${RESERVEDMEM} -gt 8192 ]; then
865 sed -i -e "s#\(WORKER_BASE_RESERVED\)=.*#\1=(\"node0:${RESERVEDMEM}MB:1\" \"node1:2000MB:0\" \"node2:2000MB:0\" \"node3:2000MB:0\")#g" /etc/platform/worker_reserved.conf
867 # Update WORKER_CPU_LIST
868 N_CPUS=$(cat /proc/cpuinfo 2>/dev/null | awk '/^[pP]rocessor/ { n +=1 } END { print (n>0) ? n : 1}')
869 sed -i "s/^WORKER_CPU_LIST=.*/WORKER_CPU_LIST=\"0-$((N_CPUS-1))\"/" /etc/platform/worker_reserved.conf
874 # Template from: post_usb_controller.cfg
877 # Source common functions
878 . /tmp/ks-functions.sh
880 if [ -d /mnt/install/source ]; then
881 srcdir=/mnt/install/source
883 srcdir=/run/install/repo
886 touch /tmp/repo-include
888 if [ -d ${srcdir}/patches ]; then
889 echo "repo --name=updates --baseurl=file://${srcdir}/patches/" > /tmp/repo-include
894 # Repository arguments from %pre
895 %include /tmp/repo-include
899 # Source common functions
900 . /tmp/ks-functions.sh
904 # Persist the boot device to the platform configuration. This will get
905 # overwritten when config_controller is run.
906 echo management_interface=$mgmt_dev >> /etc/platform/platform.conf
908 # persist the default http port number to platform configuration. This
909 # will get overwritten when config_controller is run.
910 echo http_port=8080 >> /etc/platform/platform.conf
912 # Build networking scripts
913 cat << EOF > /etc/sysconfig/network-scripts/ifcfg-lo
918 BROADCAST=127.255.255.255
927 # Note, this section is different and replaced with a wget
928 # if doing the initial install off the network
930 if [ -d /mnt/install/source ]; then
931 srcdir=/mnt/install/source
933 srcdir=/run/install/repo
936 if [ -d $srcdir/Packages ] ; then
937 mkdir -p /mnt/sysimage/www/pages/feed/rel-19.12
938 cp -r $srcdir/Packages /mnt/sysimage/www/pages/feed/rel-19.12/Packages
939 cp -r $srcdir/repodata /mnt/sysimage/www/pages/feed/rel-19.12/repodata
940 cp $srcdir/*.cfg /mnt/sysimage/www/pages/feed/rel-19.12
943 if [ -d $srcdir/patches ]; then
944 mkdir -p /mnt/sysimage/www/pages/updates/rel-19.12
945 cp -r $srcdir/patches/Packages /mnt/sysimage/www/pages/updates/rel-19.12/Packages
946 cp -r $srcdir/patches/repodata /mnt/sysimage/www/pages/updates/rel-19.12/repodata
947 mkdir -p /mnt/sysimage/opt/patching
948 cp -r $srcdir/patches/metadata /mnt/sysimage/opt/patching/metadata
949 mkdir -p /mnt/sysimage/opt/patching/packages/19.12
951 find /mnt/sysimage/www/pages/updates/rel-19.12/Packages -name '*.rpm' \
952 | xargs --no-run-if-empty -I files cp --preserve=all files /mnt/sysimage/opt/patching/packages/19.12/
955 # Create a uuid specific to this installation
956 INSTALL_UUID=`uuidgen`
957 echo $INSTALL_UUID > /mnt/sysimage/www/pages/feed/rel-19.12/install_uuid
958 echo "INSTALL_UUID=$INSTALL_UUID" >> /mnt/sysimage/etc/platform/platform.conf
963 # This is a USB install, so set ONBOOT=yes for network devices.
964 # Doing this in the %post so we don't unintentionally setup a
965 # network device during the installation.
966 for f in /etc/sysconfig/network-scripts/ifcfg-*; do
967 if grep -q '^ONBOOT=' ${f}; then
968 sed -i 's/^ONBOOT=.*/ONBOOT=yes/' ${f}
970 echo "ONBOOT=yes" >> ${f}
972 if grep -q '^IPV6_AUTOCONF=' ${f}; then
973 sed -i 's/^IPV6_AUTOCONF=.*/IPV6_AUTOCONF=no/' ${f}
975 echo "IPV6_AUTOCONF=no" >> ${f}
982 # Template from: post_usb_addon.cfg
984 if [ -d /mnt/install/source ]; then
985 srcdir=/mnt/install/source
987 srcdir=/run/install/repo
990 if [ -f ${srcdir}/ks-addon.cfg ]; then
991 cp ${srcdir}/ks-addon.cfg /tmp/
993 cat <<EOF > /tmp/ks-addon.cfg
994 # No custom addon included
1000 if [ -d /mnt/install/source ]; then
1001 srcdir=/mnt/install/source
1003 srcdir=/run/install/repo
1006 # Store the ks-addon.cfg for debugging
1007 mkdir -p /mnt/sysimage/var/log/anaconda
1008 cp /tmp/ks-addon.cfg /mnt/sysimage/var/log/anaconda/
1013 # Source common functions
1014 . /tmp/ks-functions.sh
1016 %include /tmp/ks-addon.cfg