## NOTE: updates to partition sizes need to be also reflected in ## - config/.../sysinv/conductor/manager.py:create_controller_filesystems() ## - config/.../sysinv/common/constants.py ## ## NOTE: When adding partitions, we currently have a max of 4 primary partitions. ## If more than 4 partitions are required, we can use a max of 3 --asprimary, ## to allow 1 primary logical partition with extended partitions ## ## NOTE: Max default PV size must align with the default controllerfs sizes ## ## ##*************************************************************************************************** ## Large disk install (for disks over 240GB) ## - DB size is doubled to allow for upgrades ## ## BACKUP_OVERHEAD = 5GiB ## DEFAULT_PLATFORM_STOR_SIZE = 10GiB ## DEFAULT_DATABASE_STOR_SIZE = 10GiB ## BACKUP = DEFAULT_DATABASE_STOR_SIZE + ## DEFAULT_PLATFORM_STOR_SIZE + ## BACKUP_OVERHEAD = 25GiB ## LOG_VOL_SIZE = 8GiB ## SCRATCH_VOL_SIZE = 16GiB ## RABBIT_LV = 2GiB ## DEFAULT_EXTENSION_STOR_SIZE = 1GiB ## KUBERNETES_DOCKER_STOR_SIZE = 30GiB ## DOCKER_DISTRIBUTION_STOR_SIZE = 16GiB ## ETCD_STOR_SIZE = 5GiB ## CEPH_MON_SIZE = 20GiB ## KUBELET_STOR_SIZE = 10GiB ## DC_VAULT_SIZE = 15GiB ## RESERVED_PE = 16MiB (based on pesize=32768) ## ## CGCS_PV_SIZE = (10 + 2*10 + 25 + 8 + 16 + 2 + 1 + 30 + 16 + 5 + 20 + 10 + 15)GiB + 16MiB/1024 = 178.02GiB ## ##********************************************************************************************************** ## Small disk install - (for disks below 240GB) ## - DB size is doubled to allow for upgrades ## ## DEFAULT_PLATFORM_STOR_SIZE = 10GiB ## DEFAULT_SMALL_DATABASE_STOR_SIZE = 5GiB ## DEFAULT_SMALL_BACKUP_STOR_SIZE = 20GiB ## ## LOG_VOL_SIZE = 8GiB ## SCRATCH_VOL_SIZE = 16GiB ## RABBIT_LV = 2GiB ## DEFAULT_EXTENSION_STOR_SIZE = 1GiB ## KUBERNETES_DOCKER_STOR_SIZE = 30GiB ## DOCKER_DISTRIBUTION_STOR_SIZE = 16GiB ## ETCD_STOR_SIZE = 5GiB ## CEPH_MON_SIZE = 20GiB ## KUBELET_STOR_SIZE = 10GiB ## DC_VAULT_SIZE = 15GiB ## RESERVED_PE = 16MiB (based on pesize=32768) ## ## CGCS_PV_SIZE = (10 + 2*5 + 20 + 8 + 16 + 2 + 1 + 30 + 16 + 5 + 20 + 10 + 15)GiB + 16MiB/1024 = 163.02GiB ## ##********************************************************************************************************* ## Tiny disk install - (for disks below 154GB) ## ## NOTE: Tiny disk setup is mainly for StarlingX running in QEMU/KVM VM. ## ## DEFAULT_TINY_PLATFORM_STOR_SIZE = 1GiB ## DEFAULT_TINY_DATABASE_STOR_SIZE = 1GiB ## DEFAULT_TINY_BACKUP_STOR_SIZE = 1GiB ## ## LOG_VOL_SIZE = 3GiB ## SCRATCH_VOL_SIZE = 2GiB ## RABBIT_LV = 2GiB ## DEFAULT_EXTENSION_STOR_SIZE = 1GiB ## TINY_KUBERNETES_DOCKER_STOR_SIZE = 20GiB ## TINY_DOCKER_DISTRIBUTION_STOR_SIZE = 8GiB ## TINY_ETCD_STOR_SIZE = 1GiB ## TINY_KUBELET_STOR_SIZE = 2GiB ## ## CGCS_PV_SIZE = (1 + 2*1 + 1 + 3 + 2 + 2 + 1 + 20 + 8 + 1 + 2)GiB = 43GiB ## ## MINIMUM_TINY_DISK_SIZE = CGCS_PV_SIZE + ROOTFS_SIZE + EFI_SIZE + BOOT_SIZE + PLATFORM_BACKUP_SIZE ## = 43 + 15 + 0.3 + 0.5 + 1 = 60GiB ROOTFS_SIZE=20000 LOG_VOL_SIZE=8000 SCRATCH_VOL_SIZE=16000 BOOT_SIZE=500 EFI_SIZE=300 PLATFORM_BACKUP_SIZE=$persistent_size # The default disk size thresholds must align with the ones in # config/.../sysinv/common/constants.py # which are DEFAULT_SMALL_DISK_SIZE # MINIMUM_SMALL_DISK_SIZE default_small_disk_size=240 minimum_small_disk_size=196 sz=$(blockdev --getsize64 $rootfs_device) # Round CGCS_PV_SIZE to the closest upper value that can be divided by 1024. if [ $sz -gt $(($default_small_disk_size*$gb)) ] ; then # Large disk: CGCS_PV_SIZE=179GiB*1024=183296 CGCS_PV_SIZE=183296 elif [ $sz -ge $(($minimum_small_disk_size*$gb)) ] ; then # Small disk: CGCS_PV_SIZE=164GiB*1024=167936 CGCS_PV_SIZE=167936 else # Tiny disk: CGCS_PV_SIZE=43GiB*1024=44032 # Using a disk with a size under 60GiB will fail. CGCS_PV_SIZE=44032 ROOTFS_SIZE=15000 LOG_VOL_SIZE=3000 SCRATCH_VOL_SIZE=2000 PLATFORM_BACKUP_SIZE=1000 fi 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 if [ -d /sys/firmware/efi ] ; then BACKUP_PART=${ROOTFS_PART_PREFIX}1 BACKUP_PART_NO=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}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 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 part /boot/efi --fstype=efi --onpart=${ROOTFS_PART_PREFIX}2 EOF else BACKUP_PART=${ROOTFS_PART_PREFIX}2 BACKUP_PART_NO=2 wlog "Creating 1MB BIOS GRUB partition from 1MiB to 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=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}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 part biosboot --asprimary --fstype=biosboot --onpart=${ROOTFS_PART_PREFIX}1 EOF fi 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 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 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 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 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 - 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!" exec_retry 2 1 "resize2fs $BACKUP_PART" [ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Filed to resize ext4 fs of platform backup partition!" elif [ $BACKUP_CURRENT_SIZE -gt $PLATFORM_BACKUP_SIZE ] ; then report_pre_failure_with_msg "ERROR: Backup partition is ${BACKUP_CURRENT_SIZE}MiB expected size is less or equal to ${PLATFORM_BACKUP_SIZE}MiB." else wlog "Backup partition size is correct: ${PLATFORM_BACKUP_SIZE}MiB." fi cat<>/tmp/part-include part /opt/platform-backup --fstype=ext4 --asprimary --noformat --onpart=$BACKUP_PART --fsoptions="$ROOTFS_OPTIONS" EOF else cat</tmp/backup-guid-change.sh echo "\$(date '+%Y-%m-%d %H:%M:%S.%3N') - Updating backup partition GUID." flock $rootfs_device sgdisk --change-name=${BACKUP_PART_NO}:"${BACKUP_PART_LABEL}" --typecode=${BACKUP_PART_NO}:"${BACKUP_PART_GUID}" $rootfs_device || exit 1 parted -l EOF cat<>/tmp/part-include part /opt/platform-backup --fstype=ext4 --asprimary --onpart=$BACKUP_PART --fsoptions="$ROOTFS_OPTIONS" EOF fi cat<>/tmp/part-include part /boot --fstype=ext4 --asprimary --onpart=${ROOTFS_PART_PREFIX}3 --fsoptions="$ROOTFS_OPTIONS" part pv.253004 --onpart=${ROOTFS_PART_PREFIX}5 volgroup cgts-vg --pesize=32768 pv.253004 logvol /var/log --fstype=ext4 --vgname=cgts-vg --size=$LOG_VOL_SIZE --name=log-lv logvol /scratch --fstype=ext4 --vgname=cgts-vg --size=$SCRATCH_VOL_SIZE --name=scratch-lv part / --fstype=ext4 --asprimary --onpart=${ROOTFS_PART_PREFIX}4 --fsoptions="$ROOTFS_OPTIONS" EOF