Resizing Disk - increasing the size

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

  1. 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

  2. Find the volume that needs to be resized in AWS Web Console

  3. Click on Modify to modify the volume size

  4. Provide the new volume size - greater than the current volume size and then save changes

  5. Once done, monitor the volume status of the volume to understand and monitor the progress of the volume resize

  6. 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

  7. 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"
  1. SSH into the EC2 instance that the volume is attached to

  2. 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
  1. 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

  2. Use df -HT to know the file system type, size, mount point and usage

  3. For 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
  1. Use df -HT again to check if the resize succeeded 🙂

References: