From e1a109d0a15b8c08d435dfeb5f06c8817e0eaacf Mon Sep 17 00:00:00 2001 From: Trevor Batley Date: Thu, 7 Nov 2024 08:35:21 +1100 Subject: [PATCH] a bit of a tidy-up + ks_netinstall.cfg --- ks.cfg | 36 ++++-- ks_netinstall.cfg | 295 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 319 insertions(+), 12 deletions(-) create mode 100644 ks_netinstall.cfg diff --git a/ks.cfg b/ks.cfg index 89b46d3..5d681f5 100644 --- a/ks.cfg +++ b/ks.cfg @@ -1,5 +1,6 @@ -# System authorization information -#auth --enableshadow --passalgo=sha512 +# default keyboard and language +keyboard 'us' +lang en_US.UTF-8 # We do not want SELinux selinux --permissive @@ -23,22 +24,22 @@ eula --agreed %end # Start network -#network --bootproto=dhcp +#network --bootproto=dhcp --device=link --activate # Install from the cdrom cdrom # Add netinstall repos -#this one gives curl 6 errors on netinstall while added manually works from time to time +#repo --name="smeos" --baseurl=https://koji.koozali.org/kojifiles/repos-dist/smeserver11/latest/$basearch +#repo --name="rockybase" --baseurl=https://dl.rockylinux.org/pub/rocky/8/BaseOS/$basearch/os/ +#repo --name="rockyappstream" --baseurl=https://dl.rockylinux.org/pub/rocky/8/AppStream/$basearch/os/ +#repo --name="rockypowertools" --baseurl=http://dl.rockylinux.org/pub/rocky/8/PowerTools/$basearch/os/ --cost=200 +#repo --name="rockyextras" --baseurl=http://dl.rockylinux.org/pub/rocky/8/extras/$basearch/os --cost=200 +#repo --name="epel" --baseurl=https://dl.fedoraproject.org/pub/epel/8/Everything/$basearch/ + +# Base URL for netinstall #url --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeos-11-x86_64 -#repo --name=smeos --baseurl=https://koji.koozali.org/kojifiles/repos-dist/smeserver11/latest/$basearch #url --url=https://koji.koozali.org/kojifiles/repos-dist/smeserver11/latest/$basearch -#repo --name=rocky8base --baseurl=https://dl.rockylinux.org/pub/rocky/8/BaseOS/$basearch/os/ -#url --url=https://dl.rockylinux.org/pub/rocky/8/BaseOS/$basearch/os/ -#repo --name=rocky8app --baseurl=https://dl.rockylinux.org/pub/rocky/8/AppStream/$basearch/os/ -#url --url=https://dl.rockylinux.org/pub/rocky/8/AppStream/$basearch/os/ -#repo --name=smeos --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeos-11-x86_64 -#repo --name=smeupdates --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeupdates-11-x86_64 # Packages to install %packages @@ -46,7 +47,18 @@ dracut-live @^smeserver-environment @core @baseos -#@minimal +@^minimal +anaconda +anaconda-install-env-deps +anaconda-live +chkconfig +glibc-all-langpacks +initscripts +kernel +kernel-modules +kernel-modules-extra +memtest86+ +syslinux -chrony -kexec-tools %end diff --git a/ks_netinstall.cfg b/ks_netinstall.cfg new file mode 100644 index 0000000..dd66514 --- /dev/null +++ b/ks_netinstall.cfg @@ -0,0 +1,295 @@ +# default keyboard and language +keyboard 'us' +lang en_US.UTF-8 + +# We do not want SELinux +selinux --permissive + +# Services to activate +services --enabled=NetworkManager +services --disabled=lm_sensors + +# Default root pass, will be changed in post-install process anyway +rootpw --lock +user --name=installer --uid=9999 + +# Accept EULA +eula --agreed + +# Partitioning from pre section +%include /tmp/part-include + +# Disable kdump +%addon com_redhat_kdump --disable +%end + +# Start network +network --bootproto=dhcp --device=link --activate + +# Add netinstall repos +repo --name="smeos" --baseurl=https://koji.koozali.org/kojifiles/repos-dist/smeserver11/latest/$basearch +repo --name="rockybase" --baseurl=https://dl.rockylinux.org/pub/rocky/8/BaseOS/$basearch/os/ +repo --name="rockyappstream" --baseurl=https://dl.rockylinux.org/pub/rocky/8/AppStream/$basearch/os/ +repo --name="rockypowertools" --baseurl=http://dl.rockylinux.org/pub/rocky/8/PowerTools/$basearch/os/ --cost=200 +repo --name="rockyextras" --baseurl=http://dl.rockylinux.org/pub/rocky/8/extras/$basearch/os --cost=200 +repo --name="epel" --baseurl=https://dl.fedoraproject.org/pub/epel/8/Everything/$basearch/ + +# Base URL for netinstall +#url --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeos-11-x86_64 +url --url=https://koji.koozali.org/kojifiles/repos-dist/smeserver11/latest/$basearch + +# Packages to install +%packages +dracut-live +@^smeserver-environment +@core +@baseos +@^minimal +anaconda +anaconda-install-env-deps +anaconda-live +chkconfig +glibc-all-langpacks +initscripts +kernel +kernel-modules +kernel-modules-extra +memtest86+ +syslinux +-chrony +-kexec-tools +%end + + +# Partitioning in pre-install +%pre --interpreter=/bin/bash --log=/var/log/sme-partitioning.log + +# Read command line arguments +if grep nolvm "/proc/cmdline" ; then NOLVM=true ; fi +if grep noraid "/proc/cmdline" ; then NORAID=true ; fi +if grep noxfs "/proc/cmdline" ; then FSTYPE="ext4" ; else FSTYPE="xfs" ; fi +echo "Command line arguments:" +cat /proc/cmdline + +# Minimum size of hard drive needed specified in MB +MINSIZE=5000 + +# Number of detected drives and first disk size +NDEV=0 +BASESIZE=0 +SIZEDIFF=0 + +# Loop through block devices, keep those over MINSIZE and ensure additional drives for RAID are within 100MB of the first +for DEV in $(lsblk -nl | grep disk | cut -d' ' -f1) ; do + if [ -d /sys/block/$DEV ] ; then + REMOVABLE=`cat /sys/block/$DEV/removable` + if (( $REMOVABLE == 0 )) ; then + SIZE=`cat /sys/block/$DEV/size` + MB=$(($SIZE/2**11)) + if [ $MB -gt $MINSIZE ] ; then + if [ $NDEV == 0 ] ; then + echo "First drive found: $DEV with size $MB MB" + DRIVES[$NDEV]=$DEV + BASESIZE=$MB + ((NDEV++)) + else + SIZEDIFF=$(($MB-$BASESIZE)) + if [ $SIZEDIFF -gt 100 ] || [ $SIZEDIFF -lt -100 ] ; then + echo "Drive found but size of $MB MB doesn't match $BASESIZE MB - ignoring" + else + echo "Additional drive found: $DEV with size $MB MB" + DRIVES[$NDEV]=$DEV + ((NDEV++)) + fi + fi + fi + fi + fi +done +echo "Total disks found: $NDEV" + +# Calculate recommended swap size for RAID + nolvm case +if [ -d /sys/firmware/efi ] ; then + DISKSPARE=$(($BASESIZE-200-500-3000)) +else + DISKSPARE=$(($BASESIZE-1-500-3000)) +fi +MEMSIZE=$(awk '/^MemTotal:/{print $2}' /proc/meminfo) +MEMSIZEMB=$(($MEMSIZE/2**10)) + +if [ $MEMSIZEMB -lt 2000 ] ; then + SWAPSIZE=$((2*$MEMSIZEMB)) +elif [ $MEMSIZEMB -lt 8000 ] ; then + SWAPSIZE=$MEMSIZEMB +else + SWAPSIZE=8000 +fi +if [ $SWAPSIZE -gt $DISKSPARE ] ; then SWAPSIZE=$DISKSPARE ; fi + +# Declare useful variables +printf -v DRIVELIST ",%s" "${DRIVES[@]}" +if [ $NORAID ] ; then + DRIVELIST=${DRIVES[0]} +else + DRIVELIST=${DRIVELIST:1} +fi + +echo "Final drive list: $DRIVELIST" +LEVEL=1 +SPARE=0 + + +# Error if detection has failed and fall back +if [ ${#DRIVES[@]} == 0 ] ; then + echo "No drive suitable for installation found! Reverting to Anaconda defaults." + + cat > /tmp/part-include < /tmp/part-include <> /tmp/part-include + elif [ $BASESIZE -gt 2048000 ] ; then + printf "part biosboot --fstype=biosboot --size=1 --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include + fi + + # Create boot partition + printf "part /boot --fstype=%s --size=500 --label=BOOT --ondisk=%s\n" "$FSTYPE" "${DRIVES[0]}" >> /tmp/part-include + + # Default to LVM unless specified at command line + if [ $NOLVM ] ; then + cat >> /tmp/part-include <> /tmp/part-include <> /tmp/part-include + elif [ $BASESIZE -gt 2048000 ] ; then + printf "part biosboot --fstype=biosboot --size=1 --ondisk=%s\n" "${DRIVES[$i]}" >> /tmp/part-include + fi + printf "part raid.%s1 --size=500 --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include + + # Default to LVM unless specified + if [ $NOLVM ] ; then + printf "part raid.%s2 --size=3000 --grow --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include + printf "part raid.%s3 --size=%s --ondisk=%s\n" "$i" "$SWAPSIZE" "${DRIVES[$i]}" >> /tmp/part-include + else + printf "part raid.%s2 --size=4300 --grow --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include + fi + + done + + # Compute RAID level + # from https://wiki.contribs.org/Raid + # 2 Drives - Software RAID 1 + # 3 Drives - Software RAID 1 + 1 Hot-spare + # 4 Drives - Software RAID 6 + # 5+ Drives - Software RAID 6 + 1 Hot-spare + + if [ ${#DRIVES[@]} == 2 ] ; then + LEVEL=1 + SPARE=0 + elif [ ${#DRIVES[@]} == 3 ] ; then + LEVEL=1 + SPARE=1 + elif [ ${#DRIVES[@]} == 4 ] ; then + LEVEL=6 + SPARE=0 + else + LEVEL=6 + SPARE=1 + fi + + # Set up RAID devices + printf -v EFIDEVS "raid.%s0 " "${!DRIVES[@]}" + printf -v BOOTDEVS "raid.%s1 " "${!DRIVES[@]}" + printf -v ROOTDEVS "raid.%s2 " "${!DRIVES[@]}" + printf -v SWAPDEVS "raid.%s3 " "${!DRIVES[@]}" + + # Include the EFI partition if necessary + if [ -d /sys/firmware/efi ] ; then + printf "raid /boot/efi --fstype=efi --level=1 --spares=0 --device=md9 %s\n" "$EFIDEVS" >> /tmp/part-include + fi + + # Boot partition + printf "raid /boot --fstype=%s --level=1 --spares=0 --device=md0 %s\n" "$FSTYPE" "$BOOTDEVS" >> /tmp/part-include + + # Default to LVM unless specified + if [ $NOLVM ] ; then + cat >> /tmp/part-include <> /tmp/part-include <