diff --git a/kickstart/files/miniboot.cfg b/kickstart/files/miniboot.cfg index 325fe767..b0a71161 100644 --- a/kickstart/files/miniboot.cfg +++ b/kickstart/files/miniboot.cfg @@ -980,6 +980,32 @@ for arg in $*; do esac done +# Handle persistent_size setting. +# If the persistent_size is less than the size of the existing persistent backup, +# then the installation process must terminate and exit. + +if [ -n "${persistent_size}" ]; then + part=$(readlink -f "/dev/disk/by-partlabel/platform_backup") + device=$(readlink -f "${rootfs_device}") + + ilog "Persistent backup is in ${part}" + + MAX_SIZE=$(parted -s ${device} unit MiB print | grep "Disk ${device}:" | awk '{print $3}' | sed 's/[^C0-9]*//g') + CURRENT_PERSISTENT_SIZE=$(parted -s ${part} unit MiB print | grep ${part} | awk '{print $3}' | sed 's/[^C0-9]*//g') + ilog "Current size of persistent backup is ${CURRENT_PERSISTENT_SIZE}" + ilog "Max size of ${device} is ${MAX_SIZE}" + + if [ ${persistent_size} -lt ${CURRENT_PERSISTENT_SIZE} ]; then + ilog "Provided persistent_size (${persistent_size}) is less than ${CURRENT_PERSISTENT_SIZE}" + report_failure_with_msg "Persistent size setting is less than current backup size (${CURRENT_PERSISTENT_SIZE})" + fi + + if [ ${persistent_size} -gt ${MAX_SIZE} ]; then + ilog "Provided persistent_size (${persistent_size}) is greater than ${MAX_SIZE}" + report_failure_with_msg "Persistent size setting is greater than maximum allowable size (${MAX_SIZE})" + fi +fi + # Note: This is equivalent to pre_disk_setup_common.cfg # Name : check_execs @@ -1669,12 +1695,8 @@ if [ "${controller}" = true ] ; then # Default backup partition size in MiB ilog "Platform Backup persistent size not on command line ; defaulting to ${BACKUP_SIZE}" else - if [ ${persistent_size} -lt ${BACKUP_SIZE} ] ; then - report_failure_with_msg "Cannot set persistent_size smaller than ${BACKUP_SIZE} MiB" - else - ilog "Using Platform Backup persistent size from boot command: ${persistent_size}" - BACKUP_SIZE=${persistent_size} - fi + ilog "Using Platform Backup persistent size from boot command: ${persistent_size}" + BACKUP_SIZE=${persistent_size} fi backup_part_extension_required=0 if [ ${BACKUP_PART_CURRENT_SIZE} -gt 0 ]; then