Increasing Volume Size|AWS|EC2| Cheat Sheet

Follow these 10 simple steps to increase the volume size of the EBS backed EC2 instance.

Let’s first confirm the current configurations -

Step 1: Login to your instance using SSH

Step 2: List all the block devices currently mounted on your machine
sudo lsblk

// this command will show all the mounted volumes of your machine. The EBS Block volume will be shown as the Block Name followed by the partition name
// here, Block Name : xvda and Disk Partition Name is : xvda1
with current size of 8GB.

Step 3: List the current size for filesystem
sudo df -h

// this shows the total available[7.7G] and total occupied[6.8G] space by the file system

Step 4: List out the type of filesystem
sudo file -sL /dev/xvda1

Note: Change the partition name according to your instance configurations

//here we have ext4 as our filesystem type

Let’s now increase the volume size of the instance -

Step 5: Visit AWS console and select the volume whose size has to be increased

Step 6: Click Modify and enter the appropriate size you want to have for the volume

Step 7: Again login to your instance using SSH

Step 8: Check the new disk size available using
sudo lsblk
// You will see the block size is updated with the new size but the partition is still occupying the same memory as earlier

Step 9: To update the partition size use
growpart /dev/xvda 1

// new updated size of volume 100G

Step 10: Increase the size for filesystem
resize2fs /dev/xvda1

To verify the size of the filesystem use:
sudo df -h

// this shows new size available for filesystem as 97G

Note: in every command please change the partition name as per your configuration

Cheers !! You successfully increased the volume size of your EC2 instance.

Engineer trying have "T" shaped skill set