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/ |
#this one gives curl 6 errors on netinstall while added manually works from time to time |
27 |
repo --name=smeupdates --baseurl=http://mirror.canada.pialasse.com/releases/testing/10/smeupdates/x86_64/ |
#url --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeos-10-x86_64 |
28 |
|
#repo --name=smeupdates --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeupdates-10-x86_64 |
29 |
|
#repo --name=smeos --baseurl http://distro.ibiblio.org/pub/linux/distributions/smeserver/releases/10/smeos/x86_64/ |
30 |
|
#repo --name=smeupdates --baseurl http://distro.ibiblio.org/pub/linux/distributions/smeserver/releases/10/smeupdates/x86_64/ |
31 |
|
repo --name=smeos --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeos-10-x86_64 |
32 |
|
repo --name=smeupdates --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeupdates-10-x86_64 |
33 |
|
|
34 |
# Packages to install |
# Packages to install |
35 |
%packages |
%packages |
42 |
|
|
43 |
|
|
44 |
# Partitioning in pre-install |
# Partitioning in pre-install |
45 |
%pre --interpreter=/bin/bash --log=/var/log/ks.pre01.log |
%pre --interpreter=/bin/bash --log=/var/log/sme-partitioning.log |
46 |
|
|
47 |
# Minimum size of hard drive needed specified in GB |
# Read command line arguments |
48 |
MINSIZE=5 |
if grep nolvm "/proc/cmdline" ; then NOLVM=true ; fi |
49 |
|
if grep noraid "/proc/cmdline" ; then NORAID=true ; fi |
50 |
|
if grep noxfs "/proc/cmdline" ; then FSTYPE="ext4" ; else FSTYPE="xfs" ; fi |
51 |
|
echo "Command line arguments:" |
52 |
|
cat /proc/cmdline |
53 |
|
|
54 |
# Number of detected drives |
# Minimum size of hard drive needed specified in MB |
55 |
|
MINSIZE=5000 |
56 |
|
|
57 |
|
# Number of detected drives and first disk size |
58 |
NDEV=0 |
NDEV=0 |
59 |
|
BASESIZE=0 |
60 |
|
SIZEDIFF=0 |
61 |
|
|
62 |
# 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 |
63 |
# TODO: Only pair up drives of the same size |
for DEV in $(lsblk -nl | grep disk | cut -d' ' -f1) ; do |
64 |
for DEV in $(lsblk -nl | grep disk | cut -d' ' -f1); do |
if [ -d /sys/block/$DEV ] ; then |
|
if [ -d /sys/block/$DEV ]; then |
|
65 |
REMOVABLE=`cat /sys/block/$DEV/removable` |
REMOVABLE=`cat /sys/block/$DEV/removable` |
66 |
if (( $REMOVABLE == 0 )); then |
if (( $REMOVABLE == 0 )) ; then |
67 |
SIZE=`cat /sys/block/$DEV/size` |
SIZE=`cat /sys/block/$DEV/size` |
68 |
GB=$(($SIZE/2**21)) |
MB=$(($SIZE/2**11)) |
69 |
if [ $GB -gt $MINSIZE ]; then |
if [ $MB -gt $MINSIZE ] ; then |
70 |
DRIVES[$NDEV]=$DEV |
if [ $NDEV == 0 ] ; then |
71 |
((NDEV++)) |
echo "First drive found: $DEV with size $MB MB" |
72 |
|
DRIVES[$NDEV]=$DEV |
73 |
|
BASESIZE=$MB |
74 |
|
((NDEV++)) |
75 |
|
else |
76 |
|
SIZEDIFF=$(($MB-$BASESIZE)) |
77 |
|
if [ $SIZEDIFF -gt 100 ] || [ $SIZEDIFF -lt -100 ] ; then |
78 |
|
echo "Drive found but size of $MB MB doesn't match $BASESIZE MB - ignoring" |
79 |
|
else |
80 |
|
echo "Additional drive found: $DEV with size $MB MB" |
81 |
|
DRIVES[$NDEV]=$DEV |
82 |
|
((NDEV++)) |
83 |
|
fi |
84 |
|
fi |
85 |
fi |
fi |
86 |
fi |
fi |
87 |
fi |
fi |
88 |
done |
done |
89 |
|
echo "Total disks found: $NDEV" |
90 |
|
|
91 |
|
# Calculate recommended swap size for RAID + nolvm case |
92 |
|
if [ -d /sys/firmware/efi ] ; then |
93 |
|
DISKSPARE=$(($BASESIZE-200-500-3000)) |
94 |
|
else |
95 |
|
DISKSPARE=$(($BASESIZE-1-500-3000)) |
96 |
|
fi |
97 |
|
MEMSIZE=$(awk '/^MemTotal:/{print $2}' /proc/meminfo) |
98 |
|
MEMSIZEMB=$(($MEMSIZE/2**10)) |
99 |
|
|
100 |
|
if [ $MEMSIZEMB -lt 2000 ] ; then |
101 |
|
SWAPSIZE=$((2*$MEMSIZEMB)) |
102 |
|
elif [ $MEMSIZEMB -lt 8000 ] ; then |
103 |
|
SWAPSIZE=$MEMSIZEMB |
104 |
|
else |
105 |
|
SWAPSIZE=8000 |
106 |
|
fi |
107 |
|
if [ $SWAPSIZE -gt $DISKSPARE ] ; then SWAPSIZE=$DISKSPARE ; fi |
108 |
|
|
109 |
# Declare useful variables |
# Declare useful variables |
110 |
printf -v DRIVELIST ",%s" "${DRIVES[@]}" |
printf -v DRIVELIST ",%s" "${DRIVES[@]}" |
111 |
DRIVELIST=${DRIVELIST:1} |
if [ $NORAID ] ; then |
112 |
|
DRIVELIST=${DRIVES[0]} |
113 |
|
else |
114 |
|
DRIVELIST=${DRIVELIST:1} |
115 |
|
fi |
116 |
|
|
117 |
|
echo "Final drive list: $DRIVELIST" |
118 |
LEVEL=1 |
LEVEL=1 |
119 |
SPARE=0 |
SPARE=0 |
120 |
|
|
121 |
|
|
122 |
# Error if detection has failed and fall back |
# Error if detection has failed and fall back |
123 |
if [ ${#DRIVES[@]} == 0 ] ; then |
if [ ${#DRIVES[@]} == 0 ] ; then |
124 |
echo "No drive suitable for installation found! Reverting to Anaconda defaults." |
echo "No drive suitable for installation found! Reverting to Anaconda defaults." |
146 |
bootloader --location=mbr --driveorder=$DRIVELIST |
bootloader --location=mbr --driveorder=$DRIVELIST |
147 |
EOF |
EOF |
148 |
|
|
149 |
# If single disk then set up partitioning without RAID |
# If single disk or noraid specific then set up partitioning without RAID |
150 |
# NOTE: From this point we're appending to part-include |
# NOTE: From this point we're appending to part-include |
151 |
if [ ${#DRIVES[@]} == 1 ] ; then |
if [ ${#DRIVES[@]} == 1 ] || [ $NORAID ] ; then |
152 |
|
|
153 |
# Include the EFI partition if necessary |
# Include the EFI or biosboot partition if necessary |
154 |
if [ -d /sys/firmware/efi ] ; then |
if [ -d /sys/firmware/efi ] ; then |
155 |
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 |
156 |
|
elif [ $BASESIZE -gt 2048000 ] ; then |
157 |
|
printf "part biosboot --fstype=biosboot --size=1 --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include |
158 |
fi |
fi |
159 |
|
|
160 |
cat >> /tmp/part-include <<EOF |
# Create boot partition |
161 |
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 |
162 |
part pv.01 --size=4300 --grow --ondisk=${DRIVES[0]} |
|
163 |
volgroup main pv.01 |
# Default to LVM unless specified at command line |
164 |
logvol / --fstype=xfs --name=root --vgname=main --grow --size=3000 --label=ROOT |
if [ $NOLVM ] ; then |
165 |
logvol swap --fstype=swap --name=swap --vgname=main --recommended --label=SWAP |
cat >> /tmp/part-include <<EOF |
166 |
|
part / --fstype=$FSTYPE --grow --size=3000 --label=ROOT --ondisk=${DRIVES[0]} |
167 |
|
part swap --fstype=swap --recommended --label=SWAP --ondisk=${DRIVES[0]} |
168 |
EOF |
EOF |
169 |
|
else |
170 |
|
cat >> /tmp/part-include <<EOF |
171 |
|
part pv.01 --size=4300 --grow --ondisk=${DRIVES[0]} |
172 |
|
volgroup main pv.01 |
173 |
|
logvol / --fstype=$FSTYPE --name=root --vgname=main --grow --size=3000 |
174 |
|
logvol swap --fstype=swap --name=swap --vgname=main --recommended |
175 |
|
EOF |
176 |
|
fi |
177 |
|
|
178 |
# Otherwise multiple disks - prepare for RAID |
# Otherwise multiple disks - prepare for RAID |
179 |
else |
else |
180 |
|
|
181 |
# Define EFI, boot and LVM RAID partitions |
# Define EFI or biosboot and RAID partitions |
182 |
for i in "${!DRIVES[@]}"; do |
for i in "${!DRIVES[@]}"; do |
183 |
|
|
184 |
if [ -d /sys/firmware/efi ] ; then |
if [ -d /sys/firmware/efi ] ; then |
185 |
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 |
186 |
|
elif [ $BASESIZE -gt 2048000 ] ; then |
187 |
|
printf "part biosboot --fstype=biosboot --size=1 --ondisk=%s\n" "${DRIVES[$i]}" >> /tmp/part-include |
188 |
fi |
fi |
189 |
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 |
190 |
printf "part raid.%s2 --size=4300 --grow --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include |
|
191 |
|
# Default to LVM unless specified |
192 |
|
if [ $NOLVM ] ; then |
193 |
|
printf "part raid.%s2 --size=3000 --grow --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include |
194 |
|
printf "part raid.%s3 --size=%s --ondisk=%s\n" "$i" "$SWAPSIZE" "${DRIVES[$i]}" >> /tmp/part-include |
195 |
|
else |
196 |
|
printf "part raid.%s2 --size=4300 --grow --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include |
197 |
|
fi |
198 |
|
|
199 |
done |
done |
200 |
|
|
201 |
# Compute RAID level |
# Compute RAID level |
223 |
printf -v EFIDEVS "raid.%s0 " "${!DRIVES[@]}" |
printf -v EFIDEVS "raid.%s0 " "${!DRIVES[@]}" |
224 |
printf -v BOOTDEVS "raid.%s1 " "${!DRIVES[@]}" |
printf -v BOOTDEVS "raid.%s1 " "${!DRIVES[@]}" |
225 |
printf -v ROOTDEVS "raid.%s2 " "${!DRIVES[@]}" |
printf -v ROOTDEVS "raid.%s2 " "${!DRIVES[@]}" |
226 |
|
printf -v SWAPDEVS "raid.%s3 " "${!DRIVES[@]}" |
227 |
|
|
228 |
# Include the EFI partition if necessary |
# Include the EFI partition if necessary |
229 |
if [ -d /sys/firmware/efi ] ; then |
if [ -d /sys/firmware/efi ] ; then |
230 |
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 |
231 |
fi |
fi |
232 |
|
|
233 |
printf "raid /boot --fstype=xfs --level=1 --spares=0 --device=md0 %s\n" "$BOOTDEVS" >> /tmp/part-include |
# Boot partition |
234 |
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 |
235 |
|
|
236 |
# Set up LVM |
# Default to LVM unless specified |
237 |
cat >> /tmp/part-include <<EOF |
if [ $NOLVM ] ; then |
238 |
volgroup main pv.01 |
cat >> /tmp/part-include <<EOF |
239 |
logvol / --fstype xfs --name=root --vgname=main --grow --size=3000 --label=ROOT |
raid / --fstype=$FSTYPE --level=$LEVEL --spares=$SPARE --device=md1 $ROOTDEVS |
240 |
logvol swap --fstype swap --name=swap --vgname=main --recommended --label=SWAP |
raid swap --fstype=swap --level=$LEVEL --spares=$SPARE --device=md2 $SWAPDEVS |
241 |
EOF |
EOF |
242 |
|
else |
243 |
|
cat >> /tmp/part-include <<EOF |
244 |
|
raid pv.01 --level=$LEVEL --spares=$SPARE --device=md1 $ROOTDEVS |
245 |
|
volgroup main pv.01 |
246 |
|
logvol / --fstype=$FSTYPE --name=root --vgname=main --grow --size=3000 |
247 |
|
logvol swap --fstype swap --name=swap --vgname=main --recommended |
248 |
|
EOF |
249 |
|
fi |
250 |
fi |
fi |
251 |
fi |
fi |
252 |
|
|
253 |
|
echo "Final part-include output:" |
254 |
|
cat /tmp/part-include |
255 |
|
|
256 |
%end |
%end |
257 |
|
|
258 |
|
|
270 |
%post --nochroot --log=/mnt/sysimage/var/log/ks.post01.log |
%post --nochroot --log=/mnt/sysimage/var/log/ks.post01.log |
271 |
#!/bin/bash |
#!/bin/bash |
272 |
sysimage="/mnt/sysimage" |
sysimage="/mnt/sysimage" |
273 |
|
cp -r /var/log/sme-partitioning.log ${sysimage}/root/ |
274 |
cp -r /tmp/anaconda.log ${sysimage}/root/ |
cp -r /tmp/anaconda.log ${sysimage}/root/ |
275 |
%end |
%end |