Linux - Extend the File System of EBS Volumes
For this example, suppose that you have resized the boot volume of an instance, such as a T2 instance, from 8 GB to 16 GB and an additional
volume from 8 GB to 30 GB. Use the following procedure to extend the file system of the resized volumes.
To extend the file system of EBS volumes
1. Connect to your instance.
2. To verify the file system in use for each volume, use the df -hT command.
[ec2-user ~]$ df -hT
The following is example output for an instance that has a boot volume with an ext4 file system and an additional volume with an XFS file
system.
[ec2-user ~]$ df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/xvda1 ext4 8.0G 1.9G 6.2G 24% /
/dev/xvdf1 xfs 8.0G 45M 8.0G 1% /data
...
3. To check whether the volume has a partition that must be extended, use the lsblk command to display information about the block
devices attached to your instance.
[ec2-user ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 16G 0 disk
xvda1 202:1 0 8G 0 part /
xvdf 202:80 0 30G 0 disk
xvdf1 202:81 0 8G 0 part /data
This example output shows the following:
The root volume, /dev/xvda, has a partition, /dev/xvda1. While the size of the volume is 16 GB, the size of the partition is
still 8 GB and must be extended.
The volume /dev/xvdf has a partition, /dev/xvdf1. While the size of the volume is 30G, the size of the partition is still 8 GB
and must be extended.
4. For volumes that have a partition, such as the volumes shown in the previous step, use the growpart command to extend the partition.
Notice that there is a space between the device name and the partition number.
[ec2-user ~]$ sudo growpart /dev/xvda 1
[ec2-user ~]$ sudo growpart /dev/xvdf 1
5. (Optional) To verify that the partitions reflect the increased volume size, use the lsblk command again.
[ec2-user ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 16G 0 disk
xvda1 202:1 0 16G 0 part /
xvdf 202:80 0 30G 0 disk
xvdf1 202:81 0 30G 0 part /data
6. To verify the size of the file system for each volume, use the df -h command. In this example output, both file systems reflect the original
volume size, 8 GB.
[ec2-user ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 8.0G 1.9G 6.2G 24% /
/dev/xvdf1 8.0G 45M 8.0G 1% /data
...
7. To extend the file system on each volume, use the correct command for your file system, as follows:
[XFS volumes] To extend the file system on each volume, use the xfs_growfs command. In this example, / and /data are the
volume mount points shown in the output for df -h.
[ec2-user ~]$ sudo xfs_growfs -d /
[ec2-user ~]$ sudo xfs_growfs -d /data
If the XFS tools are not already installed, you can install them as follows.
[ec2-user ~]$ sudo yum install xfsprogs
[ext4 volumes] To extend the file system on each volume, use the resize2fs command.
[ec2-user ~]$ sudo resize2fs /dev/xvda1
[ec2-user ~]$ sudo resize2fs /dev/xvdf1
[Other file system] To extend the file system on each volume, refer to the documentation for your file system for instructions.
8. (Optional) To verify that each file system reflects the increased volume size, use the df -h command again.
[ec2-user ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 16G 1.9G 14G 12% /
/dev/xvdf1 30G 45M 30G 1% /data
...
Ref Link : https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html?icmpid=docs_ec2_console