some help needed with python script to detect number of drives in kickstart file

Rudi Ahlers Rudi at SoftDux.com
Fri Mar 28 21:15:58 UTC 2008


Michael DeHaan wrote:
> Rudi Ahlers wrote:
>> Hi all
>>
>> I would like to put together a kickstart script which will allow me 
>> to install CentOS on many different platforms, regardless of the 
>> number & types of drive installed. If the system has 3 drives, I'd 
>> like to setup RAID 1 + 1 hot spare, for example. If it has 4 HDD's, 
>> then I'd like to setup RAID10, and for 10 HDD's, RAID 50.
>>
>> So, after trying many different options, I still can't get it to 
>> work, but recently found the following website, 
>> http://evuraan.blogspot.com/2005/02/auto-finding-your-hard-drives-for.html 
>> which basically outlines a way to determine how many drives are in 
>> the machine, but it's very basic.
>>
> This script is a bit overkill.   From cobbler's snippets directory, I 
> have this for default drive selection code.  You will have do a bit 
> more get RAID auto-configured, but that is left as an exercise for the 
> reader.
>
> %include /tmp/partinfo
>
> %pre
> # Determine how many drives we have
> set \$(list-harddrives)
> let numd=\$#/2
> d1=\$1
> d2=\$3
>
> cat << EOF > /tmp/partinfo
> part / --fstype ext3 --size=1024 --grow --ondisk=\$d1 --asprimary
> part swap --size=1024 --ondisk=\$d1 --asprimary
> EOF
>
>
I've tried that example already, as well, but the partitions never get 
created, with the more advanced code below:

set $(list-harddrives)
let numd=$#/2 # This will provide the total # of drives
d1=$1 # This is the device of disk 1
d2=$3 # This is the device of disk 2, etc.
d3=$5
d4=$7
d5=$9
S1=$2 # This is the size of disk 1
S2=$4 # This is the size of disk 2, etc.
S3=$6
S4=$8
S5=$10


# This would be a partition scheme for three or more drives
if [ $numd -ge 3 ] ; then
cat << EOF >> /tmp/partinfo
part raid.11    --size 200      --asprimary     --ondrive=$d1
part raid.12    --size 2048     --asprimary     --ondrive=$d1
part raid.13    --size 1 --grow                 --ondrive=$d1

part raid.21    --size 200      --asprimary     --ondrive=$d2
part raid.22    --size 2048     --asprimary     --ondrive=$d2
part raid.23    --size 1 --grow                 --ondrive=$d2

part raid.31    --size 200      --asprimary     --ondrive=$d3
part raid.32    --size 2048     --asprimary     --ondrive=$d3
part raid.33    --size 1 --grow                 --ondrive=$d3

raid /boot      --fstype ext3 --device md0 --level=RAID1 raid.11 raid.21 
raid.31 --spare=1
raid swap       --fstype swap --device md1 --level=RAID1 raid.12 raid.22 
raid.32 --spare=1
raid pv.01      --fstype ext3 --device md2 --level=RAID1 raid.13 raid.23 
raid.33 --spare=1

logvol /                --vgname=sysvg  --size=3072     --name=root
logvol /usr             --vgname=sysvg  --size=8192     --name=usr
logvol /tmp             --vgname=sysvg  --size=1024     --name=tmp
logvol /var             --vgname=sysvg  --size=8192     --name=var
logvol /home            --vgname=sysvg  --size=20480    --name=home
logvol /bck             --vgname=pv.02  --size=1 --grow --name=bck

EOF
elif [ $numd - ge 2 ]; then
cat << EOF >> /tmp/partinfo
part /boot     --fstype ext3 --size=150  --ondisk=$d1
part swap                    --size=4092 --ondisk=$d1,$d2
part pv.01     --fstype ext3 --size=100  --grow --ondisk=$d1
part pv.02     --fstype ext3 --size=100  --grow --ondisk=$d2


logvol /                --vgname=sysvg  --size=3072     --name=root
logvol /usr             --vgname=sysvg  --size=8192     --name=usr
logvol /tmp             --vgname=sysvg  --size=1024     --name=tmp
logvol /var             --vgname=sysvg  --size=8192     --name=var
logvol /home            --vgname=sysvg  --size=20480    --name=home

EOF
else
cat << EOF >> /tmp/partinfo
part /boot     --fstype ext3 --size=150  --ondisk=$d1
part swap                    --size=4092 --ondisk=$d1
part pv.01     --fstype ext3 --size=100  --grow --ondisk=$d1

logvol /                --vgname=sysvg  --size=3072     --name=root
logvol /usr             --vgname=sysvg  --size=8192     --name=usr
logvol /tmp             --vgname=sysvg  --size=1024     --name=tmp
logvol /var             --vgname=sysvg  --size=8192     --name=var
logvol /home            --vgname=sysvg  --size=20480    --name=home

EOF
fi


-- 

Kind Regards
Rudi Ahlers
CEO, SoftDux

Web:   http://www.SoftDux.com
Check out my technical blog, http://blog.softdux.com for Linux or other technical stuff, or visit http://www.WebHostingTalk.co.za for Web Hosting stuff




More information about the Kickstart-list mailing list