Re: Identifying SCSI or IDE drives in %pre

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daniel Segall wrote:
I deploy kickstarts to a number of different configurations. The servers have IDE, SAS, or SCSI drives. My partitioning is always the same, but if it's an IDE server, I do a software raid1. The SCSI & SAS servers have hardware raid1. Currently I manage multiple configs to make this happen. I'd like to start using list-harddrives in %pre, and generate the partition tables from that. It's really simple, if sd = yes, then  partition normally. hd = yes then partition with raid config.

I know this has been covered before, and I have searched and found some examples, but not exactly what I'm looking for. I am not a programmer, so if someone could help me with the logic here, that would be sweet.
Put this in the main part of you kickstart config:
%include /tmp/part-include

My partitioning logic ignores removable drives like usb devices. Add more devices to the "for" line if you have a large number of drives.

Here is my pre section:
%pre

#----- partitioning logic below--------------
# pick the first drive that is not removable and is over MINSIZE
DIR="/sys/block"

# minimum size of hard drive needed specified in GIGABYTES
MINSIZE=6


ROOTDRIVE=""

# /sys/block/*/size is in 512 byte chunks

for DEV in sda sdb hda hdb; do
 if [ -d $DIR/$DEV ]; then
   REMOVABLE=`cat $DIR/$DEV/removable`
   if (( $REMOVABLE == 0 )); then
     echo $DEV
     SIZE=`cat $DIR/$DEV/size`
     GB=$(($SIZE/2**21))
     if [ $GB -gt $MINSIZE ]; then
       echo "$(($SIZE/2**21))"
       if [ -z $ROOTDRIVE ]; then
         ROOTDRIVE=$DEV
       fi
     fi
   fi
 fi
done

echo "ROOTDRIVE=$ROOTDRIVE"

cat << EOF >> /tmp/part-include
bootloader --location=mbr --driveorder=$ROOTDRIVE
clearpart --all --drives=$ROOTDRIVE --initlabel
part /boot --fstype ext3 --size=300 --ondisk=$ROOTDRIVE
part pv.4 --size=0 --grow --ondisk=$ROOTDRIVE
volgroup VolGroup00 --pesize=32768 pv.4
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1024 --grow --maxsize=2048 logvol / --fstype ext3 --name=root --vgname=VolGroup00 --size=4096 --grow --maxsize=20480
logvol /var/log --fstype ext3 --name=var-log --vgname=VolGroup00 --size=512
logvol /tmp --fstype ext3 --name=tmp --vgname=VolGroup00 --size=1024 --maxsize=4096 logvol /usr/vice/cache --fstype ext3 --name=usr-vice-cache --vgname=VolGroup00 --size=1024
logvol /home --fstype ext3 --name=home --vgname=VolGroup00 --size=512 --grow
EOF


Sincerely,
Jason Edgecombe


[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux