[CentOS] PXE boot, Kickstart NFS install and %include...

Wed Mar 15 16:15:47 UTC 2006
Aleksandar Milivojevic <alex at milivojevic.org>

Quoting Ron Loftin <reloftin at twcny.rr.com>:

> ********************  Example disk config module  **********************
>
> #
> #	Custom partitioning for mirrored 4.5GB SCSI disks
> #
>
> #Clear the Master Boot Record
> zerombr yes
>
> #Clear all partitions from the disk
> clearpart --initlabel --all
>
> part raid.11 --noformat --asprimary --size 2048 --grow --ondisk sda
> part raid.12 --noformat --asprimary --size 256 --ondisk sda
> part raid.13 --noformat --asprimary --size 256 --ondisk sda
> part raid.14 --noformat --asprimary --size 1024 --ondisk sda
[snip]

I'm usually creating this file from %pre script, so it is automatically 
tailored for each system.  Basically, something like:

%pre
#! /bin/sh

a=`list-harddrives`
d1_name=`echo $a | awk '{ print $1 }'`
d1_size=`echo $a | awk '{ print $2 }' | cut -f1 -d'.'`
d2_name=`echo $a | awk '{ print $3 }'`
d2_size=`echo $a | awk '{ print $4 }' | cut -f1 -d'.'`
set $(echo $a)
numd=$(($#/2));

Then based on number of drives detected and drive sizes I simply build 
/tmp/partinfo (there's "%include /tmp/partinfo" in main kickstart 
file).  If above detects single drive, it outputs directives to install 
onto it directly.  If above detects two drives of same size, it outputs 
directives to build "mirrored" configuration.  I'm also adjusting 
partition sizes based on detected drive size.  Simplified (the actuall 
script is much longer), it looks something like this:

if [ "$numd" -eq 2 -a "$d1_size" -eq "$d2_size" ]
then
   echo "Building mirrors"
   echo "clearpart --initlabel --drives=$d1_name,$d2_name
part raid.01 --size $boot --ondisk $d1_name --asprimary
part raid.02 --size $boot --ondisk $d2_name --asprimary
part raid.11 --size 1 --grow --ondisk $d1_name --asprimary
part raid.12 --size 1 --grow --ondisk $d2_name --asprimary
raid /boot --level 1 --device md0 raid.01 raid.02
raid pv.00 --level 1 --device md1 raid.11 raid.12
... and so on ...
" > /tmp/partinfo
else
   echo "Installing on signle disk"
   echo "clearpart --initlabel --drives=$d1_name
part /boot --size $boot --ondisk $d1_name --asprimary
part pv.00 --size 1 --grow --ondisk $d1_name --asprimary
... and so on ...
" > /tmp/partinfo
fi

Of course, you need to be carefull not to use this if machine has 
drives with data that you want to preserve ;-)

-- 
See Ya' later, alligator!
http://www.8-P.ca/