Problem: well there is a guide from AWS official website but I want to make a simplified version.
This post mainly takes this website as a reference, I saw the website have some indentation problem so I make a refined version here.
Solution: we mainly using “lsblk” and “growpart” command to extend drive storage.
First, after extending current volume in EC2 instance, enter “lsblk” to get block devices information:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 20G 0 disk
└─xvda1 202:1 0 8G 0 part /
You can see the original file system size is 8G, and we extend the space from 8G to 20G. But the 12G new, fresh storage still hasn’t applied to the current system.
Second, using “growpart” to extend a partition in a partition table, we know that the current system file partition is xvda1 so enter below command:
sudo growpart /dev/xvda 1
now check again with “lsblk”
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 20G 0 disk
└─xvda1 202:1 0 20G 0 part /
Although the partition now reflects the increased volume size, last we need to extend the filesystem itself. If your filesystem is an ext2, ext3, or ext4, type:
sudo resize2fs /dev/xvda1
If your filesystem is an XFS, then type:
sudo xfs_growfs /dev/xvda1