I've found that with the bash shell from busybox used during the kickstart doesn't have all the functionality one is used to. And it varies between rhel3,4,5. So I elected to do any scripted partitioning in a python script. Following are the %pre install script and autopartition script pulled from the server via NFS to accomplish our install. (NFS server IP address is 192.168.0.2). Part of the python code from the autopartition script was borrowed from /usr/lib/anaconda/list-harddrives-stub. I rely heavily on the %include capability and have made stuff very modular. I utilize a perl script that creates our ks.cfg files. Hope this gives you some more ideas. Daryl Smith Software Engineer Micron Technology ########## Applicable code chunks from our ks.cfg file ###### zerombr yes # Partitioning Information, determined below in %pre %include /tmp/clearpart # partition done via script, below in %pre %include /tmp/partition-layout ### Commands To Be Run Pre-Installation %pre --interpreter /bin/sh ( export TMP_MOUNT=/tmp-pre export NFSHOST=192.168.0.2 NFSMOUNT=/vol/pteng/osload NFSPATH="/linux/ks/centos5u2" mkdir -p ${TMP_MOUNT} mount -t nfs -o nolock ${NFSHOST}:${NFSMOUNT} ${TMP_MOUNT} DISKA=`list-harddrives | head -1 | cut -d" " -f1` partitions="`grep ${DISKA}1 /proc/partitions`" if [ "${partitions}" ]; then echo "clearpart --all" > /tmp/clearpart else echo "clearpart --initlabel" > /tmp/clearpart fi if [ -f "${TMP_MOUNT}/${NFSPATH}/packages/install-packages" ]; then cp "${TMP_MOUNT}/${NFSPATH}/packages/install-packages" /tmp/install-packages else echo "${TMP_MOUNT}/${NFSPATH}/packages/install-packages not found." fi if [ -f "${TMP_MOUNT}/${NFSPATH}/packages/remove_packages" ]; then cp "${TMP_MOUNT}/${NFSPATH}/packages/remove_packages" /tmp/remove-packages else echo "${TMP_MOUNT}/${NFSPATH}/packages/remove_packages not found" fi # Get MAC address for potential customized installs (unused at this time) MAC_ADDR=`ifconfig eth0 | grep HWaddr | sed -e 's/^.*HWaddr \([A-Fa-f0-9:]*\).*$/\1/; s/:/-/g'` if [ -f "${TMP_MOUNT}/${NFSPATH}/${MAC_ADDR}" ]; then cp "${TMP_MOUNT}/${NFSPATH}/${MAC_ADDR}" /tmp/network fi # make sure at the very least an empty partition-layout exists touch /tmp/partition-layout # check for specialized parition layout files based on MAC # address or hostname. Else call autopartition script. PART_SRC=${TMP_MOUNT}/${NFSPATH}/partition if [ -f "${PART_SRC}/${MAC_ADDR}" ]; then echo "partition data: file=${MAC_ADDR}" cp "${PART_SRC}/${MAC_ADDR}" /tmp/partition-layout elif [ -f "${PART_SRC}/linuxhost999" ]; then echo "partition data: file=linuxhost999" cp "${PART_SRC}/linuxhost999" /tmp/partition-layout elif [ -f "${PART_SRC}/autopartition" ]; then echo "partition script: file=autopartition" cp "${PART_SRC}/autopartition" /tmp/autopartition fi if [ -f /tmp/autopartition ]; then /tmp/autopartition desktop fi umount ${TMP_MOUNT} ) 2>&1 | tee /tmp/preinstall.log #### End pre-install #!/usr/bin/python # # autopartition script # Scan system for harddrives and output partitioning file for # kickstart script # Used for rhel3,rhel4,rhel5, and centos5 # import os, string import sys # for testing if (os.path.exists('isys')): sys.path.append('isys') # this is available during a kickstart sys.path.append('/usr/lib/anaconda') import isys import parted # this is in kilobytes def memInstalled(): f = open("/proc/meminfo", "r") lines = f.readlines() f.close() for l in lines: if l.startswith("MemTotal:"): fields = string.split(l) mem = fields[1] break return int(mem) # try to keep 2.4 kernel swapper happy! def swapSuggestion(quiet=0): mem = memInstalled()/1024 mem = ((mem/16)+1)*16 if mem < 2000: swap = 2000 else: swap = 2000 + mem return (swap) # 18Gig minimum disksize in megabytes # type = [ 'partition', minimum in megs, maximum in megs ] # /usr gets the excess left over. no maximum # put /, /usr, and extra swap(s) on extended # each swap partition will be 2Gig # Based on information from http://tldp.org/HOWTO/Partition # Swap should be placed on outer tracks for best performance. # if the drive is a newer style ZBR drive # partition 1 will be /boot # partition 2 will be /var # partition 3 will be extended and contain the rest ( /, /usr, additional swap(s) ) # partition 4 will be 2GB swap server = [[ '/boot', 100, 100 ], [ '/var', 2000, 6000 ], [ '/', 5000, 12000 ], [ '/usr', 8000, 0 ], [ 'swap', 2000, 8000 ]] desktop = [[ '/boot', 100, 100 ], [ '/var', 2000, 4000 ], [ '/', 5000, 10000 ], [ '/usr', 8000, 0 ], [ 'swap', 2000, 8000 ]] tester = [[ '/boot', 100, 100 ], [ '/var', 2000, 4000 ], [ '/', 5000, 10000 ], [ '/usr', 8000, 0 ], [ 'swap', 2000, 8000 ]] MinDisksize = tester[0][1] + tester[1][1] + tester[2][1] + tester[3][1]+ tester[4][1] drives = isys.hardDriveDict() driveList = drives.keys() driveList.sort() drive = driveList[0] #if isys.mediaPresent(drive): # continue # try to open and get size skip = 0 deviceFile = "/tmp/%s" % (drive,) isys.makeDevInode(drive, deviceFile) try: dev = parted.PedDevice.get(deviceFile) except: skip = 1 os.remove(deviceFile) sizeMB = (float(dev.heads * dev.cylinders * dev.sectors) / (1024 * 1024) * dev.sector_size) # assign minimums to start BootSize = tester[0][1] VarMin = tester[1][1] RootMin = tester[2][1] UsrMin = tester[3][1] SwapMin = tester[4][1] swapsugg = swapSuggestion() SwapPartitions = int(round(swapsugg / 2000.0)) MegsPerCyl = int(sizeMB / dev.cylinders) RemainingDisk = int(sizeMB) - MinDisksize # First use excess disk for swap partitions # only build make a maximum of three SwapOne = SwapMin SwapTwo = 0 SwapThree = 0 SwapPartitions = SwapPartitions - 1 if SwapPartitions > 0: if RemainingDisk > 2000: SwapTwo = 2000 else: SwapTwo = RemainingDisk RemainingDisk = RemainingDisk - SwapTwo SwapPartitions = SwapPartitions - 1 if SwapPartitions > 0: if RemainingDisk > 2000: SwapThree = 2000 else: SwapThree = RemainingDisk RemainingDisk = RemainingDisk - SwapThree SwapPartitions = SwapPartitions - 1 # Next use excess disk for /var partition VarMax = tester[1][2] VarMore = VarMax - VarMin if RemainingDisk > VarMore: VarSize = VarMax RemainingDisk = RemainingDisk - VarMore else: VarSize = VarMin + RemainingDisk RemainingDisk = 0 RootMax = tester[2][2] RootSize = RootMin UsrSize = UsrMin RootMore = RootMax - RootMin # If evenly split the remaining excess between / and /usr # until RootMax has is met. Then give everything else to /usr if RemainingDisk < (2 * RootMore): # redefine RootMore to half of remaining space RootMore = RemainingDisk / 2 RootSize = RootSize + RootMore RemainingDisk = RemainingDisk - RootMore # give other remaining half to usr UsrMore = RemainingDisk UsrSize = UsrSize + UsrMore RemainingDisk = 0 else: RootSize = RootMax RemainingDisk = RemainingDisk - RootMore # give other remaining disk to usr but UsrSize = UsrSize + RemainingDisk RemainingDisk = 0 # Subtract off 5 meg so actual disk size is not exceeded. # The /usr partition has the --grow option, so it will use # all available anyway. UsrSize = UsrSize - 5 ############################### # Caculate Cylinder Boundaries ############################### MBPerCyl = int(sizeMB / dev.cylinders) BootStartCyl = 1 BootCylSize = int(BootSize / MBPerCyl ) BootEndCyl = BootCylSize VarStartCyl = BootEndCyl + 1 VarCylSize = int(VarSize / MBPerCyl ) + 1 VarEndCyl = VarStartCyl + VarCylSize RootStartCyl = VarEndCyl + 1 RootCylSize = int(RootSize / MBPerCyl ) + 1 RootEndCyl = RootStartCyl + RootCylSize f = open("/tmp/partition-layout", "w") print >> f, "partition /boot --asprimary --size=%s --ondisk=%s --fstype=ext3" %(BootSize,drive) print >> f, "partition /var --asprimary --size=%s --ondisk=%s --fstype=ext3" %(VarSize,drive) print >> f, "partition / --asprimary --size=%s --ondisk=%s --fstype=ext3" %(RootSize,drive) print >> f, "partition /usr --size=%s --grow --ondisk=%s --fstype=ext3" %(UsrSize,drive) print >> f, "partition swap --size=%s --ondisk=%s --fstype=ext3" %(SwapOne,drive) if SwapTwo != 0: print >> f, "partition swap --size=%s --ondisk=%s --fstype=ext3" %(SwapTwo,drive) if SwapThree != 0: print >> f, "partition swap --size=%s --ondisk=%s --fstype=ext3" %(SwapThree,drive) f.close() # debug #print drive, sizeMB On Tue, 2009-01-13 at 16:30, kickstart-list-request@xxxxxxxxxx wrote: > Send Kickstart-list mailing list submissions to > kickstart-list@xxxxxxxxxx > > To subscribe or unsubscribe via the World Wide Web, visit > https://www.redhat.com/mailman/listinfo/kickstart-list > or, via email, send a message with subject or body 'help' to > kickstart-list-request@xxxxxxxxxx > > You can reach the person managing the list at > kickstart-list-owner@xxxxxxxxxx > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Kickstart-list digest..." > > ______________________________________________________________________ > Today's Topics: > > 1. kickstart fails to process %pre event (Larry Brigman) > 2. RE: kickstart fails to process %pre event (Shabazian, Chip) > 3. RE: kickstart fails to process %pre event (Shabazian, Chip) > > ______________________________________________________________________ > From: Larry Brigman <larry.brigman@xxxxxxxxx> > To: kickstart-list@xxxxxxxxxx > Subject: kickstart fails to process %pre event > Date: Tue, 13 Jan 2009 15:11:18 -0800 > > I have a kickstart file for doing RHEL5 installs. It works just fine but now as > we have moved to having more than one disk in the systems; this > automated install > breaks as it cannot determine which disk to install the system on. I > could write multiple > kickstart files to handle 1,6,12,18,24,36 and 48 disk installs but I > shouldn't need to. > > I have added a %pre script, instead, to the file to handle this case > but it doesn't seem to even be > run. We are doing the installs from pxeboot. I look at the > /tmp/ks.cfg file and it has the > %pre script embedded but the file that it creates when executed > doesn't. The logging page > (ctrl+alt+F3) does not show that the script was processed. > > Additional info > 2.6.18-53 RHEL5 kernel > anaconda-11.1.2.87-1 > > > How do I troubleshoot this problem? > > Below is my kickstart file > ----------------------------- > #platform=x86, AMD64, or Intel EM64T > # System authorization information > auth --useshadow --enablemd5 > # Clear the Master Boot Record > zerombr > #dynamic drive install > # cmdline causes no-interaction installs > cmdline > # Use text install > text > # use graphical install > # graphical > # disable asking for key on install > key --skip > # Firewall configuration > firewall --disabled > # Run the Setup Agent on first boot > firstboot --disable > # System keyboard > keyboard us > # System language > lang en_US > # Installation logging level > logging --level=info > # Install OS instead of upgrade > install > # Use network installation > # area51 > # CD Image loop mounted or copied (must match booted image) > url --url=http://10.109.0.46/repo/RHEL5/VOD > repo --name=packages --baseurl=http://10.109.0.46/packages > repo --name=EL5-latest --baseurl=http://10.109.0.46/repo/RHEL5/x86_64/ > # Network information > > # SELinux configuration > selinux --disabled > # System timezone > timezone --isUtc America/Los_Angeles > # X Window System configuration information > #xconfig --defaultdesktop=GNOME --depth=8 --resolution=800x600 --startxonboot > #reboot > %packages --nobase > kernel > bash > passwd > mkinitrd > grub > coreutils > httpd > openssh-server > openssh-clients > ftp > kexec-tools > rootfiles > sudo > sysklogd > smartmontools > yum > ntp > mdadm > traceroute > strace > man > bind-utils > tcpdump > logrotate > audit > > > # extra tools > sysstat > gdb > vim-minimal > which > > #remove un-used packages > -libhugetlbfs.i386 > -libtermcap.i386 > -system-config-securitylevel-tui > -policycoreutils > -librpm.i386 > -zlib.i386 > -sqlite.i386 > -beecrypt.i386 > -elfutils-libelf.i386 > -sysreport > -rp-pppoe > -NetworkManager > -aspell* > -words > -bluez* > -ypbind > -yptools > -nc > > > %pre --interpreter /bin/sh > #!/bin/sh > # assumes all disks for install are on the scsi bus > echo "pre kickstart script is running" >/tmp/pre-kickstart.out > #path for file > outfile=/tmp/part-include > > get_disk_paths() { > for d in `echo /sys/bus/scsi/devices/*`; > do > [ -d $d/block* ] && echo $d/block* > done > } > > convert_path_to_dev_name() { > echo $1 | sed -e 's/^.*block\://' > } > > get_queue_type() { > file=$(dirname $1)/queue_type > if [ -f $file ]; then > cat $file > else > echo "no queue type" > fi > } > > get_disk_size() { > file=$1/size > if [ -f $file ]; then > cat $file > else > echo 0 > fi > } > > is_removable() { > cat $1/removable > } > > > all_disks=$(get_disk_paths) > all_dev_names=$(for d in $all_disks; do convert_path_to_dev_name $d; done) > > #echo $all_disks > #echo $all_dev_names > > install_disk="" > install_dev="" > for dev in $all_disks; > do > #here is our test for USB flash device > #No queuing and is_removable > if [ $(get_queue_type $dev) == "none" ] && [ $(is_removable $dev) -eq 1 ] ;then > install_disk=$dev > install_dev=$(convert_path_to_dev_name $dev) > fi > done > > #no USB flash device use all of first disk > if [ -z "$install_disk" ]; then > $install_disk=$(echo $all_disk | cut -d' ' -f1) > $install_dev=$(convert_path_to_dev_name $install_disk) > fi > install_dev_size=$(get_disk_size $install_disk) > > #echo $install_disk > #echo $install_dev > #echo $install_dev_size > size_kblks=$[ $install_dev_size / 2 ] > size_Mblks=$[ size_kblks / 1000 ] > boot_size=100 > swap_size=500 > root_size=$[ $size_Mblks - $boot_size - $swap_size ] > > cat <<EOF >$outfile > #partitioning info starts here > clearpart --drives=$(echo $all_dev_names | tr ' ' ,) --all --initlabel > ignoredisk --drives=$(echo ${all_dev_names/$install_dev/} | tr ' ' , ) > > part / --fstype=ext3 --ondisk=$install_dev --size=$root_size --asprimary > part /boot --fstype=ext2 --ondisk=$install_dev --size=$boot_size --asprimary > part swap --fstype=swap --ondisk=$install_dev --size=$swap_size --asprimary > #autopart > # System bootloader configuration > bootloader --append="rhgb quiet crashkernel=128M@16M console=tty1 > console=ttyS0,38400n8" --location=mbr --driveorder=$install_dev > > EOF > > %post > #update dns and nameservers > cat >/etc/resolv.conf<<EOF > search mydns.com > nameserver 5.5.3.240 > nameserver 5.5.64.127 > EOF > > cat >/etc/yum.repos.d/packages.repo<<EOF > [packages] > name=local packages > baseurl=http://area51/packages > enabled=1 > gpgcheck=0 > EOF > > cat >/etc/yum.repos.d/rhel5_local.repo<<EOF > [rhel5] > name=Red Hat Enterprise Linux 5 local - \$basearch > baseurl=http://area51/repo/RHEL5/\$basearch > enabled=1 > gpgcheck=0 > EOF > chkconfig httpd on > # modify grub for serial console > sed -i -e 's/^timeout=5/serial --unit=0 --speed=38400 --word=8 > --parity=no --stop=1 \ > terminal --timeout=5 serial console \ > timeout=5/' /boot/grub/grub.conf > > # modify inittab to add serial console login > cat >>/etc/inittab <<EOF > > #serial console login enabled > co:2345:respawn:/sbin/agetty ttyS0 38400 vt100-nav > EOF > > # add tmpfs mounts > cat >>/etc/fstab<<EOF > tmpfs /tmp tmpfs size=20M 0 0 > tmpfs /var/tmp tmpfs size=2M 0 0 > tmpfs /var/run tmpfs size=2M 0 0 > EOF > # update for noatime > sed -i -e '1,2s/defaults/defaults,noatime,nodiratime/' /etc/fstab > > # get host info > GATEWAY=$(route -n | grep ^0.0.0.0 | awk '{print $2}') > #HOSTNAME=$(hostname) > HOSTIP=$(ifconfig eth0 | grep "inet addr" | cut -d: -f2|awk '{print $1}') > NETMASK=$(ifconfig eth0 | grep Mask | cut -d: -f4) > HOSTNAME=$(host $HOSTIP 5.5.64.127 | grep pointer | cut -d' ' -f 5 | > cut -d. -f1 ) > #FQDN=$(host $HOSTNAME 5.5.64.127 | grep address | cut -d' ' -f1) > if [ -z "$HOSTIP" ] ; then > echo "Did not find a IP address for host $HOSTNAME from Server:$DNS!" > echo "This will need to be set manually" > fi > #echo write hosts file > #echo "$HOSTIP $FQDN $HOSTNAME" >> /etc/hosts > # update network file for gateway > echo "GATEWAY=$GATEWAY" >>/etc/sysconfig/network > echo update ifcfg-eth0 for static > ( cd /etc/sysconfig/network-scripts > sed -i -e "s/dhcp/static/" ifcfg-eth0 > cat >>ifcfg-eth0 <<EOF > IPADDR=$HOSTIP > NETMASK=$NETMASK > EOF > ) > # make netreport to quiet network startup > echo "mkdir -p /var/run/netreport" >> /etc/rc.d/rc.sysinit > > # update other ethernet interfaces > HOSTNUM=$[ $(echo $HOSTNAME | perl -ln -e '/([1-9]+)$/; print "$1";') % 255] > for e in 2 3 4 5 6 7 8 9 > do > file=/etc/sysconfig/network-scripts/ifcfg-eth${e} > if [ -e $file ] ; then > netnum=$[ ${e} + 100 ] > sed -i -e "s/ONBOOT=no/ONBOOT=yes\n\ > IPADDR=172.25.${HOSTNUM}.${netnum} \n\ > NETMASK=255.255.0.0 \n\ > BOOTPROTO=static \ > /" $file > if [ ${e} -eq 2 ]; then > cat >/etc/ethers.eth${e}<<EOF_ETHERS > #nsg ethers > 00:00:00:00:00:05 172.25.100.3 > 00:00:00:00:00:05 172.25.100.2 > EOF_ETHERS > else > ( cd /etc > ln -s ethers.eth2 ethers.eth${e} > ) > fi > fi > done > sync > > %include /tmp/part-include > > > > ______________________________________________________________________ > From: "Shabazian, Chip" <Chip.Shabazian@xxxxxxxxxxxxxxxxx> > To: Discussion list about Kickstart <kickstart-list@xxxxxxxxxx> > Subject: RE: kickstart fails to process %pre event > Date: Tue, 13 Jan 2009 15:28:24 -0800 > > The best way I've found for troubleshooting pre or post scripting errors > is to simply put a sleep statement in the pre or post, then manually > walk through the script and see where it fails. > > %pre > Sleep 9999999999999 > > Chip > > -----Original Message----- > From: kickstart-list-bounces@xxxxxxxxxx > [mailto:kickstart-list-bounces@xxxxxxxxxx] On Behalf Of Larry Brigman > Sent: Tuesday, January 13, 2009 3:11 PM > To: kickstart-list@xxxxxxxxxx > Subject: kickstart fails to process %pre event > > I have a kickstart file for doing RHEL5 installs. It works just fine > but now as > we have moved to having more than one disk in the systems; this > automated install > breaks as it cannot determine which disk to install the system on. I > could write multiple > kickstart files to handle 1,6,12,18,24,36 and 48 disk installs but I > shouldn't need to. > > I have added a %pre script, instead, to the file to handle this case > but it doesn't seem to even be > run. We are doing the installs from pxeboot. I look at the > /tmp/ks.cfg file and it has the > %pre script embedded but the file that it creates when executed > doesn't. The logging page > (ctrl+alt+F3) does not show that the script was processed. > > Additional info > 2.6.18-53 RHEL5 kernel > anaconda-11.1.2.87-1 > > > How do I troubleshoot this problem? > > Below is my kickstart file > ----------------------------- > #platform=x86, AMD64, or Intel EM64T > # System authorization information > auth --useshadow --enablemd5 > # Clear the Master Boot Record > zerombr > #dynamic drive install > # cmdline causes no-interaction installs > cmdline > # Use text install > text > # use graphical install > # graphical > # disable asking for key on install > key --skip > # Firewall configuration > firewall --disabled > # Run the Setup Agent on first boot > firstboot --disable > # System keyboard > keyboard us > # System language > lang en_US > # Installation logging level > logging --level=info > # Install OS instead of upgrade > install > # Use network installation > # area51 > # CD Image loop mounted or copied (must match booted image) > url --url=http://10.109.0.46/repo/RHEL5/VOD > repo --name=packages --baseurl=http://10.109.0.46/packages > repo --name=EL5-latest --baseurl=http://10.109.0.46/repo/RHEL5/x86_64/ > # Network information > > # SELinux configuration > selinux --disabled > # System timezone > timezone --isUtc America/Los_Angeles > # X Window System configuration information > #xconfig --defaultdesktop=GNOME --depth=8 --resolution=800x600 > --startxonboot > #reboot > %packages --nobase > kernel > bash > passwd > mkinitrd > grub > coreutils > httpd > openssh-server > openssh-clients > ftp > kexec-tools > rootfiles > sudo > sysklogd > smartmontools > yum > ntp > mdadm > traceroute > strace > man > bind-utils > tcpdump > logrotate > audit > > > # extra tools > sysstat > gdb > vim-minimal > which > > #remove un-used packages > -libhugetlbfs.i386 > -libtermcap.i386 > -system-config-securitylevel-tui > -policycoreutils > -librpm.i386 > -zlib.i386 > -sqlite.i386 > -beecrypt.i386 > -elfutils-libelf.i386 > -sysreport > -rp-pppoe > -NetworkManager > -aspell* > -words > -bluez* > -ypbind > -yptools > -nc > > > %pre --interpreter /bin/sh > #!/bin/sh > # assumes all disks for install are on the scsi bus > echo "pre kickstart script is running" >/tmp/pre-kickstart.out > #path for file > outfile=/tmp/part-include > > get_disk_paths() { > for d in `echo /sys/bus/scsi/devices/*`; > do > [ -d $d/block* ] && echo $d/block* > done > } > > convert_path_to_dev_name() { > echo $1 | sed -e 's/^.*block\://' > } > > get_queue_type() { > file=$(dirname $1)/queue_type > if [ -f $file ]; then > cat $file > else > echo "no queue type" > fi > } > > get_disk_size() { > file=$1/size > if [ -f $file ]; then > cat $file > else > echo 0 > fi > } > > is_removable() { > cat $1/removable > } > > > all_disks=$(get_disk_paths) > all_dev_names=$(for d in $all_disks; do convert_path_to_dev_name $d; > done) > > #echo $all_disks > #echo $all_dev_names > > install_disk="" > install_dev="" > for dev in $all_disks; > do > #here is our test for USB flash device > #No queuing and is_removable > if [ $(get_queue_type $dev) == "none" ] && [ $(is_removable > $dev) -eq 1 ] ;then > install_disk=$dev > install_dev=$(convert_path_to_dev_name $dev) > fi > done > > #no USB flash device use all of first disk > if [ -z "$install_disk" ]; then > $install_disk=$(echo $all_disk | cut -d' ' -f1) > $install_dev=$(convert_path_to_dev_name $install_disk) > fi > install_dev_size=$(get_disk_size $install_disk) > > #echo $install_disk > #echo $install_dev > #echo $install_dev_size > size_kblks=$[ $install_dev_size / 2 ] > size_Mblks=$[ size_kblks / 1000 ] > boot_size=100 > swap_size=500 > root_size=$[ $size_Mblks - $boot_size - $swap_size ] > > cat <<EOF >$outfile > #partitioning info starts here > clearpart --drives=$(echo $all_dev_names | tr ' ' ,) --all --initlabel > ignoredisk --drives=$(echo ${all_dev_names/$install_dev/} | tr ' ' , ) > > part / --fstype=ext3 --ondisk=$install_dev --size=$root_size > --asprimary > part /boot --fstype=ext2 --ondisk=$install_dev --size=$boot_size > --asprimary > part swap --fstype=swap --ondisk=$install_dev --size=$swap_size > --asprimary > #autopart > # System bootloader configuration > bootloader --append="rhgb quiet crashkernel=128M@16M console=tty1 > console=ttyS0,38400n8" --location=mbr --driveorder=$install_dev > > EOF > > %post > #update dns and nameservers > cat >/etc/resolv.conf<<EOF > search mydns.com > nameserver 5.5.3.240 > nameserver 5.5.64.127 > EOF > > cat >/etc/yum.repos.d/packages.repo<<EOF > [packages] > name=local packages > baseurl=http://area51/packages > enabled=1 > gpgcheck=0 > EOF > > cat >/etc/yum.repos.d/rhel5_local.repo<<EOF > [rhel5] > name=Red Hat Enterprise Linux 5 local - \$basearch > baseurl=http://area51/repo/RHEL5/\$basearch > enabled=1 > gpgcheck=0 > EOF > chkconfig httpd on > # modify grub for serial console > sed -i -e 's/^timeout=5/serial --unit=0 --speed=38400 --word=8 > --parity=no --stop=1 \ > terminal --timeout=5 serial console \ > timeout=5/' /boot/grub/grub.conf > > # modify inittab to add serial console login > cat >>/etc/inittab <<EOF > > #serial console login enabled > co:2345:respawn:/sbin/agetty ttyS0 38400 vt100-nav > EOF > > # add tmpfs mounts > cat >>/etc/fstab<<EOF > tmpfs /tmp tmpfs size=20M 0 0 > tmpfs /var/tmp tmpfs size=2M 0 0 > tmpfs /var/run tmpfs size=2M 0 0 > EOF > # update for noatime > sed -i -e '1,2s/defaults/defaults,noatime,nodiratime/' /etc/fstab > > # get host info > GATEWAY=$(route -n | grep ^0.0.0.0 | awk '{print $2}') > #HOSTNAME=$(hostname) > HOSTIP=$(ifconfig eth0 | grep "inet addr" | cut -d: -f2|awk '{print > $1}') > NETMASK=$(ifconfig eth0 | grep Mask | cut -d: -f4) > HOSTNAME=$(host $HOSTIP 5.5.64.127 | grep pointer | cut -d' ' -f 5 | > cut -d. -f1 ) > #FQDN=$(host $HOSTNAME 5.5.64.127 | grep address | cut -d' ' -f1) > if [ -z "$HOSTIP" ] ; then > echo "Did not find a IP address for host $HOSTNAME from > Server:$DNS!" > echo "This will need to be set manually" > fi > #echo write hosts file > #echo "$HOSTIP $FQDN $HOSTNAME" >> /etc/hosts > # update network file for gateway > echo "GATEWAY=$GATEWAY" >>/etc/sysconfig/network > echo update ifcfg-eth0 for static > ( cd /etc/sysconfig/network-scripts > sed -i -e "s/dhcp/static/" ifcfg-eth0 > cat >>ifcfg-eth0 <<EOF > IPADDR=$HOSTIP > NETMASK=$NETMASK > EOF > ) > # make netreport to quiet network startup > echo "mkdir -p /var/run/netreport" >> /etc/rc.d/rc.sysinit > > # update other ethernet interfaces > HOSTNUM=$[ $(echo $HOSTNAME | perl -ln -e '/([1-9]+)$/; print "$1";') % > 255] > for e in 2 3 4 5 6 7 8 9 > do > file=/etc/sysconfig/network-scripts/ifcfg-eth${e} > if [ -e $file ] ; then > netnum=$[ ${e} + 100 ] > sed -i -e "s/ONBOOT=no/ONBOOT=yes\n\ > IPADDR=172.25.${HOSTNUM}.${netnum} \n\ > NETMASK=255.255.0.0 \n\ > BOOTPROTO=static \ > /" $file > if [ ${e} -eq 2 ]; then > cat >/etc/ethers.eth${e}<<EOF_ETHERS > #nsg ethers > 00:00:00:00:00:05 172.25.100.3 > 00:00:00:00:00:05 172.25.100.2 > EOF_ETHERS > else > ( cd /etc > ln -s ethers.eth2 ethers.eth${e} > ) > fi > fi > done > sync > > %include /tmp/part-include > > _______________________________________________ > Kickstart-list mailing list > Kickstart-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/kickstart-list > > > > ______________________________________________________________________ > From: "Shabazian, Chip" <Chip.Shabazian@xxxxxxxxxxxxxxxxx> > To: Discussion list about Kickstart <kickstart-list@xxxxxxxxxx> > Subject: RE: kickstart fails to process %pre event > Date: Tue, 13 Jan 2009 15:30:21 -0800 > > Damn outlook thinking for me... That's supposed to be a lower case S - > sleep 999999999999 > > -----Original Message----- > From: kickstart-list-bounces@xxxxxxxxxx > [mailto:kickstart-list-bounces@xxxxxxxxxx] On Behalf Of Shabazian, Chip > Sent: Tuesday, January 13, 2009 3:28 PM > To: Discussion list about Kickstart > Subject: RE: kickstart fails to process %pre event > > The best way I've found for troubleshooting pre or post scripting errors > is to simply put a sleep statement in the pre or post, then manually > walk through the script and see where it fails. > > %pre > Sleep 9999999999999 > > Chip > > -----Original Message----- > From: kickstart-list-bounces@xxxxxxxxxx > [mailto:kickstart-list-bounces@xxxxxxxxxx] On Behalf Of Larry Brigman > Sent: Tuesday, January 13, 2009 3:11 PM > To: kickstart-list@xxxxxxxxxx > Subject: kickstart fails to process %pre event > > I have a kickstart file for doing RHEL5 installs. It works just fine > but now as > we have moved to having more than one disk in the systems; this > automated install > breaks as it cannot determine which disk to install the system on. I > could write multiple > kickstart files to handle 1,6,12,18,24,36 and 48 disk installs but I > shouldn't need to. > > I have added a %pre script, instead, to the file to handle this case > but it doesn't seem to even be > run. We are doing the installs from pxeboot. I look at the > /tmp/ks.cfg file and it has the > %pre script embedded but the file that it creates when executed > doesn't. The logging page > (ctrl+alt+F3) does not show that the script was processed. > > Additional info > 2.6.18-53 RHEL5 kernel > anaconda-11.1.2.87-1 > > > How do I troubleshoot this problem? > > Below is my kickstart file > ----------------------------- > #platform=x86, AMD64, or Intel EM64T > # System authorization information > auth --useshadow --enablemd5 > # Clear the Master Boot Record > zerombr > #dynamic drive install > # cmdline causes no-interaction installs > cmdline > # Use text install > text > # use graphical install > # graphical > # disable asking for key on install > key --skip > # Firewall configuration > firewall --disabled > # Run the Setup Agent on first boot > firstboot --disable > # System keyboard > keyboard us > # System language > lang en_US > # Installation logging level > logging --level=info > # Install OS instead of upgrade > install > # Use network installation > # area51 > # CD Image loop mounted or copied (must match booted image) > url --url=http://10.109.0.46/repo/RHEL5/VOD > repo --name=packages --baseurl=http://10.109.0.46/packages > repo --name=EL5-latest --baseurl=http://10.109.0.46/repo/RHEL5/x86_64/ > # Network information > > # SELinux configuration > selinux --disabled > # System timezone > timezone --isUtc America/Los_Angeles > # X Window System configuration information > #xconfig --defaultdesktop=GNOME --depth=8 --resolution=800x600 > --startxonboot > #reboot > %packages --nobase > kernel > bash > passwd > mkinitrd > grub > coreutils > httpd > openssh-server > openssh-clients > ftp > kexec-tools > rootfiles > sudo > sysklogd > smartmontools > yum > ntp > mdadm > traceroute > strace > man > bind-utils > tcpdump > logrotate > audit > > > # extra tools > sysstat > gdb > vim-minimal > which > > #remove un-used packages > -libhugetlbfs.i386 > -libtermcap.i386 > -system-config-securitylevel-tui > -policycoreutils > -librpm.i386 > -zlib.i386 > -sqlite.i386 > -beecrypt.i386 > -elfutils-libelf.i386 > -sysreport > -rp-pppoe > -NetworkManager > -aspell* > -words > -bluez* > -ypbind > -yptools > -nc > > > %pre --interpreter /bin/sh > #!/bin/sh > # assumes all disks for install are on the scsi bus > echo "pre kickstart script is running" >/tmp/pre-kickstart.out > #path for file > outfile=/tmp/part-include > > get_disk_paths() { > for d in `echo /sys/bus/scsi/devices/*`; > do > [ -d $d/block* ] && echo $d/block* > done > } > > convert_path_to_dev_name() { > echo $1 | sed -e 's/^.*block\://' > } > > get_queue_type() { > file=$(dirname $1)/queue_type > if [ -f $file ]; then > cat $file > else > echo "no queue type" > fi > } > > get_disk_size() { > file=$1/size > if [ -f $file ]; then > cat $file > else > echo 0 > fi > } > > is_removable() { > cat $1/removable > } > > > all_disks=$(get_disk_paths) > all_dev_names=$(for d in $all_disks; do convert_path_to_dev_name $d; > done) > > #echo $all_disks > #echo $all_dev_names > > install_disk="" > install_dev="" > for dev in $all_disks; > do > #here is our test for USB flash device > #No queuing and is_removable > if [ $(get_queue_type $dev) == "none" ] && [ $(is_removable > $dev) -eq 1 ] ;then > install_disk=$dev > install_dev=$(convert_path_to_dev_name $dev) > fi > done > > #no USB flash device use all of first disk > if [ -z "$install_disk" ]; then > $install_disk=$(echo $all_disk | cut -d' ' -f1) > $install_dev=$(convert_path_to_dev_name $install_disk) > fi > install_dev_size=$(get_disk_size $install_disk) > > #echo $install_disk > #echo $install_dev > #echo $install_dev_size > size_kblks=$[ $install_dev_size / 2 ] > size_Mblks=$[ size_kblks / 1000 ] > boot_size=100 > swap_size=500 > root_size=$[ $size_Mblks - $boot_size - $swap_size ] > > cat <<EOF >$outfile > #partitioning info starts here > clearpart --drives=$(echo $all_dev_names | tr ' ' ,) --all --initlabel > ignoredisk --drives=$(echo ${all_dev_names/$install_dev/} | tr ' ' , ) > > part / --fstype=ext3 --ondisk=$install_dev --size=$root_size > --asprimary > part /boot --fstype=ext2 --ondisk=$install_dev --size=$boot_size > --asprimary > part swap --fstype=swap --ondisk=$install_dev --size=$swap_size > --asprimary > #autopart > # System bootloader configuration > bootloader --append="rhgb quiet crashkernel=128M@16M console=tty1 > console=ttyS0,38400n8" --location=mbr --driveorder=$install_dev > > EOF > > %post > #update dns and nameservers > cat >/etc/resolv.conf<<EOF > search mydns.com > nameserver 5.5.3.240 > nameserver 5.5.64.127 > EOF > > cat >/etc/yum.repos.d/packages.repo<<EOF > [packages] > name=local packages > baseurl=http://area51/packages > enabled=1 > gpgcheck=0 > EOF > > cat >/etc/yum.repos.d/rhel5_local.repo<<EOF > [rhel5] > name=Red Hat Enterprise Linux 5 local - \$basearch > baseurl=http://area51/repo/RHEL5/\$basearch > enabled=1 > gpgcheck=0 > EOF > chkconfig httpd on > # modify grub for serial console > sed -i -e 's/^timeout=5/serial --unit=0 --speed=38400 --word=8 > --parity=no --stop=1 \ > terminal --timeout=5 serial console \ > timeout=5/' /boot/grub/grub.conf > > # modify inittab to add serial console login > cat >>/etc/inittab <<EOF > > #serial console login enabled > co:2345:respawn:/sbin/agetty ttyS0 38400 vt100-nav > EOF > > # add tmpfs mounts > cat >>/etc/fstab<<EOF > tmpfs /tmp tmpfs size=20M 0 0 > tmpfs /var/tmp tmpfs size=2M 0 0 > tmpfs /var/run tmpfs size=2M 0 0 > EOF > # update for noatime > sed -i -e '1,2s/defaults/defaults,noatime,nodiratime/' /etc/fstab > > # get host info > GATEWAY=$(route -n | grep ^0.0.0.0 | awk '{print $2}') > #HOSTNAME=$(hostname) > HOSTIP=$(ifconfig eth0 | grep "inet addr" | cut -d: -f2|awk '{print > $1}') > NETMASK=$(ifconfig eth0 | grep Mask | cut -d: -f4) > HOSTNAME=$(host $HOSTIP 5.5.64.127 | grep pointer | cut -d' ' -f 5 | > cut -d. -f1 ) > #FQDN=$(host $HOSTNAME 5.5.64.127 | grep address | cut -d' ' -f1) > if [ -z "$HOSTIP" ] ; then > echo "Did not find a IP address for host $HOSTNAME from > Server:$DNS!" > echo "This will need to be set manually" > fi > #echo write hosts file > #echo "$HOSTIP $FQDN $HOSTNAME" >> /etc/hosts > # update network file for gateway > echo "GATEWAY=$GATEWAY" >>/etc/sysconfig/network > echo update ifcfg-eth0 for static > ( cd /etc/sysconfig/network-scripts > sed -i -e "s/dhcp/static/" ifcfg-eth0 > cat >>ifcfg-eth0 <<EOF > IPADDR=$HOSTIP > NETMASK=$NETMASK > EOF > ) > # make netreport to quiet network startup > echo "mkdir -p /var/run/netreport" >> /etc/rc.d/rc.sysinit > > # update other ethernet interfaces > HOSTNUM=$[ $(echo $HOSTNAME | perl -ln -e '/([1-9]+)$/; print "$1";') % > 255] > for e in 2 3 4 5 6 7 8 9 > do > file=/etc/sysconfig/network-scripts/ifcfg-eth${e} > if [ -e $file ] ; then > netnum=$[ ${e} + 100 ] > sed -i -e "s/ONBOOT=no/ONBOOT=yes\n\ > IPADDR=172.25.${HOSTNUM}.${netnum} \n\ > NETMASK=255.255.0.0 \n\ > BOOTPROTO=static \ > /" $file > if [ ${e} -eq 2 ]; then > cat >/etc/ethers.eth${e}<<EOF_ETHERS > #nsg ethers > 00:00:00:00:00:05 172.25.100.3 > 00:00:00:00:00:05 172.25.100.2 > EOF_ETHERS > else > ( cd /etc > ln -s ethers.eth2 ethers.eth${e} > ) > fi > fi > done > sync > > %include /tmp/part-include > > _______________________________________________ > Kickstart-list mailing list > Kickstart-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/kickstart-list > > _______________________________________________ > Kickstart-list mailing list > Kickstart-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/kickstart-list > > > > ______________________________________________________________________ > _______________________________________________ > Kickstart-list mailing list > Kickstart-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/kickstart-list _______________________________________________ Kickstart-list mailing list Kickstart-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/kickstart-list