From 5942a56ec6f0b265ca6d1c8c800fe84c4a22860f Mon Sep 17 00:00:00 2001 From: Eric MacDonald Date: Thu, 13 May 2021 15:57:43 +0000 Subject: [PATCH] Revert "Align partitions created by kickstarters" This reverts commit 0e89acc83c616741952a068a3ff07ba91440eff8. Reason for revert: Review should have been abandoned rather than merged. Change-Id: I95f1e151183f122d93b834ab2a785736e5a8ef12 Closes-Bug: 1928341 --- bsp-files/kickstarts/pre_disk_aio.cfg | 99 +++++--------------- bsp-files/kickstarts/pre_disk_controller.cfg | 99 ++++++-------------- 2 files changed, 54 insertions(+), 144 deletions(-) diff --git a/bsp-files/kickstarts/pre_disk_aio.cfg b/bsp-files/kickstarts/pre_disk_aio.cfg index df8f4552..ded2b735 100755 --- a/bsp-files/kickstarts/pre_disk_aio.cfg +++ b/bsp-files/kickstarts/pre_disk_aio.cfg @@ -104,8 +104,6 @@ SCRATCH_VOL_SIZE=16000 PLATFORM_BACKUP_SIZE=10000 BOOT_SIZE=500 EFI_SIZE=300 -ONE_MiB=$(( 1024 * 1024 )) -ONE_TENTH_MiB_IN_SECTORS=200 ROOTFS_OPTIONS="defaults" profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended` @@ -114,50 +112,22 @@ if [ -n "$profile_mode" ]; then ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion" 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 BACKUP_PART=${ROOTFS_PART_PREFIX}1 BACKUP_PART_NO=1 START_POINT=1 - SIZE_SEC=$(( ($PLATFORM_BACKUP_SIZE * $ONE_MiB )/$logical_block_size )) - END_POINT=$(( $START_POINT + $SIZE_SEC - 1 )) + END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE)) BACKUP_END_POINT=$END_POINT if [ $BACKUP_CREATED -eq 0 ] ; then - wlog "Creating platform backup partition of ${PLATFORM_BACKUP_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" + wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB." + exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" fi - START_POINT=$(( $END_POINT + 1 )) - SIZE_SEC=$(( ($EFI_SIZE * $ONE_MiB )/$logical_block_size )) - END_POINT=$(( $START_POINT + $SIZE_SEC - 1)) - - 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" + START_POINT=$END_POINT + END_POINT=$(($START_POINT + $EFI_SIZE)) + wlog "Creating EFI partition of ${EFI_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB." + exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary fat32 ${START_POINT}MiB ${END_POINT}MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" cat<>/tmp/part-include @@ -167,29 +137,15 @@ else BACKUP_PART=${ROOTFS_PART_PREFIX}2 BACKUP_PART_NO=2 wlog "Creating 1MB BIOS GRUB partition from 1MiB to 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" + exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary 1MiB 2MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" - SIZE_SEC=$(( ( $ONE_MiB )/$logical_block_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 )) + START_POINT=2 + END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE)) BACKUP_END_POINT=$END_POINT if [ $BACKUP_CREATED -eq 0 ] ; then - wlog "Creating platform backup partition of ${PLATFORM_BACKUP_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" + wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB." + exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" fi cat<>/tmp/part-include @@ -197,25 +153,22 @@ part biosboot --asprimary --fstype=biosboot --onpart=${ROOTFS_PART_PREFIX}1 EOF fi -START_POINT=$(( $END_POINT + 1 )) -SIZE_SEC=$(( ($BOOT_SIZE * $ONE_MiB )/$logical_block_size )) -END_POINT=$(( $START_POINT + $SIZE_SEC - 1 )) -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" +START_POINT=$END_POINT +END_POINT=$(($START_POINT + $BOOT_SIZE)) +wlog "Creating boot partition of ${BOOT_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB." +exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" -START_POINT=$(( $END_POINT + 1 )) -SIZE_SEC=$(( ($ROOTFS_SIZE * $ONE_MiB )/$logical_block_size )) -END_POINT=$(( $START_POINT + $SIZE_SEC - 1 )) -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" +START_POINT=$END_POINT +END_POINT=$(($START_POINT + $ROOTFS_SIZE)) +wlog "Creating rootfs partition of ${ROOTFS_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB." +exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" -START_POINT=$(( $END_POINT + 1 )) -SIZE_SEC=$(( ($CGCS_PV_SIZE * $ONE_MiB )/$logical_block_size )) -END_POINT=$(( $START_POINT + $SIZE_SEC - 1 )) -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" +START_POINT=$END_POINT +END_POINT=$(($START_POINT + $CGCS_PV_SIZE)) +wlog "Creating cgcs-vg partition of ${CGCS_PV_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB." +exec_retry 5 0.5 "parted -s $rootfs_device mkpart extended ${START_POINT}MiB ${END_POINT}MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" if [ $BACKUP_CREATED -ne 0 ] ; then @@ -223,8 +176,8 @@ if [ $BACKUP_CREATED -ne 0 ] ; 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." # parted will throw an error about overlapping with the next partition if we don't do this - BACKUP_END_POINT=$(( $BACKUP_END_POINT - $ONE_TENTH_MiB_IN_SECTORS )) - exec_retry 5 0.5 "parted $rootfs_device resizepart $BACKUP_PART_NO ${BACKUP_END_POINT}s" + BACKUP_END_POINT=$(($BACKUP_END_POINT - 1)).9 + exec_retry 5 0.5 "parted -s $rootfs_device resizepart $BACKUP_PART_NO ${BACKUP_END_POINT}MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: resize of platform backup partition failed!" exec_retry 2 0.1 "e2fsck -p -f $BACKUP_PART" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: e2fsck failed on platform backup partition!" diff --git a/bsp-files/kickstarts/pre_disk_controller.cfg b/bsp-files/kickstarts/pre_disk_controller.cfg index a76136c3..1d246027 100755 --- a/bsp-files/kickstarts/pre_disk_controller.cfg +++ b/bsp-files/kickstarts/pre_disk_controller.cfg @@ -1,62 +1,37 @@ ## NOTE: updates to partition sizes need to be also reflected in ## _controller_filesystem_limits() in sysinv/api/controllers/v1/istorconfig.py + ROOTFS_SIZE=20000 LOG_VOL_SIZE=8000 SCRATCH_VOL_SIZE=16000 PLATFORM_BACKUP_SIZE=10000 BOOT_SIZE=500 EFI_SIZE=300 -ONE_MiB=$((1024 * 1024)) -ONE_TENTH_MiB_IN_SECTORS=200 + ROOTFS_OPTIONS="defaults" profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended` if [ -n "$profile_mode" ]; then # Enable iversion labelling for rootfs when IMA is enabled ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion" 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 BACKUP_PART=${ROOTFS_PART_PREFIX}1 BACKUP_PART_NO=1 - SIZE_SEC=$(( ($PLATFORM_BACKUP_SIZE * $ONE_MiB )/$logical_block_size )) - END_POINT=$(( $START_POINT + $SIZE_SEC - 1 )) + START_POINT=1 + END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE)) BACKUP_END_POINT=$END_POINT if [ $BACKUP_CREATED -eq 0 ] ; then - wlog "Creating platform backup partition of ${PLATFORM_BACKUP_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" + wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB." + exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" fi - START_POINT=$(( $END_POINT + 1 )) - SIZE_SEC=$(( ($EFI_SIZE * $ONE_MiB )/$logical_block_size )) - END_POINT=$(( $START_POINT + $SIZE_SEC - 1)) - 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" + START_POINT=$END_POINT + END_POINT=$(($START_POINT + $EFI_SIZE)) + wlog "Creating EFI partition of ${EFI_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB." + exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary fat32 ${START_POINT}MiB ${END_POINT}MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" cat<>/tmp/part-include @@ -65,32 +40,16 @@ EOF else BACKUP_PART=${ROOTFS_PART_PREFIX}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." - exec_retry 5 0.5 "parted $rootfs_device mkpart primary 1MiB 2MiB" + exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary 1MiB 2MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" - START_POINT=$(( $END_POINT + 1 )) - SIZE_SEC=$(( ($PLATFORM_BACKUP_SIZE * $ONE_MiB )/$logical_block_size )) - END_POINT=$(( $START_POINT + $SIZE_SEC - 1 )) - + START_POINT=2 + END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE)) BACKUP_END_POINT=$END_POINT if [ $BACKUP_CREATED -eq 0 ] ; then - wlog "Creating platform backup partition of ${PLATFORM_BACKUP_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" + wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB." + exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" fi cat<>/tmp/part-include @@ -98,23 +57,21 @@ part biosboot --asprimary --fstype=biosboot --onpart=${ROOTFS_PART_PREFIX}1 EOF fi -START_POINT=$(( $END_POINT + 1 )) -SIZE_SEC=$(( ($BOOT_SIZE * $ONE_MiB )/$logical_block_size )) -END_POINT=$(( $START_POINT + $SIZE_SEC - 1 )) -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" +START_POINT=$END_POINT +END_POINT=$(($START_POINT + $BOOT_SIZE)) +wlog "Creating boot partition of ${BOOT_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB." +exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" -START_POINT=$(( $END_POINT + 1 )) -SIZE_SEC=$(( ($ROOTFS_SIZE * $ONE_MiB )/$logical_block_size )) -END_POINT=$(( $START_POINT + $SIZE_SEC - 1 )) -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" +START_POINT=$END_POINT +END_POINT=$(($START_POINT + $ROOTFS_SIZE)) +wlog "Creating rootfs partition of ${ROOTFS_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB." +exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" -START_POINT=$(( $END_POINT + 1 )) -wlog "Creating cgcs-vg partition of ${CGCS_PV_SIZE}MiB from ${START_POINT}s to 100%." -exec_retry 5 0.5 "parted $rootfs_device mkpart extended ${START_POINT}s 100%" +START_POINT=$END_POINT +wlog "Creating cgcs-vg partition of ${CGCS_PV_SIZE}MiB from ${START_POINT}MiB to 100%." +exec_retry 5 0.5 "parted -s $rootfs_device mkpart extended ${START_POINT}MiB 100%" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!" if [ $BACKUP_CREATED -ne 0 ] ; then @@ -122,8 +79,8 @@ if [ $BACKUP_CREATED -ne 0 ] ; 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." # parted will throw an error about overlapping with the next partition if we don't do this - BACKUP_END_POINT=$(( $BACKUP_END_POINT - $ONE_TENTH_MiB_IN_SECTORS )) - exec_retry 5 0.5 "parted $rootfs_device resizepart $BACKUP_PART_NO ${BACKUP_END_POINT}s" + BACKUP_END_POINT=$(($BACKUP_END_POINT - 1)).9 + exec_retry 5 0.5 "parted -s $rootfs_device resizepart $BACKUP_PART_NO ${BACKUP_END_POINT}MiB" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: resize of platform backup partition failed!" exec_retry 2 0.1 "e2fsck -p -f $BACKUP_PART" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: e2fsck failed on platform backup partition!"