VMware Cloud Community
DonMig
Contributor
Contributor

Kickstart - Pre section fdisk command fails

By using the %Pre in the Kickstart.cfg for a VMWare ESX 3.02 installation we want to insure the dev/sda

drive is the correct size before we start the installation.

The problem is the fdisk command doesn't work, doesn't do anything with no output.

I confirmed the fdisk is in the path - usr/sbin coming from stage2.img, I changed the script to call the

fdisk from the /sbin directory in case there was a path issue. Just in case I ran a echo "$PATH" to

confirm the path is correct, which it was.

fdisk version 2.11y (fdisk -v)

The question is why doesn't the fdisk command work?

-


%packages

@base

%pre

#!/bin/sh

  1. init

function pause(){

read -p "$*"

}

drivesize=`fdisk -l | grep Disk | grep /dev/sda | awk '{ print $5 }'`

echo $drivesize

if [[ $drivesize -ge 62773001240 && $drivesize -le 62773003240 ]]; then

echo "Drive exists and is within limits."

else

pause 'Disk /dev/sda is not within limits. Press ENTER to reboot system'

reboot

fi

%post

-


I also tried calling the fdisk from --interpreter /usr/bin/python - same results - no output from the

command.

Any ideas on a workaround or another way to determine the size of the hard drive before we clearpart

--all.

Don...

0 Kudos
3 Replies
azn2kew
Champion
Champion

You can read more details on this site regarding UDA deployment and kickstart scripting. Each scripts are different due to variations value so check it out.[http://www.rtfm-ed.co.uk/?page_id=366] &

YIM: igeeksystems@yahoo.com

Skype: igeeksystems

Hotmail:igeeksystems@hotmail.com

Google: igeeksystems@gmail.com

If you found this information useful, please consider awarding points for "Correct" or "Helpful". Thanks!!! Regards, Stefan Nguyen VMware vExpert 2009 iGeek Systems Inc. VMware vExpert, VCP 3 & 4, VSP, VTSP, CCA, CCEA, CCNA, MCSA, EMCSE, EMCISA
0 Kudos
Schorschi
Expert
Expert

The actual environment available at %pre execution time is limited. Many libraries are not in place, commands do not work as expected or are severely limited. I have found it easier to do a OEM load, and during the actual OEM load in text mode, jump to ALT-F2, the interactive shell, and trying things to validate things really work as expected. You can extend this time by putting a read line in your %pre script as well.

DonMig
Contributor
Contributor

Thank you for your inputs:

After additional testing by pausing the installation at the %Pre state and using the interactive

Screen (alt &F2) I was able to determine the commands that were available and working.

fdisk does not work at this stage but the /proc/partitions is populated.

I modified the script to parse this file.

I also had to add "awk" to the initrd.img under the sbin directory.

-


%packages

@base

%pre

#!/bin/sh

  1. init

function pause(){

read -p "$*"

}

drivesize=`sed -n '/sda$/p' /proc/partitions | awk '{ print $3 }'`

echo $drivesize

if [[ $drivesize -ge 62773001240 && $drivesize -le 62773003240 ]]; then

echo "Drive exists and is within limits."

else

pause 'Disk /dev/sda is not within limits. Press ENTER to reboot system'

reboot

fi

%post

-


0 Kudos