@jorp @neil :
Could the Rocky Linux AMI be built without a swap partition? That would allow the storage to be configured seamlessly.
I’m pulling in Rocky Linux 8 (ami-04826709428f49157) and when we log into the console we can see it has been provisioned with 8Gb disk and a 511Mb swap partition.
The problem is that if we provision the image (via Terraform in my case) and specify a larger disk e.g. 15Gb, then the root partition does not automatically get expanded
sh-4.4$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 15G 0 disk
├─nvme0n1p1 259:1 0 7.5G 0 part /
└─nvme0n1p2 259:2 0 511M 0 part [SWAP]
The reason is the swap partition prevents it. The only way around it requires that the swap partition be deleted so we can run growpart
and resize2fs
. To delete the partition requires running fdisk
, which is a UI and requires human interaction to delete a partition.
In other words, with the existing RockyLinux AMI, if we need a partition larger than 7.5Gb, it requires manual intervention which doesn’t work well with our otherwise-automated pipeline.
The CentOS AMI marketplace doesn’t create a swap partition, I believe for this very reason.
To reproduce: launch a RockyLinux AMI from AWS console, but specify a larger storage size than 8 e.g. 10.
Connect to the console and confirm there is only 7.5Gb available to the root partition.
If you repeat the same exercise but with a CentOS image, you’ll see the root partition is automatically expanded to match the disk size as specified in the launch parameters.