diff --git a/bsp-files/kickstarts/pre_prestaging_install_check.cfg b/bsp-files/kickstarts/pre_prestaging_install_check.cfg index 49409c87..7df3c152 100644 --- a/bsp-files/kickstarts/pre_prestaging_install_check.cfg +++ b/bsp-files/kickstarts/pre_prestaging_install_check.cfg @@ -18,22 +18,22 @@ if [ -e /run/install/repo/ks-setup.cfg ]; then fi # if force_install is set, install anyway. Ignore the remainder of this section. -if [ -z ${force_install} ]; then +if [ -z "${force_install}" ]; then if [ -z "$rootfs_device" ]; then rootfs_device=$(get_disk_dev) fi - + orig_rootfs_device=$rootfs_device by_path_rootfs_device=$(get_by_path $rootfs_device) rootfs_device=$(get_disk $by_path_rootfs_device) wlog "Found rootfs $orig_rootfs_device on: $by_path_rootfs_device->$rootfs_device." - + part_numbers=( $(parted -s ${rootfs_device} print | awk '$1 == "Number" {i=1; next}; i {print $1}') ) # print the partnumber info for informational purposes for i in ${part_numbers[@]}; do wlog "partnumber: ${i}" done - + # Get the correct rootfs prefix ROOTFS_PART_PREFIX=${rootfs_device} # check if rootfs part is nvme (eg. /dev/nvme0n1). The partitions have a "p" in the part prefix. @@ -45,10 +45,11 @@ if [ -z ${force_install} ]; then ROOTFS_PART_PREFIX=${ROOTFS_PART_PREFIX}p ;; esac - + # temporary mount directory - temp_mount=/mnt - + temp_mount=/mnt/temp_mount + mkdir -p ${temp_mount} + wlog "Searching for existing installation..." for part in "${part_numbers[@]}"; do device=${ROOTFS_PART_PREFIX}${part} @@ -69,10 +70,35 @@ if [ -z ${force_install} ]; then fi umount ${temp_mount} done + rm -rf ${temp_mount} wlog "Installing Prestaged content. No existing installation found." else # force install inspite of existing installation wlog "Force install the prestage content" wlog "Installing Prestaged content. All existing installations will be lost." fi + +# If the size of the Platform Backup partition is greater than 30GB, parted will fail when +# it tries to reconfigure the partition in a later step. We delete the partition now so that +# parted succeeds in the later step. + +partition_id=$(parted -s ${rootfs_device} print | awk '/Platform Backup/ { print $1; }') + +# if the partition id is not empty or zero, then the partition actually exists. +# Delete the partition. +if [[ "${partition_id}" -ne '' && "${partition_id}" -ne "0" ]]; then + wlog "Deleting platform backup at partition ${partition_id} on ${rootfs_device}" + + # Delete the platform backup partition + parted -s ${rootfs_device} rm ${partition_id} + rc=$? + + if [ "${rc}" -ne "0" ]; then + wlog "Unable to delete platform backup at partition ${partition_id} on ${rootfs_device}: [exit code ${rc}]" + exit -1 + else + wlog "Deleted partition ${partition_id} on ${rootfs_device}" + fi +fi + %end