23 |
|
|
24 |
|
|
25 |
# Add netinstall repos |
# Add netinstall repos |
26 |
repo --name=smeos --baseurl=http://mirror.canada.pialasse.com/releases/testing/10/smeos/x86_64/ |
repo --name=smeos --mirrorlist=https://mirrorlist.koozali.org/mirrorlist/smeos-10 |
27 |
repo --name=smeupdates --baseurl=http://mirror.canada.pialasse.com/releases/testing/10/smeupdates/x86_64/ |
repo --name=smeupdates --mirrorlist=https://mirrorlist.koozali.org/mirrorlist/smeupdates-10 |
28 |
|
|
29 |
# Packages to install |
# Packages to install |
30 |
%packages |
%packages |
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 |
|
if grep noxfs "/proc/cmdline" ; then FSTYPE="ext4" ; else FSTYPE="xfs" ; fi |
46 |
|
echo "Command line arguments:" |
47 |
|
cat /proc/cmdline |
48 |
|
|
49 |
# Number of detected drives |
# Minimum size of hard drive needed specified in MB |
50 |
|
MINSIZE=5000 |
51 |
|
|
52 |
|
# Number of detected drives and first disk size |
53 |
NDEV=0 |
NDEV=0 |
54 |
|
BASESIZE=0 |
55 |
|
SIZEDIFF=0 |
56 |
|
|
57 |
# 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 |
58 |
# TODO: Only pair up drives of the same size |
for DEV in $(lsblk -nl | grep disk | cut -d' ' -f1) ; do |
59 |
for DEV in $(lsblk -nl | grep disk | cut -d' ' -f1); do |
if [ -d /sys/block/$DEV ] ; then |
|
if [ -d /sys/block/$DEV ]; then |
|
60 |
REMOVABLE=`cat /sys/block/$DEV/removable` |
REMOVABLE=`cat /sys/block/$DEV/removable` |
61 |
if (( $REMOVABLE == 0 )); then |
if (( $REMOVABLE == 0 )) ; then |
62 |
SIZE=`cat /sys/block/$DEV/size` |
SIZE=`cat /sys/block/$DEV/size` |
63 |
GB=$(($SIZE/2**21)) |
MB=$(($SIZE/2**11)) |
64 |
if [ $GB -gt $MINSIZE ]; then |
if [ $MB -gt $MINSIZE ] ; then |
65 |
DRIVES[$NDEV]=$DEV |
if [ $NDEV == 0 ] ; then |
66 |
((NDEV++)) |
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 |
fi |
fi |
81 |
fi |
fi |
82 |
fi |
fi |
83 |
done |
done |
84 |
|
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 |
|
|
104 |
# Declare useful variables |
# Declare useful variables |
105 |
printf -v DRIVELIST ",%s" "${DRIVES[@]}" |
printf -v DRIVELIST ",%s" "${DRIVES[@]}" |
106 |
DRIVELIST=${DRIVELIST:1} |
if [ $NORAID ] ; then |
107 |
|
DRIVELIST=${DRIVES[0]} |
108 |
|
else |
109 |
|
DRIVELIST=${DRIVELIST:1} |
110 |
|
fi |
111 |
|
|
112 |
|
echo "Final drive list: $DRIVELIST" |
113 |
LEVEL=1 |
LEVEL=1 |
114 |
SPARE=0 |
SPARE=0 |
115 |
|
|
116 |
|
|
117 |
# Error if detection has failed and fall back |
# Error if detection has failed and fall back |
118 |
if [ ${#DRIVES[@]} == 0 ] ; then |
if [ ${#DRIVES[@]} == 0 ] ; then |
119 |
echo "No drive suitable for installation found! Reverting to Anaconda defaults." |
echo "No drive suitable for installation found! Reverting to Anaconda defaults." |
141 |
bootloader --location=mbr --driveorder=$DRIVELIST |
bootloader --location=mbr --driveorder=$DRIVELIST |
142 |
EOF |
EOF |
143 |
|
|
144 |
# If single disk then set up partitioning without RAID |
# If single disk or noraid specific then set up partitioning without RAID |
145 |
# NOTE: From this point we're appending to part-include |
# NOTE: From this point we're appending to part-include |
146 |
if [ ${#DRIVES[@]} == 1 ] ; then |
if [ ${#DRIVES[@]} == 1 ] || [ $NORAID ] ; then |
147 |
|
|
148 |
# Include the EFI partition if necessary |
# Include the EFI or biosboot partition if necessary |
149 |
if [ -d /sys/firmware/efi ] ; then |
if [ -d /sys/firmware/efi ] ; then |
150 |
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 |
151 |
|
elif [ $BASESIZE -gt 2048000 ] ; then |
152 |
|
printf "part biosboot --fstype=biosboot --size=1 --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include |
153 |
fi |
fi |
154 |
|
|
155 |
cat >> /tmp/part-include <<EOF |
# Create boot partition |
156 |
part /boot --fstype=xfs --size=500 --ondisk=${DRIVES[0]} --label=BOOT |
printf "part /boot --fstype=%s --size=500 --label=BOOT --ondisk=%s\n" "$FSTYPE" "${DRIVES[0]}" >> /tmp/part-include |
157 |
part pv.01 --size=4300 --grow --ondisk=${DRIVES[0]} |
|
158 |
volgroup main pv.01 |
# Default to LVM unless specified at command line |
159 |
logvol / --fstype=xfs --name=root --vgname=main --grow --size=3000 --label=ROOT |
if [ $NOLVM ] ; then |
160 |
logvol swap --fstype=swap --name=swap --vgname=main --recommended --label=SWAP |
cat >> /tmp/part-include <<EOF |
161 |
|
part / --fstype=$FSTYPE --grow --size=3000 --label=ROOT --ondisk=${DRIVES[0]} |
162 |
|
part swap --fstype=swap --recommended --label=SWAP --ondisk=${DRIVES[0]} |
163 |
EOF |
EOF |
164 |
|
else |
165 |
|
cat >> /tmp/part-include <<EOF |
166 |
|
part pv.01 --size=4300 --grow --ondisk=${DRIVES[0]} |
167 |
|
volgroup main pv.01 |
168 |
|
logvol / --fstype=$FSTYPE --name=root --vgname=main --grow --size=3000 |
169 |
|
logvol swap --fstype=swap --name=swap --vgname=main --recommended |
170 |
|
EOF |
171 |
|
fi |
172 |
|
|
173 |
# Otherwise multiple disks - prepare for RAID |
# Otherwise multiple disks - prepare for RAID |
174 |
else |
else |
175 |
|
|
176 |
# Define EFI, boot and LVM RAID partitions |
# Define EFI or biosboot and RAID partitions |
177 |
for i in "${!DRIVES[@]}"; do |
for i in "${!DRIVES[@]}"; do |
178 |
|
|
179 |
if [ -d /sys/firmware/efi ] ; then |
if [ -d /sys/firmware/efi ] ; then |
180 |
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 |
181 |
|
elif [ $BASESIZE -gt 2048000 ] ; then |
182 |
|
printf "part biosboot --fstype=biosboot --size=1 --ondisk=%s\n" "${DRIVES[$i]}" >> /tmp/part-include |
183 |
fi |
fi |
184 |
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 |
185 |
printf "part raid.%s2 --size=4300 --grow --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include |
|
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 |
done |
done |
195 |
|
|
196 |
# Compute RAID level |
# Compute RAID level |
218 |
printf -v EFIDEVS "raid.%s0 " "${!DRIVES[@]}" |
printf -v EFIDEVS "raid.%s0 " "${!DRIVES[@]}" |
219 |
printf -v BOOTDEVS "raid.%s1 " "${!DRIVES[@]}" |
printf -v BOOTDEVS "raid.%s1 " "${!DRIVES[@]}" |
220 |
printf -v ROOTDEVS "raid.%s2 " "${!DRIVES[@]}" |
printf -v ROOTDEVS "raid.%s2 " "${!DRIVES[@]}" |
221 |
|
printf -v SWAPDEVS "raid.%s3 " "${!DRIVES[@]}" |
222 |
|
|
223 |
# Include the EFI partition if necessary |
# Include the EFI partition if necessary |
224 |
if [ -d /sys/firmware/efi ] ; then |
if [ -d /sys/firmware/efi ] ; then |
225 |
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 |
226 |
fi |
fi |
227 |
|
|
228 |
printf "raid /boot --fstype=xfs --level=1 --spares=0 --device=md0 %s\n" "$BOOTDEVS" >> /tmp/part-include |
# Boot partition |
229 |
printf "raid pv.01 --level=%s --spares=%s --device=md1 %s\n" "$LEVEL" "$SPARE" "$ROOTDEVS" >> /tmp/part-include |
printf "raid /boot --fstype=%s --level=1 --spares=0 --device=md0 %s\n" "$FSTYPE" "$BOOTDEVS" >> /tmp/part-include |
230 |
|
|
231 |
# Set up LVM |
# Default to LVM unless specified |
232 |
cat >> /tmp/part-include <<EOF |
if [ $NOLVM ] ; then |
233 |
volgroup main pv.01 |
cat >> /tmp/part-include <<EOF |
234 |
logvol / --fstype xfs --name=root --vgname=main --grow --size=3000 --label=ROOT |
raid / --fstype=$FSTYPE --level=$LEVEL --spares=$SPARE --device=md1 $ROOTDEVS |
235 |
logvol swap --fstype swap --name=swap --vgname=main --recommended --label=SWAP |
raid swap --fstype=swap --level=$LEVEL --spares=$SPARE --device=md2 $SWAPDEVS |
236 |
EOF |
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 |
|
logvol / --fstype=$FSTYPE --name=root --vgname=main --grow --size=3000 |
242 |
|
logvol swap --fstype swap --name=swap --vgname=main --recommended |
243 |
|
EOF |
244 |
|
fi |
245 |
fi |
fi |
246 |
fi |
fi |
247 |
|
|
248 |
|
echo "Final part-include output:" |
249 |
|
cat /tmp/part-include |
250 |
|
|
251 |
%end |
%end |
252 |
|
|
253 |
|
|
255 |
%post --interpreter=/usr/bin/bash --log=/var/log/ks.post02.log |
%post --interpreter=/usr/bin/bash --log=/var/log/ks.post02.log |
256 |
userdel -r installer |
userdel -r installer |
257 |
sleep 2 |
sleep 2 |
|
/sbin/rsyslogd |
|
|
sleep 2 |
|
258 |
/sbin/e-smith/signal-event post-install |
/sbin/e-smith/signal-event post-install |
259 |
sleep 2 |
sleep 2 |
260 |
/sbin/e-smith/db configuration set UnsavedChanges no |
/sbin/e-smith/db configuration set UnsavedChanges no |
265 |
%post --nochroot --log=/mnt/sysimage/var/log/ks.post01.log |
%post --nochroot --log=/mnt/sysimage/var/log/ks.post01.log |
266 |
#!/bin/bash |
#!/bin/bash |
267 |
sysimage="/mnt/sysimage" |
sysimage="/mnt/sysimage" |
268 |
|
cp -r /var/log/sme-partitioning.log ${sysimage}/root/ |
269 |
cp -r /tmp/anaconda.log ${sysimage}/root/ |
cp -r /tmp/anaconda.log ${sysimage}/root/ |
270 |
%end |
%end |