Align partitions created by kickstarters
Partitions on some disks may be created unaligned. The cause is that the creation of partitions is done between specific intervals expressed in MBs. The kernel exposed a specific variable for each disk for providing an offset to align each partitions (/sys/block/<disk>/alignment_offset). For better granular control, we transform MB units into logical sector units and use the alignment_offset variable to properly align the partitions. Change-Id: I971c232fe0969eac14b85c5796908f0c85e23dbf Closes-bug: 1883975 Signed-off-by: Daniel Safta <daniel.safta@windriver.com>
This commit is contained in:
parent
08c8c65795
commit
0e89acc83c
@ -104,6 +104,8 @@ SCRATCH_VOL_SIZE=16000
|
|||||||
PLATFORM_BACKUP_SIZE=10000
|
PLATFORM_BACKUP_SIZE=10000
|
||||||
BOOT_SIZE=500
|
BOOT_SIZE=500
|
||||||
EFI_SIZE=300
|
EFI_SIZE=300
|
||||||
|
ONE_MiB=$(( 1024 * 1024 ))
|
||||||
|
ONE_TENTH_MiB_IN_SECTORS=200
|
||||||
|
|
||||||
ROOTFS_OPTIONS="defaults"
|
ROOTFS_OPTIONS="defaults"
|
||||||
profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
|
profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
|
||||||
@ -112,22 +114,50 @@ if [ -n "$profile_mode" ]; then
|
|||||||
ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
|
ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
BLOCK_DEVICE=$(echo $rootfs_device |awk -F/ '{ print $3 }')
|
||||||
|
|
||||||
|
optimal_io_size=$(cat /sys/block/$BLOCK_DEVICE/queue/optimal_io_size)
|
||||||
|
logical_block_size=$(cat /sys/block/$BLOCK_DEVICE/queue/logical_block_size)
|
||||||
|
alignment_offset=$(cat /sys/block/$BLOCK_DEVICE/alignment_offset)
|
||||||
|
|
||||||
|
if [ -z ${optimal_io_size} ] || [ $optimal_io_size -le 0 ]; then
|
||||||
|
optimal_io_size=$ONE_MiB
|
||||||
|
wlog "Error finding optimal_io_size. Using the default ${ONE_MiB} value"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z ${logical_block_size} ] || [ $logical_block_size -le 0 ]; then
|
||||||
|
logical_block_size=512
|
||||||
|
wlog "Error finding logical_block_size. Using the default 512 value"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z ${alignment_offset} ]; then
|
||||||
|
alignment_offset=0
|
||||||
|
wlog "Error finding alignment_offset. Using the default 0 value"
|
||||||
|
fi
|
||||||
|
|
||||||
|
wlog "Optimal IO size: ${optimal_io_size}, logical block size: ${logical_block_size}, alignment offset: ${alignment_offset}."
|
||||||
|
|
||||||
|
START_POINT=$(( ($optimal_io_size + $alignment_offset)/$logical_block_size ))
|
||||||
|
|
||||||
if [ -d /sys/firmware/efi ] ; then
|
if [ -d /sys/firmware/efi ] ; then
|
||||||
BACKUP_PART=${ROOTFS_PART_PREFIX}1
|
BACKUP_PART=${ROOTFS_PART_PREFIX}1
|
||||||
BACKUP_PART_NO=1
|
BACKUP_PART_NO=1
|
||||||
START_POINT=1
|
START_POINT=1
|
||||||
END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE))
|
SIZE_SEC=$(( ($PLATFORM_BACKUP_SIZE * $ONE_MiB )/$logical_block_size ))
|
||||||
|
END_POINT=$(( $START_POINT + $SIZE_SEC - 1 ))
|
||||||
BACKUP_END_POINT=$END_POINT
|
BACKUP_END_POINT=$END_POINT
|
||||||
if [ $BACKUP_CREATED -eq 0 ] ; then
|
if [ $BACKUP_CREATED -eq 0 ] ; then
|
||||||
wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}s to ${END_POINT}s."
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB"
|
exec_retry 5 0.5 "parted $rootfs_device mkpart primary ext4 ${START_POINT}s ${END_POINT}s"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
START_POINT=$END_POINT
|
START_POINT=$(( $END_POINT + 1 ))
|
||||||
END_POINT=$(($START_POINT + $EFI_SIZE))
|
SIZE_SEC=$(( ($EFI_SIZE * $ONE_MiB )/$logical_block_size ))
|
||||||
wlog "Creating EFI partition of ${EFI_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
END_POINT=$(( $START_POINT + $SIZE_SEC - 1))
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary fat32 ${START_POINT}MiB ${END_POINT}MiB"
|
|
||||||
|
wlog "Creating EFI partition of ${EFI_SIZE}MiB from ${START_POINT}s to ${END_POINT}s."
|
||||||
|
exec_retry 5 0.5 "parted $rootfs_device mkpart primary fat32 ${START_POINT}s ${END_POINT}s"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
|
|
||||||
cat<<EOF>>/tmp/part-include
|
cat<<EOF>>/tmp/part-include
|
||||||
@ -137,15 +167,29 @@ else
|
|||||||
BACKUP_PART=${ROOTFS_PART_PREFIX}2
|
BACKUP_PART=${ROOTFS_PART_PREFIX}2
|
||||||
BACKUP_PART_NO=2
|
BACKUP_PART_NO=2
|
||||||
wlog "Creating 1MB BIOS GRUB partition from 1MiB to 2MiB."
|
wlog "Creating 1MB BIOS GRUB partition from 1MiB to 2MiB."
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary 1MiB 2MiB"
|
# Although we calculate proper sector between which to create the bios
|
||||||
|
# partition, we still create it between 1MiB and 2MiB to take into account
|
||||||
|
# upgrade scenarios.
|
||||||
|
# If upgrading from version N to N+1, version N might have non-aligned bios
|
||||||
|
# partition, but right after it will be the platform backup partition. If
|
||||||
|
# the alignment is bad, then if we try to align the bios partition by
|
||||||
|
# shifting it right, we may come over the backup partition, that is not
|
||||||
|
# deleted by kickstarters.
|
||||||
|
# Since the bios partition is only used for booting, it not being aligned
|
||||||
|
# shouldn't cause any issues.
|
||||||
|
exec_retry 5 0.5 "parted $rootfs_device mkpart primary 1MiB 2MiB"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
|
|
||||||
START_POINT=2
|
SIZE_SEC=$(( ( $ONE_MiB )/$logical_block_size ))
|
||||||
END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE))
|
END_POINT=$(( $START_POINT + $SIZE_SEC - 1 ))
|
||||||
|
|
||||||
|
START_POINT=$(( $END_POINT + 1 ))
|
||||||
|
SIZE_SEC=$(( ($PLATFORM_BACKUP_SIZE * $ONE_MiB )/$logical_block_size ))
|
||||||
|
END_POINT=$(( $START_POINT + $SIZE_SEC - 1 ))
|
||||||
BACKUP_END_POINT=$END_POINT
|
BACKUP_END_POINT=$END_POINT
|
||||||
if [ $BACKUP_CREATED -eq 0 ] ; then
|
if [ $BACKUP_CREATED -eq 0 ] ; then
|
||||||
wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}s to ${END_POINT}s."
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB"
|
exec_retry 5 0.5 "parted $rootfs_device mkpart primary ext4 ${START_POINT}s ${END_POINT}s"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
fi
|
fi
|
||||||
cat<<EOF>>/tmp/part-include
|
cat<<EOF>>/tmp/part-include
|
||||||
@ -153,22 +197,25 @@ part biosboot --asprimary --fstype=biosboot --onpart=${ROOTFS_PART_PREFIX}1
|
|||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
START_POINT=$END_POINT
|
START_POINT=$(( $END_POINT + 1 ))
|
||||||
END_POINT=$(($START_POINT + $BOOT_SIZE))
|
SIZE_SEC=$(( ($BOOT_SIZE * $ONE_MiB )/$logical_block_size ))
|
||||||
wlog "Creating boot partition of ${BOOT_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
END_POINT=$(( $START_POINT + $SIZE_SEC - 1 ))
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB"
|
wlog "Creating boot partition of ${BOOT_SIZE}MiB from ${START_POINT}s to ${END_POINT}s."
|
||||||
|
exec_retry 5 0.5 "parted $rootfs_device mkpart primary ext4 ${START_POINT}s ${END_POINT}s"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
|
|
||||||
START_POINT=$END_POINT
|
START_POINT=$(( $END_POINT + 1 ))
|
||||||
END_POINT=$(($START_POINT + $ROOTFS_SIZE))
|
SIZE_SEC=$(( ($ROOTFS_SIZE * $ONE_MiB )/$logical_block_size ))
|
||||||
wlog "Creating rootfs partition of ${ROOTFS_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
END_POINT=$(( $START_POINT + $SIZE_SEC - 1 ))
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB"
|
wlog "Creating rootfs partition of ${ROOTFS_SIZE}MiB from ${START_POINT}s to ${END_POINT}s."
|
||||||
|
exec_retry 5 0.5 "parted $rootfs_device mkpart primary ext4 ${START_POINT}s ${END_POINT}s"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
|
|
||||||
START_POINT=$END_POINT
|
START_POINT=$(( $END_POINT + 1 ))
|
||||||
END_POINT=$(($START_POINT + $CGCS_PV_SIZE))
|
SIZE_SEC=$(( ($CGCS_PV_SIZE * $ONE_MiB )/$logical_block_size ))
|
||||||
wlog "Creating cgcs-vg partition of ${CGCS_PV_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
END_POINT=$(( $START_POINT + $SIZE_SEC - 1 ))
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart extended ${START_POINT}MiB ${END_POINT}MiB"
|
wlog "Creating cgcs-vg partition of ${CGCS_PV_SIZE}MiB from ${START_POINT}s to ${END_POINT}s."
|
||||||
|
exec_retry 5 0.5 "parted $rootfs_device mkpart extended ${START_POINT}s ${END_POINT}s"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
|
|
||||||
if [ $BACKUP_CREATED -ne 0 ] ; then
|
if [ $BACKUP_CREATED -ne 0 ] ; then
|
||||||
@ -176,8 +223,8 @@ if [ $BACKUP_CREATED -ne 0 ] ; then
|
|||||||
if [ $BACKUP_CURRENT_SIZE -lt $PLATFORM_BACKUP_SIZE ] ; then
|
if [ $BACKUP_CURRENT_SIZE -lt $PLATFORM_BACKUP_SIZE ] ; then
|
||||||
wlog "Backup partition size is ${BACKUP_CURRENT_SIZE}MiB, resizing to ${PLATFORM_BACKUP_SIZE}MiB."
|
wlog "Backup partition size is ${BACKUP_CURRENT_SIZE}MiB, resizing to ${PLATFORM_BACKUP_SIZE}MiB."
|
||||||
# parted will throw an error about overlapping with the next partition if we don't do this
|
# 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
|
BACKUP_END_POINT=$(( $BACKUP_END_POINT - $ONE_TENTH_MiB_IN_SECTORS ))
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device resizepart $BACKUP_PART_NO ${BACKUP_END_POINT}MiB"
|
exec_retry 5 0.5 "parted $rootfs_device resizepart $BACKUP_PART_NO ${BACKUP_END_POINT}s"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: resize of platform backup partition failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: resize of platform backup partition failed!"
|
||||||
exec_retry 2 0.1 "e2fsck -p -f $BACKUP_PART"
|
exec_retry 2 0.1 "e2fsck -p -f $BACKUP_PART"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: e2fsck failed on platform backup partition!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: e2fsck failed on platform backup partition!"
|
||||||
|
@ -1,37 +1,62 @@
|
|||||||
|
|
||||||
## NOTE: updates to partition sizes need to be also reflected in
|
## NOTE: updates to partition sizes need to be also reflected in
|
||||||
## _controller_filesystem_limits() in sysinv/api/controllers/v1/istorconfig.py
|
## _controller_filesystem_limits() in sysinv/api/controllers/v1/istorconfig.py
|
||||||
|
|
||||||
ROOTFS_SIZE=20000
|
ROOTFS_SIZE=20000
|
||||||
LOG_VOL_SIZE=8000
|
LOG_VOL_SIZE=8000
|
||||||
SCRATCH_VOL_SIZE=16000
|
SCRATCH_VOL_SIZE=16000
|
||||||
PLATFORM_BACKUP_SIZE=10000
|
PLATFORM_BACKUP_SIZE=10000
|
||||||
BOOT_SIZE=500
|
BOOT_SIZE=500
|
||||||
EFI_SIZE=300
|
EFI_SIZE=300
|
||||||
|
ONE_MiB=$((1024 * 1024))
|
||||||
|
ONE_TENTH_MiB_IN_SECTORS=200
|
||||||
ROOTFS_OPTIONS="defaults"
|
ROOTFS_OPTIONS="defaults"
|
||||||
profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
|
profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
|
||||||
if [ -n "$profile_mode" ]; then
|
if [ -n "$profile_mode" ]; then
|
||||||
# Enable iversion labelling for rootfs when IMA is enabled
|
# Enable iversion labelling for rootfs when IMA is enabled
|
||||||
ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
|
ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
|
||||||
fi
|
fi
|
||||||
|
BLOCK_DEVICE=$(echo $rootfs_device |awk -F/ '{ print $3 }')
|
||||||
|
|
||||||
|
optimal_io_size=$(cat /sys/block/$BLOCK_DEVICE/queue/optimal_io_size)
|
||||||
|
logical_block_size=$(cat /sys/block/$BLOCK_DEVICE/queue/logical_block_size)
|
||||||
|
alignment_offset=$(cat /sys/block/$BLOCK_DEVICE/alignment_offset)
|
||||||
|
|
||||||
|
if [ -z ${optimal_io_size} ] || [ $optimal_io_size -le 0 ]; then
|
||||||
|
optimal_io_size=$ONE_MiB
|
||||||
|
wlog "Error finding optimal_io_size. Using the default ${ONE_MiB} value"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z ${logical_block_size} ] || [ $logical_block_size -le 0 ]; then
|
||||||
|
logical_block_size=512
|
||||||
|
wlog "Error finding logical_block_size. Using the default 512 value"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z ${alignment_offset} ]; then
|
||||||
|
alignment_offset=0
|
||||||
|
wlog "Error finding alignment_offset. Using the default 0 value"
|
||||||
|
fi
|
||||||
|
|
||||||
|
wlog "Optimal IO size: ${optimal_io_size}, logical block size: ${logical_block_size}, alignment offset: ${alignment_offset}."
|
||||||
|
|
||||||
|
START_POINT=$(( ($optimal_io_size + $alignment_offset)/$logical_block_size ))
|
||||||
|
|
||||||
if [ -d /sys/firmware/efi ] ; then
|
if [ -d /sys/firmware/efi ] ; then
|
||||||
BACKUP_PART=${ROOTFS_PART_PREFIX}1
|
BACKUP_PART=${ROOTFS_PART_PREFIX}1
|
||||||
BACKUP_PART_NO=1
|
BACKUP_PART_NO=1
|
||||||
START_POINT=1
|
SIZE_SEC=$(( ($PLATFORM_BACKUP_SIZE * $ONE_MiB )/$logical_block_size ))
|
||||||
END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE))
|
END_POINT=$(( $START_POINT + $SIZE_SEC - 1 ))
|
||||||
BACKUP_END_POINT=$END_POINT
|
BACKUP_END_POINT=$END_POINT
|
||||||
if [ $BACKUP_CREATED -eq 0 ] ; then
|
if [ $BACKUP_CREATED -eq 0 ] ; then
|
||||||
wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}s to ${END_POINT}s."
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB"
|
exec_retry 5 0.5 "parted $rootfs_device mkpart primary ext4 ${START_POINT}s ${END_POINT}s"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
START_POINT=$END_POINT
|
START_POINT=$(( $END_POINT + 1 ))
|
||||||
END_POINT=$(($START_POINT + $EFI_SIZE))
|
SIZE_SEC=$(( ($EFI_SIZE * $ONE_MiB )/$logical_block_size ))
|
||||||
wlog "Creating EFI partition of ${EFI_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
END_POINT=$(( $START_POINT + $SIZE_SEC - 1))
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary fat32 ${START_POINT}MiB ${END_POINT}MiB"
|
wlog "Creating EFI partition of ${EFI_SIZE}MiB from ${START_POINT}s to ${END_POINT}s."
|
||||||
|
exec_retry 5 0.5 "parted $rootfs_device mkpart primary fat32 ${START_POINT}s ${END_POINT}s"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
|
|
||||||
cat<<EOF>>/tmp/part-include
|
cat<<EOF>>/tmp/part-include
|
||||||
@ -40,16 +65,32 @@ EOF
|
|||||||
else
|
else
|
||||||
BACKUP_PART=${ROOTFS_PART_PREFIX}2
|
BACKUP_PART=${ROOTFS_PART_PREFIX}2
|
||||||
BACKUP_PART_NO=2
|
BACKUP_PART_NO=2
|
||||||
|
|
||||||
|
# Although we calculate proper sector between which to create the bios
|
||||||
|
# partition, we still create it between 1MiB and 2MiB to take into account
|
||||||
|
# upgrade scenarios.
|
||||||
|
# If upgrading from version N to N+1, version N might have non-aligned bios
|
||||||
|
# partition, but right after it will be the platform backup partition. If
|
||||||
|
# the alignment is bad, then if we try to align the bios partition by
|
||||||
|
# shifting it right, we may come over the backup partition, that is not
|
||||||
|
# deleted by kickstarters.
|
||||||
|
# Since the bios partition is only used for booting, it not being aligned
|
||||||
|
# shouldn't cause any issues.
|
||||||
|
SIZE_SEC=$(( ( $ONE_MiB )/$logical_block_size ))
|
||||||
|
END_POINT=$(( $START_POINT + $SIZE_SEC - 1 ))
|
||||||
|
|
||||||
wlog "Creating 1MB BIOS GRUB partition from 1MiB to 2MiB."
|
wlog "Creating 1MB BIOS GRUB partition from 1MiB to 2MiB."
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary 1MiB 2MiB"
|
exec_retry 5 0.5 "parted $rootfs_device mkpart primary 1MiB 2MiB"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
|
|
||||||
START_POINT=2
|
START_POINT=$(( $END_POINT + 1 ))
|
||||||
END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE))
|
SIZE_SEC=$(( ($PLATFORM_BACKUP_SIZE * $ONE_MiB )/$logical_block_size ))
|
||||||
|
END_POINT=$(( $START_POINT + $SIZE_SEC - 1 ))
|
||||||
|
|
||||||
BACKUP_END_POINT=$END_POINT
|
BACKUP_END_POINT=$END_POINT
|
||||||
if [ $BACKUP_CREATED -eq 0 ] ; then
|
if [ $BACKUP_CREATED -eq 0 ] ; then
|
||||||
wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}s to ${END_POINT}s."
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB"
|
exec_retry 5 0.5 "parted $rootfs_device mkpart primary ext4 ${START_POINT}s ${END_POINT}s"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
fi
|
fi
|
||||||
cat<<EOF>>/tmp/part-include
|
cat<<EOF>>/tmp/part-include
|
||||||
@ -57,21 +98,23 @@ part biosboot --asprimary --fstype=biosboot --onpart=${ROOTFS_PART_PREFIX}1
|
|||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
START_POINT=$END_POINT
|
START_POINT=$(( $END_POINT + 1 ))
|
||||||
END_POINT=$(($START_POINT + $BOOT_SIZE))
|
SIZE_SEC=$(( ($BOOT_SIZE * $ONE_MiB )/$logical_block_size ))
|
||||||
wlog "Creating boot partition of ${BOOT_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
END_POINT=$(( $START_POINT + $SIZE_SEC - 1 ))
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB"
|
wlog "Creating boot partition of ${BOOT_SIZE}MiB from ${START_POINT}s to ${END_POINT}s."
|
||||||
|
exec_retry 5 0.5 "parted $rootfs_device mkpart primary ext4 ${START_POINT}s ${END_POINT}s"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
|
|
||||||
START_POINT=$END_POINT
|
START_POINT=$(( $END_POINT + 1 ))
|
||||||
END_POINT=$(($START_POINT + $ROOTFS_SIZE))
|
SIZE_SEC=$(( ($ROOTFS_SIZE * $ONE_MiB )/$logical_block_size ))
|
||||||
wlog "Creating rootfs partition of ${ROOTFS_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
END_POINT=$(( $START_POINT + $SIZE_SEC - 1 ))
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB"
|
wlog "Creating rootfs partition of ${ROOTFS_SIZE}MiB from ${START_POINT}s to ${END_POINT}s."
|
||||||
|
exec_retry 5 0.5 "parted $rootfs_device mkpart primary ext4 ${START_POINT}s ${END_POINT}s"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
|
|
||||||
START_POINT=$END_POINT
|
START_POINT=$(( $END_POINT + 1 ))
|
||||||
wlog "Creating cgcs-vg partition of ${CGCS_PV_SIZE}MiB from ${START_POINT}MiB to 100%."
|
wlog "Creating cgcs-vg partition of ${CGCS_PV_SIZE}MiB from ${START_POINT}s to 100%."
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device mkpart extended ${START_POINT}MiB 100%"
|
exec_retry 5 0.5 "parted $rootfs_device mkpart extended ${START_POINT}s 100%"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
||||||
|
|
||||||
if [ $BACKUP_CREATED -ne 0 ] ; then
|
if [ $BACKUP_CREATED -ne 0 ] ; then
|
||||||
@ -79,8 +122,8 @@ if [ $BACKUP_CREATED -ne 0 ] ; then
|
|||||||
if [ $BACKUP_CURRENT_SIZE -lt $PLATFORM_BACKUP_SIZE ] ; then
|
if [ $BACKUP_CURRENT_SIZE -lt $PLATFORM_BACKUP_SIZE ] ; then
|
||||||
wlog "Backup partition size is ${BACKUP_CURRENT_SIZE}MiB, resizing to ${PLATFORM_BACKUP_SIZE}MiB."
|
wlog "Backup partition size is ${BACKUP_CURRENT_SIZE}MiB, resizing to ${PLATFORM_BACKUP_SIZE}MiB."
|
||||||
# parted will throw an error about overlapping with the next partition if we don't do this
|
# 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
|
BACKUP_END_POINT=$(( $BACKUP_END_POINT - $ONE_TENTH_MiB_IN_SECTORS ))
|
||||||
exec_retry 5 0.5 "parted -s $rootfs_device resizepart $BACKUP_PART_NO ${BACKUP_END_POINT}MiB"
|
exec_retry 5 0.5 "parted $rootfs_device resizepart $BACKUP_PART_NO ${BACKUP_END_POINT}s"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: resize of platform backup partition failed!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: resize of platform backup partition failed!"
|
||||||
exec_retry 2 0.1 "e2fsck -p -f $BACKUP_PART"
|
exec_retry 2 0.1 "e2fsck -p -f $BACKUP_PART"
|
||||||
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: e2fsck failed on platform backup partition!"
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: e2fsck failed on platform backup partition!"
|
||||||
|
Loading…
Reference in New Issue
Block a user