diff --git a/bsp-files/kickstarts/pre_disk_aio.cfg b/bsp-files/kickstarts/pre_disk_aio.cfg index 56819432..ef304eb1 100755 --- a/bsp-files/kickstarts/pre_disk_aio.cfg +++ b/bsp-files/kickstarts/pre_disk_aio.cfg @@ -117,7 +117,10 @@ if [ -d /sys/firmware/efi ] ; then BACKUP_PART_NO=1 START_POINT=1 END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE)) - parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB + BACKUP_END_POINT=$END_POINT + if [ $BACKUP_CREATED -eq 0 ] ; then + parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB + fi START_POINT=$END_POINT END_POINT=$(($START_POINT + $EFI_SIZE)) @@ -133,8 +136,10 @@ else START_POINT=2 END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE)) - parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB - + BACKUP_END_POINT=$END_POINT + if [ $BACKUP_CREATED -eq 0 ] ; then + parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB + fi cat<>/tmp/part-include part biosboot --asprimary --fstype=biosboot --onpart=${ROOTFS_PART_PREFIX}1 EOF @@ -153,6 +158,14 @@ END_POINT=$(($START_POINT + $CGCS_PV_SIZE)) parted -s $ROOTFS_DISK mkpart extended ${START_POINT}MiB ${END_POINT}MiB if [ $BACKUP_CREATED -ne 0 ] ; then + BACKUP_CURRENT_SIZE=$(parted -s $BACKUP_PART unit MiB print | grep $BACKUP_PART | awk '{print $3}' | sed 's/[^C0-9]*//g') + if [ $BACKUP_CURRENT_SIZE -lt $PLATFORM_BACKUP_SIZE ] ; then + # parted will throw an error about overlapping with the next partition if we don't do this + BACKUP_END_POINT=$(($BACKUP_END_POINT - 1)).9 + parted -s $ROOTFS_DISK resizepart $BACKUP_PART_NO ${BACKUP_END_POINT}MiB + e2fsck -p -f $BACKUP_PART + resize2fs $BACKUP_PART + fi cat<>/tmp/part-include part /opt/platform-backup --fstype=ext4 --asprimary --noformat --onpart=$BACKUP_PART --fsoptions="$ROOTFS_OPTIONS" EOF diff --git a/bsp-files/kickstarts/pre_disk_controller.cfg b/bsp-files/kickstarts/pre_disk_controller.cfg index deb87e80..6399b782 100755 --- a/bsp-files/kickstarts/pre_disk_controller.cfg +++ b/bsp-files/kickstarts/pre_disk_controller.cfg @@ -21,7 +21,10 @@ if [ -d /sys/firmware/efi ] ; then BACKUP_PART_NO=1 START_POINT=1 END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE)) - parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB + BACKUP_END_POINT=$END_POINT + if [ $BACKUP_CREATED -eq 0 ] ; then + parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB + fi START_POINT=$END_POINT END_POINT=$(($START_POINT + $EFI_SIZE)) @@ -37,8 +40,10 @@ else START_POINT=2 END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE)) - parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB - + BACKUP_END_POINT=$END_POINT + if [ $BACKUP_CREATED -eq 0 ] ; then + parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB + fi cat<>/tmp/part-include part biosboot --asprimary --fstype=biosboot --onpart=${ROOTFS_PART_PREFIX}1 EOF @@ -56,6 +61,14 @@ START_POINT=$END_POINT parted -s $ROOTFS_DISK mkpart extended ${START_POINT}MiB 100% if [ $BACKUP_CREATED -ne 0 ] ; then + BACKUP_CURRENT_SIZE=$(parted -s $BACKUP_PART unit MiB print | grep $BACKUP_PART | awk '{print $3}' | sed 's/[^C0-9]*//g') + if [ $BACKUP_CURRENT_SIZE -lt $PLATFORM_BACKUP_SIZE ] ; then + # parted will throw an error about overlapping with the next partition if we don't do this + BACKUP_END_POINT=$(($BACKUP_END_POINT - 1)).9 + parted -s $ROOTFS_DISK resizepart $BACKUP_PART_NO ${BACKUP_END_POINT}MiB + e2fsck -p -f $BACKUP_PART + resize2fs $BACKUP_PART + fi cat<>/tmp/part-include part /opt/platform-backup --fstype=ext4 --asprimary --noformat --onpart=$BACKUP_PART --fsoptions="$ROOTFS_OPTIONS" EOF