First login to the AWS console , go to the ec2 instances , select the required instance , click on ‘Storage’ and click on the ‘Volume id’ . Now select actions and choose ‘modify volume’ , increase the volume and save. Here, I have added 30G which means I am modifying my volume from default 16G to 30G . Please note the 30G is not adding to the existing 16G , its modifying the existing 16G to 30G
Now we need to extend the partition to add this extra storage to the root partition . SSH to the linux instance , and run a lsblk
Here you can see the newly added 30G but its not added to to the root partition . Now , run the growpart command ,
Run lsblk again and you can see the total volume increased to 30G .
Now we need to extend the filesystem , run the below command and you will see the root file system is still 16G
df -hT
The commands to extend the file system differ depending on the file system type. For eg: the XFS file system needs the xfs_growfs command and specify the mount point of the file system . But for our ext4 FS the below command is needed.
resize2fs /dev/xvda1
Run df -hT again