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:
- Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
- In the navigation pane, choose "Volumes."
- Select the volume you want to modify and choose "Actions," then "Modify volume."
- 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.
- 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:
-
Connect to your instance.
-
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.
-
Check if the partition needs extension by comparing sizes in the
lsblk
output. If needed, extend the partition using theresize2fs
command:[ec2-user ~]$ sudo resize2fs /dev/xvdf
-
Verify the partition extension with
lsblk
. -
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
-
Depending on the file system type:
- For XFS, use
sudo xfs_growfs -d /
. - For Ext4, use
sudo resize2fs /dev/xvda1
.
- For XFS, use
-
Verify the file system extension with
df -hT
.
These steps ensure your Linux file system is extended after resizing an EBS volume on AWS.