Modify EBS Volume and Extend Linux File System on AWS

Modifying EBS Volume on AWS

If you need to modify an Elastic Block Store (EBS) volume on Amazon Web Services (AWS), follow these steps using the AWS Management Console:

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
  2. In the navigation pane, choose "Volumes."
  3. Select the volume you want to modify and choose "Actions," then "Modify volume."
  4. On the "Modify volume" screen, you'll see the current configuration, including type, size, IOPS, and throughput. Adjust the settings as needed:
    • To modify the type, select a value for Volume type.
    • To modify the size, enter a new value for Size.
    • For gp3, io1, and io2 types, modify IOPS by entering a new value.
    • For gp3 type, modify Throughput by entering a new value.
  5. After making changes, choose "Modify." Confirm the modifications when prompted.

Why Can't You Decrease the Size of an EBS Volume?

EBS volumes cannot be decreased in size due to technical constraints. When you modify a volume, AWS only allows increasing its size, not decreasing. This limitation is inherent in the architecture and ensures data integrity and consistent performance.

Extending a Linux File System After Resizing an EBS Volume

To extend a file system on Linux after resizing an EBS volume, follow these steps:

  1. Connect to your instance.

  2. If your volume has a partition, extend it. Use the lsblk command to check for a partition.

    [ec2-user ~]$ sudo lsblk
    NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    xvda    202:0    0  8G  0 disk
    └─xvda1 202:1    0   7.2G  0 part /
    xvdf    202:80   0  24G  0 disk
    

    If there's a partition, proceed to the next step. If not, skip to step 3.

  3. Check if the partition needs extension by comparing sizes in the lsblk output. If needed, extend the partition using the resize2fs command:

    [ec2-user ~]$ sudo resize2fs /dev/xvdf
    
  4. Verify the partition extension with lsblk.

  5. Extend the file system. Use df -hT to get information about the file system.

    [ec2-user ~]$ df -hT
    Filesystem      Type   Size    Used   Avail   Use%   Mounted on
    /dev/xvdf      ext4   24.0G    1.9G   22.1G    10%    /data
    
  6. Depending on the file system type:

    • For XFS, use sudo xfs_growfs -d /.
    • For Ext4, use sudo resize2fs /dev/xvda1.
  7. Verify the file system extension with df -hT.

These steps ensure your Linux file system is extended after resizing an EBS volume on AWS.

Click Here for Demo Video