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