9 |
|
|
10 |
# Default root pass, will be changed in post-install process anyway |
# Default root pass, will be changed in post-install process anyway |
11 |
rootpw --lock |
rootpw --lock |
12 |
|
user --name=installer --uid=9999 |
13 |
|
|
14 |
# Accept EULA |
# Accept EULA |
15 |
eula --agreed |
eula --agreed |
37 |
|
|
38 |
|
|
39 |
# Partitioning in pre-install |
# Partitioning in pre-install |
40 |
%pre --interpreter=/bin/bash --log=/var/log/ks.pre01.log |
%pre --interpreter=/bin/bash --log=/var/log/sme-partitioning.log |
41 |
|
|
42 |
# Minimum size of hard drive needed specified in GB |
# Read command line arguments |
43 |
MINSIZE=5 |
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 |
|
|
48 |
# Number of detected drives |
# Minimum size of hard drive needed specified in MB |
49 |
|
MINSIZE=5000 |
50 |
|
|
51 |
|
# Number of detected drives and first disk size |
52 |
NDEV=0 |
NDEV=0 |
53 |
|
BASESIZE=0 |
54 |
|
SIZEDIFF=0 |
55 |
|
|
56 |
# Loop through block devices and keep those over MINSIZE |
# Loop through block devices, keep those over MINSIZE and ensure additional drives for RAID are within 100MB of the first |
57 |
# TODO: Only pair up drives of the same size |
for DEV in $(lsblk -nl | grep disk | cut -d' ' -f1) ; do |
58 |
for DEV in $(lsblk -nl | grep disk | cut -d' ' -f1); do |
if [ -d /sys/block/$DEV ] ; then |
|
if [ -d /sys/block/$DEV ]; then |
|
59 |
REMOVABLE=`cat /sys/block/$DEV/removable` |
REMOVABLE=`cat /sys/block/$DEV/removable` |
60 |
if (( $REMOVABLE == 0 )); then |
if (( $REMOVABLE == 0 )) ; then |
61 |
SIZE=`cat /sys/block/$DEV/size` |
SIZE=`cat /sys/block/$DEV/size` |
62 |
GB=$(($SIZE/2**21)) |
MB=$(($SIZE/2**11)) |
63 |
if [ $GB -gt $MINSIZE ]; then |
if [ $MB -gt $MINSIZE ] ; then |
64 |
DRIVES[$NDEV]=$DEV |
if [ $NDEV == 0 ] ; then |
65 |
((NDEV++)) |
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 |
fi |
fi |
80 |
fi |
fi |
81 |
fi |
fi |
82 |
done |
done |
83 |
|
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 |
|
|
103 |
# Declare useful variables |
# Declare useful variables |
104 |
printf -v DRIVELIST ",%s" "${DRIVES[@]}" |
printf -v DRIVELIST ",%s" "${DRIVES[@]}" |
105 |
DRIVELIST=${DRIVELIST:1} |
if [ $NORAID ] ; then |
106 |
|
DRIVELIST=${DRIVES[0]} |
107 |
|
else |
108 |
|
DRIVELIST=${DRIVELIST:1} |
109 |
|
fi |
110 |
|
|
111 |
|
echo "Final drive list: $DRIVELIST" |
112 |
LEVEL=1 |
LEVEL=1 |
113 |
SPARE=0 |
SPARE=0 |
114 |
|
|
115 |
|
|
116 |
# Error if detection has failed and fall back |
# Error if detection has failed and fall back |
117 |
if [ ${#DRIVES[@]} == 0 ] ; then |
if [ ${#DRIVES[@]} == 0 ] ; then |
118 |
echo "No drive suitable for installation found! Reverting to Anaconda defaults." |
echo "No drive suitable for installation found! Reverting to Anaconda defaults." |
140 |
bootloader --location=mbr --driveorder=$DRIVELIST |
bootloader --location=mbr --driveorder=$DRIVELIST |
141 |
EOF |
EOF |
142 |
|
|
143 |
# If single disk then set up partitioning without RAID |
# If single disk or noraid specific then set up partitioning without RAID |
144 |
# NOTE: From this point we're appending to part-include |
# NOTE: From this point we're appending to part-include |
145 |
if [ ${#DRIVES[@]} == 1 ] ; then |
if [ ${#DRIVES[@]} == 1 ] || [ $NORAID ] ; then |
146 |
|
|
147 |
# Include the EFI partition if necessary |
# Include the EFI or biosboot partition if necessary |
148 |
if [ -d /sys/firmware/efi ] ; then |
if [ -d /sys/firmware/efi ] ; then |
149 |
printf "part /boot/efi --fstype=efi --size=200 --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include |
printf "part /boot/efi --fstype=efi --size=200 --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include |
150 |
|
elif [ $BASESIZE -gt 2048000 ] ; then |
151 |
|
printf "part biosboot --fstype=biosboot --size=1 --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include |
152 |
fi |
fi |
153 |
|
|
154 |
cat >> /tmp/part-include <<EOF |
# Create boot partition |
155 |
part /boot --fstype=xfs --size=500 --ondisk=${DRIVES[0]} --label=BOOT |
printf "part /boot --fstype=xfs --size=500 --label=BOOT --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include |
156 |
part pv.01 --size=4300 --grow --ondisk=${DRIVES[0]} |
|
157 |
volgroup main pv.01 |
# Default to LVM unless specified at command line |
158 |
logvol / --fstype=xfs --name=root --vgname=main --grow --size=3000 --label=ROOT |
if [ $NOLVM ] ; then |
159 |
logvol swap --fstype=swap --name=swap --vgname=main --recommended --label=SWAP |
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 |
EOF |
EOF |
163 |
|
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 |
|
|
172 |
# Otherwise multiple disks - prepare for RAID |
# Otherwise multiple disks - prepare for RAID |
173 |
else |
else |
174 |
|
|
175 |
# Define EFI, boot and LVM RAID partitions |
# Define EFI or biosboot and RAID partitions |
176 |
for i in "${!DRIVES[@]}"; do |
for i in "${!DRIVES[@]}"; do |
177 |
|
|
178 |
if [ -d /sys/firmware/efi ] ; then |
if [ -d /sys/firmware/efi ] ; then |
179 |
printf "part raid.%s0 --size=200 --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include |
printf "part raid.%s0 --size=200 --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include |
180 |
|
elif [ $BASESIZE -gt 2048000 ] ; then |
181 |
|
printf "part biosboot --fstype=biosboot --size=1 --ondisk=%s\n" "${DRIVES[$i]}" >> /tmp/part-include |
182 |
fi |
fi |
183 |
printf "part raid.%s1 --size=500 --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include |
printf "part raid.%s1 --size=500 --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include |
184 |
printf "part raid.%s2 --size=4300 --grow --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include |
|
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 |
done |
done |
194 |
|
|
195 |
# Compute RAID level |
# Compute RAID level |
217 |
printf -v EFIDEVS "raid.%s0 " "${!DRIVES[@]}" |
printf -v EFIDEVS "raid.%s0 " "${!DRIVES[@]}" |
218 |
printf -v BOOTDEVS "raid.%s1 " "${!DRIVES[@]}" |
printf -v BOOTDEVS "raid.%s1 " "${!DRIVES[@]}" |
219 |
printf -v ROOTDEVS "raid.%s2 " "${!DRIVES[@]}" |
printf -v ROOTDEVS "raid.%s2 " "${!DRIVES[@]}" |
220 |
|
printf -v SWAPDEVS "raid.%s3 " "${!DRIVES[@]}" |
221 |
|
|
222 |
# Include the EFI partition if necessary |
# Include the EFI partition if necessary |
223 |
if [ -d /sys/firmware/efi ] ; then |
if [ -d /sys/firmware/efi ] ; then |
224 |
printf "raid /boot/efi --fstype=efi --level=1 --spares=0 --device=md9 %s\n" "$EFIDEVS" >> /tmp/part-include |
printf "raid /boot/efi --fstype=efi --level=1 --spares=0 --device=md9 %s\n" "$EFIDEVS" >> /tmp/part-include |
225 |
fi |
fi |
226 |
|
|
227 |
|
# Boot partition |
228 |
printf "raid /boot --fstype=xfs --level=1 --spares=0 --device=md0 %s\n" "$BOOTDEVS" >> /tmp/part-include |
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 |
|
229 |
|
|
230 |
# Set up LVM |
# Default to LVM unless specified |
231 |
cat >> /tmp/part-include <<EOF |
if [ $NOLVM ] ; then |
232 |
volgroup main pv.01 |
cat >> /tmp/part-include <<EOF |
233 |
logvol / --fstype xfs --name=root --vgname=main --grow --size=3000 --label=ROOT |
raid / --fstype=xfs --level=$LEVEL --spares=$SPARE --device=md1 $ROOTDEVS |
234 |
logvol swap --fstype swap --name=swap --vgname=main --recommended --label=SWAP |
raid swap --fstype=swap --level=$LEVEL --spares=$SPARE --device=md2 $SWAPDEVS |
235 |
EOF |
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 |
|
EOF |
243 |
|
fi |
244 |
fi |
fi |
245 |
fi |
fi |
246 |
|
|
247 |
|
echo "Final part-include output:" |
248 |
|
cat /tmp/part-include |
249 |
|
|
250 |
%end |
%end |
251 |
|
|
252 |
|
|
253 |
# SME events in post-install |
# SME events in post-install |
254 |
%post --interpreter=/usr/bin/bash --log=/var/log/ks.post02.log |
%post --interpreter=/usr/bin/bash --log=/var/log/ks.post02.log |
255 |
/sbin/rsyslogd; |
userdel -r installer |
256 |
sleep 2; |
sleep 2 |
257 |
/sbin/e-smith/signal-event post-install; |
/sbin/e-smith/signal-event post-install |
258 |
sleep 2; |
sleep 2 |
259 |
/sbin/e-smith/db configuration set UnsavedChanges no; |
/sbin/e-smith/db configuration set UnsavedChanges no |
260 |
touch /forcequotacheck |
touch /forcequotacheck |
261 |
%end |
%end |
262 |
|
|
264 |
%post --nochroot --log=/mnt/sysimage/var/log/ks.post01.log |
%post --nochroot --log=/mnt/sysimage/var/log/ks.post01.log |
265 |
#!/bin/bash |
#!/bin/bash |
266 |
sysimage="/mnt/sysimage" |
sysimage="/mnt/sysimage" |
267 |
|
cp -r /var/log/sme-partitioning.log ${sysimage}/root/ |
268 |
cp -r /tmp/anaconda.log ${sysimage}/root/ |
cp -r /tmp/anaconda.log ${sysimage}/root/ |
269 |
%end |
%end |