We have a bunch of micro EC2 instances for some of our services. These have a default storage size of 20GB which sometimes is too little. To increase the storage disk size, follow these steps:

  1. Locate the instance in your EC2 dashboard and click on the Instance ID.
  2. Click on the Storage tab and then on the Volume ID
  3. In the Actions dropdown at the top of the page, click Modify Volume
  4. Set the new size and save.

Now you have increased the size of the disk, but not the current partition. To do so you need to SSH into your server and run: lsblk

This will give you something like this:

nvme0n1     259:0    0   30G  0 disk
└─nvme0n1p1 259:1    0   20G  0 part /

This information tells us that we can increase the nvme0n1p1 partition with 10G. Run: sudo growpart /dev/nvme0n1 1 and then run lsblk again:

nvme0n1     259:0    0   30G  0 disk
└─nvme0n1p1 259:1    0   30G  0 part /

If we now run df -h we still get:

Filesystem      Size  Used Avail Use% Mounted on
/dev/root        20G   20G   91M 100% /

Bah! Still 20G?!

Apparently we need to extend the filesystem for each volume to use all space the partition has which we can do by running: sudo resize2fs /dev/nvme0n1p1. If we run df -h again, we get:

Filesystem      Size  Used Avail Use% Mounted on
/dev/root        30G   20G  9.8G  67% /

Et voila! We now have increased the EC2 storage volume from 20G to 30G.


Reference: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html