Whenever you need to increase your EC2 EBS volume size follow below simple steps:
First Login to your AWS account.
2. Choose “EC2” from the services list or type EC2 on the top search bar.
3. Click on the EC2 instance that you want to increase the size.
4. Click on the storage section then you see an option like this one.
5. Click on Volume ID then you redirect to the volume screen.
6. Choose the volume that you want to resize then click on Action then click on “Modify Volume”
7. You’ll see an options window like this one:
8. Set the new size for your EBS volume (in this case I extended a 20GB volume to 30GB) and click modify.
Now, we need to extend the partition itself. So you need to
SSH to the EC2 instance where the EBS we’ve just extended is attached Disk to Part.
Follow below final steps:
Type the following command to list our disk and part:
[ec2-user ~]$ lsblk
You should be able to see a similar output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT nvme0n1 302:0 0 30G 0 disk └─nvme0n1p1 202:1 0 20G 0 part /
As you can see, the size of the root volume reflects the new size, 30GB, the size of the partition reflects the original size, 20 GB, and must be extended before you can extend the file system
To do so, type the following command:
[ec2-user ~]$ sudo growpart /dev/nvme0n1 1
Be careful, there is a space between the device name and partition number!
Now we can check that the partition reflects the increased volume size (we can check it with the lsblk command we already used):
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT nvme0n1 302:0 0 30G 0 disk └─└─nvme0n1p1 202:1 0 20G 0 part /
Last but not least, we need to extend the filesystem itself.
If your filesystem is an ext2, ext3, or ext4, type:
[ec2-user ~]$ sudo resize2fs /dev/nvme0n1p1
If your filesystem is an XFS, then type:
[ec2-user ~]$ sudo xfs_growfs /dev/nvme0n1p1
Finally, we can check our extended filesystem by typing:
[ec2-user ~]$ df -h
If everything went right, we should be able to see our effective filesystem extended size:
Filesystem Size Used Avail Use% Mounted on devtmpfs 980M 0 980M 0% /dev tmpfs 997M 0 997M 0% /dev/shm tmpfs 997M 440K 997M 1% /run tmpfs 997M 0 997M 0% /sys/fs/cgroup /dev/nvme0n1p1 30G 1,4G 19G 7% /
You have just extended your EC2 EBS volume size, enjoy!