I am running packer with an extra disk set to 10GB and on Cloudformation I want one of my Launch Template to use another volume size (let's take 20GB).
If I add a file system directly to the disk then it's fine, this will use the extra space added (the 10GB extra) like it is part of it.
mkfs -t ext4 $EXTRA_DISK
Now I want to create multiple partitions on that disk and I want to use that extra space left (10GB) instead of leaving it unpartitioned.
But if I partition the disk then they will have a fixed size and that 10GB left in the volume will be unused.
parted -a optimal $EXTRA_DISK mklabel gpt
parted -a optimal $EXTRA_DISK mkpart primary 0% 40%
parted -a optimal $EXTRA_DISK mkpart primary 40% 100%
#
PARTITIONS=$(fdisk -l | grep nvme | grep -v $BOOT_DISK | awk '{print $1}' | sed '1d' | cut -d':' -f1)
for partition in $PARTITIONS; do mkfs.ext4 $partition; done
Is there a way to make sure that at least one partition is using all the space left when CF Launch Template has a higher volume size or is it just impossible (which would makes sense as I'm defining the partition beforehand)?