We sometimes resize disks in AWS at Togai. We do this manually. Below is the guide for the same. We only talk about how to increase the size of a disk, not decrease
Follow these steps 🪜 to increase the size of a disk/volume
Do all the steps with the volume attached to the running EC2 instance. All the volumes we use support resizing (increasing the size) of volume while it’s attached to the running EC2 instance. Do check if there are any programs running in the EC2 instance that are dependent on the volume and if it will get affected due to the online resizing of the volume i.e. resizing when it’s attached to the EC2 instance and the EC2 instance is up and running
Find the volume that needs to be resized in AWS Web Console
Click on
Modify
to modify the volume sizeProvide the new volume size - greater than the current volume size and then save changes
Once done, monitor the volume status of the volume to understand and monitor the progress of the volume resize
Once the volume shows that it’s in use and that it’s not in modifying state (it’s probably moved on to optimizing state / completed ✔️ state), follow the below steps
Find out the hypervisor type of the instance. Usually, all the instances we use are Nitro instances. If not sure, use the below command to find out
aws ec2 describe-instance-types --instance-type <instance_type> --query "InstanceTypes[].Hypervisor"
SSH into the EC2 instance that the volume is attached to
Use the following command to find the mount point of the volume and ensure it has no partitions (type
part
) in it / under it
sudo lsblk
If the volume has partitions, follow https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html or else move on to the next step
Use
df -HT
to know the file system type, size, mount point and usageFor
xfs
(XFS) file system, use the following command to resize
sudo xfs_growfs -d <mount-point>
# for example
sudo xfs_growfs -d /blah-mount-point
- Use
df -HT
again to check if the resize succeeded 🙂
References:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-modify-volume.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/modify-volume-requirements.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/requesting-ebs-volume-modifications.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/monitoring-volume-modifications.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html