--- cdrom.image/sme10/Packages/base/sme-kickstart.cfg 2021/01/31 00:15:05 1.7 +++ cdrom.image/sme10/Packages/base/sme-kickstart.cfg 2021/06/09 07:04:49 1.14 @@ -23,8 +23,11 @@ eula --agreed # Add netinstall repos -repo --name=smeos --baseurl=http://mirror.canada.pialasse.com/releases/testing/10/smeos/x86_64/ -repo --name=smeupdates --baseurl=http://mirror.canada.pialasse.com/releases/testing/10/smeupdates/x86_64/ +#this one gives curl 6 errors on netinstall while added manually works from time to time +#url --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeos-10-x86_64 +#repo --name=smeupdates --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeupdates-10-x86_64 +repo --name=smeos --baseurl http://distro.ibiblio.org/pub/linux/distributions/smeserver/releases/10/smeos/x86_64/ +repo --name=smeupdates --baseurl http://distro.ibiblio.org/pub/linux/distributions/smeserver/releases/testing/10/smeupdates/x86_64/ # Packages to install %packages @@ -37,36 +40,83 @@ repo --name=smeupdates --baseurl=http:// # Partitioning in pre-install -%pre --interpreter=/bin/bash --log=/var/log/ks.pre01.log +%pre --interpreter=/bin/bash --log=/var/log/sme-partitioning.log -# Minimum size of hard drive needed specified in GB -MINSIZE=5 +# 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 -# Number of detected drives +# 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 and keep those over MINSIZE -# TODO: Only pair up drives of the same size -for DEV in $(lsblk -nl | grep disk | cut -d' ' -f1); do - if [ -d /sys/block/$DEV ]; then +# 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 + if (( $REMOVABLE == 0 )) ; then SIZE=`cat /sys/block/$DEV/size` - GB=$(($SIZE/2**21)) - if [ $GB -gt $MINSIZE ]; then - DRIVES[$NDEV]=$DEV - ((NDEV++)) + 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[@]}" -DRIVELIST=${DRIVELIST:1} +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." @@ -94,33 +144,56 @@ else bootloader --location=mbr --driveorder=$DRIVELIST EOF - # If single disk then set up partitioning without RAID + # If single disk or noraid specific then set up partitioning without RAID # NOTE: From this point we're appending to part-include - if [ ${#DRIVES[@]} == 1 ] ; then + if [ ${#DRIVES[@]} == 1 ] || [ $NORAID ] ; then - # Include the EFI partition if necessary + # Include the EFI or biosboot partition if necessary if [ -d /sys/firmware/efi ] ; then printf "part /boot/efi --fstype=efi --size=200 --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include + elif [ $BASESIZE -gt 2048000 ] ; then + printf "part biosboot --fstype=biosboot --size=1 --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include fi - cat >> /tmp/part-include <> /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 - printf "part raid.%s2 --size=4300 --grow --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 @@ -148,25 +221,36 @@ EOF 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 - printf "raid /boot --fstype=xfs --level=1 --spares=0 --device=md0 %s\n" "$BOOTDEVS" >> /tmp/part-include - printf "raid pv.01 --level=%s --spares=%s --device=md1 %s\n" "$LEVEL" "$SPARE" "$ROOTDEVS" >> /tmp/part-include + # Boot partition + printf "raid /boot --fstype=%s --level=1 --spares=0 --device=md0 %s\n" "$FSTYPE" "$BOOTDEVS" >> /tmp/part-include - # Set up LVM - cat >> /tmp/part-include <> /tmp/part-include <> /tmp/part-include <