I am trying to do an upgrade on a VMWare appliance. I am getting an error, and I dug into the script that is causing the error and will post the statement that is causing the error. Basically, my software seems to want an additional partition before it will do the upgrade. So, I added a new partition to the VM and left it in every possible state - formatted, not formatted, mounted, not mounted.. etc. I am going to post the script, if you can help me understand what the fdisk -l (list fdisk) output is causing this to error - I would appreciate it. I will also post the section that is next which is what would happen if it succeeded. Thank you in advance for your help.
function vmware_check_additional_disk()
{
if [ "$MODEL" == "VMWARE" ]; then
LogMessage "INFO" "VMWARE - verify additional disk is available..."
TMPFILE1=`mktemp -t ap.tmp.XXXXXXXX` || exit 1
TMPFILE2=`mktemp -t ap.tmp.XXXXXXXX` || exit 1
# Require additional disk added to the VM first if not abort.
RESET_HDD=$(fdisk -l 2>&1 | grep "contain a valid partition table" | awk '{print $2}' | tail -n1)
if [ -z $RESET_HDD ]; then
rm -f /tmp/ap.tmp.*
LogMessage "ERROR" "VMWARE - Unable to locate new empty partition added to the VM..."
return 1
fi
RESET_PARTITION="${RESET_HDD}1"
echo "p\n" > $TMPFILE1
echo "q\n" >> $TMPFILE1
fdisk $RESET_HDD < $TMPFILE1 > $TMPFILE2 2>&1
HDD_SIZE_TMP=$(egrep '^Disk' $TMPFILE2 | awk '{print $5}')
is_integer $HDD_SIZE_TMP
if [ $? -ne 0 ]; then
rm -f /tmp/ap.tmp.*
LogMessage "ERROR" "VMWARE - Unable to determine disk size $HDD_SIZE bytes..."
return 1
fi
# convert bytes to MG
HDD_SIZE=$(($HDD_SIZE_TMP>>20))
if [ $HDD_SIZE -lt 2000 ]; then
rm -f /tmp/ap.tmp.*
LogMessage "ERROR" "VMWARE - Can't setup reset image in partition smaller than 2000 MB"
return 1
fi
rm -f /tmp/ap.tmp.*
fi