/[smeserver]/cdrom.image/sme10/netinstall/ks.cfg
ViewVC logotype

Annotation of /cdrom.image/sme10/netinstall/ks.cfg

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (hide annotations) (download)
Thu Mar 18 22:20:46 2021 UTC (3 years, 2 months ago) by chrissn
Branch: MAIN
Changes since 1.5: +113 -32 lines
* Thu Mar 18 2021 Chris Sansom-Ninnes <chris@sansom.ninnes.net>
- Add support for >2TB BIOS drives [SME:11456]
- Add support for nolvm and noraid command line arguments [SME:11381]

1 jpp 1.1 # System authorization information
2     auth --enableshadow --passalgo=sha512
3    
4 chrissn 1.2 # We do not want SELinux
5 jpp 1.1 selinux --disabled
6    
7 chrissn 1.2 # Services to activate
8 jpp 1.1 services --disabled=lm_sensors
9    
10 chrissn 1.2 # Default root pass, will be changed in post-install process anyway
11     rootpw --lock
12 chrissn 1.4 user --name=installer --uid=9999
13 jpp 1.1
14 chrissn 1.2 # Accept EULA
15 jpp 1.1 eula --agreed
16    
17 chrissn 1.2 # Partitioning from pre section
18 jpp 1.1 %include /tmp/part-include
19    
20 chrissn 1.2 # Disable kdump
21 jpp 1.1 %addon com_redhat_kdump --disable
22     %end
23    
24 chrissn 1.2
25     # Add netinstall repos
26 chrissn 1.3 url --url https://mirror.canada.pialasse.com/releases/testing/10/smeos/x86_64/
27 jpp 1.1 repo --name=smeupdates --baseurl=https://mirror.canada.pialasse.com/releases/testing/10/smeupdates/x86_64/
28    
29 chrissn 1.2 # Packages to install
30     %packages
31     @^minimal
32     @base
33     @core
34     -chrony
35     -kexec-tools
36     %end
37    
38    
39     # Partitioning in pre-install
40 chrissn 1.6 %pre --interpreter=/bin/bash --log=/var/log/sme-partitioning.log
41 chrissn 1.2
42 chrissn 1.6 # Read command line arguments
43     if grep nolvm "/proc/cmdline" ; then NOLVM=true ; fi
44     if grep noraid "/proc/cmdline" ; then NORAID=true ; fi
45     echo "Command line arguments:"
46     cat /proc/cmdline
47 jpp 1.1
48 chrissn 1.6 # Minimum size of hard drive needed specified in MB
49     MINSIZE=5000
50    
51     # Number of detected drives and first disk size
52 jpp 1.1 NDEV=0
53 chrissn 1.6 BASESIZE=0
54     SIZEDIFF=0
55 jpp 1.1
56 chrissn 1.6 # Loop through block devices, keep those over MINSIZE and ensure additional drives for RAID are within 100MB of the first
57     for DEV in $(lsblk -nl | grep disk | cut -d' ' -f1) ; do
58     if [ -d /sys/block/$DEV ] ; then
59 jpp 1.1 REMOVABLE=`cat /sys/block/$DEV/removable`
60 chrissn 1.6 if (( $REMOVABLE == 0 )) ; then
61 jpp 1.1 SIZE=`cat /sys/block/$DEV/size`
62 chrissn 1.6 MB=$(($SIZE/2**11))
63     if [ $MB -gt $MINSIZE ] ; then
64     if [ $NDEV == 0 ] ; then
65     echo "First drive found: $DEV with size $MB MB"
66     DRIVES[$NDEV]=$DEV
67     BASESIZE=$MB
68     ((NDEV++))
69     else
70     SIZEDIFF=$(($MB-$BASESIZE))
71     if [ $SIZEDIFF -gt 100 ] || [ $SIZEDIFF -lt -100 ] ; then
72     echo "Drive found but size of $MB MB doesn't match $BASESIZE MB - ignoring"
73     else
74     echo "Additional drive found: $DEV with size $MB MB"
75     DRIVES[$NDEV]=$DEV
76     ((NDEV++))
77     fi
78     fi
79 jpp 1.1 fi
80     fi
81     fi
82     done
83 chrissn 1.6 echo "Total disks found: $NDEV"
84    
85     # Calculate recommended swap size for RAID + nolvm case
86     if [ -d /sys/firmware/efi ] ; then
87     DISKSPARE=$(($BASESIZE-200-500-3000))
88     else
89     DISKSPARE=$(($BASESIZE-1-500-3000))
90     fi
91     MEMSIZE=$(awk '/^MemTotal:/{print $2}' /proc/meminfo)
92     MEMSIZEMB=$(($MEMSIZE/2**10))
93    
94     if [ $MEMSIZEMB -lt 2000 ] ; then
95     SWAPSIZE=$((2*$MEMSIZEMB))
96     elif [ $MEMSIZEMB -lt 8000 ] ; then
97     SWAPSIZE=$MEMSIZEMB
98     else
99     SWAPSIZE=8000
100     fi
101     if [ $SWAPSIZE -gt $DISKSPARE ] ; then SWAPSIZE=$DISKSPARE ; fi
102 jpp 1.1
103 chrissn 1.2 # Declare useful variables
104     printf -v DRIVELIST ",%s" "${DRIVES[@]}"
105 chrissn 1.6 if [ $NORAID ] ; then
106     DRIVELIST=${DRIVES[0]}
107     else
108     DRIVELIST=${DRIVELIST:1}
109     fi
110    
111     echo "Final drive list: $DRIVELIST"
112 chrissn 1.2 LEVEL=1
113     SPARE=0
114    
115 chrissn 1.6
116 chrissn 1.2 # Error if detection has failed and fall back
117     if [ ${#DRIVES[@]} == 0 ] ; then
118     echo "No drive suitable for installation found! Reverting to Anaconda defaults."
119    
120     cat > /tmp/part-include <<EOF
121     # Clear the Master Boot Record
122     zerombr
123    
124     # Clear current partitions
125     clearpart --all --initlabel
126 jpp 1.1
127 chrissn 1.2 # Automatically create partitions using LVM
128     autopart --lvm --nohome
129 jpp 1.1 EOF
130    
131 chrissn 1.2 # Otherwise clear detected devices and set up bootloader
132 jpp 1.1 else
133 chrissn 1.2 cat > /tmp/part-include <<EOF
134     # Clear the Master Boot Record
135     zerombr
136    
137     # Clear current partitions and install bootloader
138     clearpart --all --drives=$DRIVELIST --initlabel
139     ignoredisk --only-use=$DRIVELIST
140     bootloader --location=mbr --driveorder=$DRIVELIST
141     EOF
142    
143 chrissn 1.6 # If single disk or noraid specific then set up partitioning without RAID
144 chrissn 1.2 # NOTE: From this point we're appending to part-include
145 chrissn 1.6 if [ ${#DRIVES[@]} == 1 ] || [ $NORAID ] ; then
146 chrissn 1.2
147 chrissn 1.6 # Include the EFI or biosboot partition if necessary
148 chrissn 1.2 if [ -d /sys/firmware/efi ] ; then
149     printf "part /boot/efi --fstype=efi --size=200 --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include
150 chrissn 1.6 elif [ $BASESIZE -gt 2048000 ] ; then
151     printf "part biosboot --fstype=biosboot --size=1 --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include
152 chrissn 1.2 fi
153 jpp 1.1
154 chrissn 1.6 # Create boot partition
155     printf "part /boot --fstype=xfs --size=500 --label=BOOT --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include
156    
157     # Default to LVM unless specified at command line
158     if [ $NOLVM ] ; then
159     cat >> /tmp/part-include <<EOF
160     part / --fstype=xfs --grow --size=3000 --label=ROOT --ondisk=${DRIVES[0]}
161     part swap --fstype=swap --recommended --label=SWAP --ondisk=${DRIVES[0]}
162 chrissn 1.2 EOF
163 chrissn 1.6 else
164     cat >> /tmp/part-include <<EOF
165     part pv.01 --size=4300 --grow --ondisk=${DRIVES[0]}
166     volgroup main pv.01
167     logvol / --fstype=xfs --name=root --vgname=main --grow --size=3000
168     logvol swap --fstype=swap --name=swap --vgname=main --recommended
169     EOF
170     fi
171 chrissn 1.2
172     # Otherwise multiple disks - prepare for RAID
173     else
174    
175 chrissn 1.6 # Define EFI or biosboot and RAID partitions
176 chrissn 1.2 for i in "${!DRIVES[@]}"; do
177 chrissn 1.6
178 chrissn 1.2 if [ -d /sys/firmware/efi ] ; then
179     printf "part raid.%s0 --size=200 --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include
180 chrissn 1.6 elif [ $BASESIZE -gt 2048000 ] ; then
181     printf "part biosboot --fstype=biosboot --size=1 --ondisk=%s\n" "${DRIVES[$i]}" >> /tmp/part-include
182 chrissn 1.2 fi
183     printf "part raid.%s1 --size=500 --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include
184 chrissn 1.6
185     # Default to LVM unless specified
186     if [ $NOLVM ] ; then
187     printf "part raid.%s2 --size=3000 --grow --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include
188     printf "part raid.%s3 --size=%s --ondisk=%s\n" "$i" "$SWAPSIZE" "${DRIVES[$i]}" >> /tmp/part-include
189     else
190     printf "part raid.%s2 --size=4300 --grow --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include
191     fi
192    
193 chrissn 1.2 done
194    
195     # Compute RAID level
196     # from https://wiki.contribs.org/Raid
197     # 2 Drives - Software RAID 1
198     # 3 Drives - Software RAID 1 + 1 Hot-spare
199 chrissn 1.3 # 4 Drives - Software RAID 6
200     # 5+ Drives - Software RAID 6 + 1 Hot-spare
201 chrissn 1.2
202     if [ ${#DRIVES[@]} == 2 ] ; then
203     LEVEL=1
204     SPARE=0
205     elif [ ${#DRIVES[@]} == 3 ] ; then
206     LEVEL=1
207     SPARE=1
208 chrissn 1.3 elif [ ${#DRIVES[@]} == 4 ] ; then
209     LEVEL=6
210     SPARE=0
211 chrissn 1.2 else
212     LEVEL=6
213     SPARE=1
214     fi
215 jpp 1.1
216 chrissn 1.2 # Set up RAID devices
217     printf -v EFIDEVS "raid.%s0 " "${!DRIVES[@]}"
218     printf -v BOOTDEVS "raid.%s1 " "${!DRIVES[@]}"
219     printf -v ROOTDEVS "raid.%s2 " "${!DRIVES[@]}"
220 chrissn 1.6 printf -v SWAPDEVS "raid.%s3 " "${!DRIVES[@]}"
221 chrissn 1.2
222     # Include the EFI partition if necessary
223     if [ -d /sys/firmware/efi ] ; then
224 chrissn 1.3 printf "raid /boot/efi --fstype=efi --level=1 --spares=0 --device=md9 %s\n" "$EFIDEVS" >> /tmp/part-include
225 chrissn 1.2 fi
226 jpp 1.1
227 chrissn 1.6 # Boot partition
228 chrissn 1.3 printf "raid /boot --fstype=xfs --level=1 --spares=0 --device=md0 %s\n" "$BOOTDEVS" >> /tmp/part-include
229 jpp 1.1
230 chrissn 1.6 # Default to LVM unless specified
231     if [ $NOLVM ] ; then
232     cat >> /tmp/part-include <<EOF
233     raid / --fstype=xfs --level=$LEVEL --spares=$SPARE --device=md1 $ROOTDEVS
234     raid swap --fstype=swap --level=$LEVEL --spares=$SPARE --device=md2 $SWAPDEVS
235     EOF
236     else
237     cat >> /tmp/part-include <<EOF
238     raid pv.01 --level=$LEVEL --spares=$SPARE --device=md1 $ROOTDEVS
239     volgroup main pv.01
240     logvol / --fstype xfs --name=root --vgname=main --grow --size=3000
241     logvol swap --fstype swap --name=swap --vgname=main --recommended
242 chrissn 1.2 EOF
243 chrissn 1.6 fi
244 chrissn 1.2 fi
245     fi
246 jpp 1.1
247 chrissn 1.6 echo "Final part-include output:"
248     cat /tmp/part-include
249    
250 jpp 1.1 %end
251    
252    
253 chrissn 1.2 # SME events in post-install
254 jpp 1.1 %post --interpreter=/usr/bin/bash --log=/var/log/ks.post02.log
255 chrissn 1.4 userdel -r installer
256     sleep 2
257     /sbin/e-smith/signal-event post-install
258     sleep 2
259     /sbin/e-smith/db configuration set UnsavedChanges no
260 jpp 1.1 touch /forcequotacheck
261 chrissn 1.2 %end
262 jpp 1.1
263    
264     %post --nochroot --log=/mnt/sysimage/var/log/ks.post01.log
265     #!/bin/bash
266     sysimage="/mnt/sysimage"
267 chrissn 1.6 cp -r /var/log/sme-partitioning.log ${sysimage}/root/
268 jpp 1.1 cp -r /tmp/anaconda.log ${sysimage}/root/
269     %end

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed