Hey thanks! That is a good start!
Chris Adams wrote:
Once upon a time, Matt Fahrner <Matt.Fahrner@xxxxxxxx> said:
Does anyone know if there's a way, say in the "%pre" to run something
that could do more customized partitioning than what is supplied by
generic "kickstart". For instance, perhaps running a Perl script that
in turn runs "fdisk"?
I don't think perl is available during %pre (IIRC perl is not in the
install image at all).
Here's what I do in my %pre for partitioning (this may not be as smart
as what you want, but it may give you some ideas). I figure my own swap
size first, then look at the available devices (in this case I know I've
got 4 drives, doing RAID mirroring and LVM striping) to figure out how
much space to use.
I call python to get a couple of things (but I'm not a python person, so
that is just copied from some of the anaconda source), and I use shell
math to do the calculations. It should be easy enough to expand this to
be smarter about other filesystems than /usr/local. It also currently
assumes all drives are the same size as the first drive (only the first
line of output from "list-hardrives" is used) because in my setup, that
is true; a better way would be to use a shell array. The lvcreate
script could also be smarter (use different options based on the device
being used).
************************************************************************
zerombr yes
clearpart --all --initlabel
%include /tmp/part-include
bootloader --location=mbr
%pre
# How much RAM is there (round up to next 16MB)
ram=`python <<EOF
import sys
sys.path.append('/usr/lib/anaconda')
import iutil
sizekB = iutil.memInstalled(1)
print sizekB
EOF
`
ram=$(((($ram + 1023) / 1024 + 15) / 16 * 16))
# Swap should be twice RAM
swap=$(($ram * 2))
if [ "$(($swap > 2048))" = "1" ]; then
# but no more than 2G
swap=2048
fi
# Figure out disk size and partition scheme
list-harddrives | while read dev mb; do
mb=`echo $mb | sed 's/\.[0-9]*//'`
echo "dev=$dev; mb=$mb"
break
done > /tmp/ks-hd-info
. /tmp/ks-hd-info
boot=75
lvm=$(($mb - $boot))
# Since we're going to software stripe, full lvm size will be double
lvm=$(($lvm * 2))
root=250
usr=2500
tmp=750
var=2500
# Leave some empty space for LVM snapshots
empty=750
# Make /usr/local the rest
usrlocal=$(($lvm - $root - $swap - $usr - $tmp - $var - $empty))
# Set the volume based on the hostname
. /tmp/netinfo
if [ "$HOSTNAME" = "" ]; then
vol=vol
else
vol=${HOSTNAME%%.*}
fi
# Cheat: we want lvcreate called with certain options, and Red Hat
# doesn't currently support passing extra options. So, create an
# lvcreate script that uses the options, and bind mount it on top of the
# binary (after copying the binary).
cp /usr/sbin/lvcreate /tmp/lvcreate.bin
cat > /tmp/lvcreate <<EOF
#!/bin/sh
exec /tmp/lvcreate.bin -i 2 -I 512 \$@
EOF
chmod +x /tmp/lvcreate
mount /tmp/lvcreate /usr/sbin/lvcreate -o bind
cat > /tmp/part-include <<EOF
part raid.01 --ondisk=sda --size=$boot --asprimary
part raid.02 --ondisk=sdb --size=$boot --asprimary
part raid.03 --ondisk=sdc --size=$boot --asprimary
part raid.04 --ondisk=sdd --size=$boot --asprimary
part raid.05 --ondisk=sda --size=1 --grow --asprimary
part raid.06 --ondisk=sdb --size=1 --grow --asprimary
part raid.07 --ondisk=sdc --size=1 --grow --asprimary
part raid.08 --ondisk=sdd --size=1 --grow --asprimary
raid /boot --level=1 --device=md0 --fstype=ext3 raid.01 raid.02 raid.03 raid.04
raid pv.10 --level=1 --device=md1 raid.05 raid.07
raid pv.20 --level=1 --device=md2 raid.06 raid.08
volgroup $vol pv.10 pv.20
logvol / --name=root --vgname=$vol --fstype=ext3 --size=$root
logvol swap --name=swap --vgname=$vol --fstype=swap --size=$swap
logvol /usr --name=usr --vgname=$vol --fstype=ext3 --size=$usr
logvol /tmp --name=tmp --vgname=$vol --fstype=ext3 --size=$tmp
logvol /var --name=var --vgname=$vol --fstype=ext3 --size=$var
logvol /usr/local --name=usrlocal --vgname=$vol --fstype=ext3 --size=$usrlocal
EOF
************************************************************************
--
---------------------------------------------------------------------
Matt Fahrner 2 South Park St.
Manager of Networking Willis House
Burlington Coat Factory Warehouse Lebanon, N.H. 03766
TEL: (603) 448-4100 xt 5150 USA
FAX: (603) 443-6190 Matt.Fahrner@xxxxxxxx
---------------------------------------------------------------------