Merge "Persistent backup partition resizing"

This commit is contained in:
Zuul 2020-05-25 17:25:39 +00:00 committed by Gerrit Code Review
commit e574d861e3
2 changed files with 32 additions and 6 deletions

View File

@ -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<<EOF>>/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<<EOF>>/tmp/part-include
part /opt/platform-backup --fstype=ext4 --asprimary --noformat --onpart=$BACKUP_PART --fsoptions="$ROOTFS_OPTIONS"
EOF

View File

@ -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<<EOF>>/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<<EOF>>/tmp/part-include
part /opt/platform-backup --fstype=ext4 --asprimary --noformat --onpart=$BACKUP_PART --fsoptions="$ROOTFS_OPTIONS"
EOF