Expanding an EBS Volume
Step 1: Modify the EBS Volume in the AWS Console
- Select the instance where we want to expand the EBS volume.
- Scroll down to the storage section and click on the EBS volume.
- Click the EBS volume ID to view its details.
- Click the Modify button.
- Modify the volume size from
8 GiB
to12 GiB
and click Modify.
- Wait for Update:
- AWS will modify the volume in the background. You can monitor the State in the Volumes section until it shows as available.
Step 1.1: Modify the EBS Volume Using AWS CLI
- Check the Volume ID:
- Run the following command to list all the volumes in the region:
-
Copy the
VolumeId
of the volume you want to modify. -
Modify the Volume:
- Run the following command to modify the volume size. For example we want to modify the volume with
VolumeId
vol-0a8a678e064948d77
to16 GiB
:
Step 2: Reflect the Changes on the EC2 Instance Using SSH Connection
- Verify the New Size on the Instance:
- SSH into your EC2 instance.
- Check if the OS recognizes the new volume size, and lets use it to see the file system type:
From the output, we can see that the file system type is xfs
.
- Resize the partition
This command will resize the storage partition to the maximum size available.
-
Expand the File System:
-
Run the following commands based on the file system type.
-
For ext2/ext3/ext4 file systems:
-
For XFS file systems, the same one that we had in the instance:
-
Replace
/dev/xvdf
and/mount/point
with your specific device name or mount point as listed bylsblk
. From the output oflsblk
, you can see the mount point of the volume. Use that mount point in the command.
- Type in the command that suits your file system and press
Enter
. We have a XFS file system in this instance and/
is the mount point. The command is:
- Verify Expansion:
- Run
df -h
to ensure the file system reflects the new volume size.
We have successfully expanded the EBS volume and the file system on the EC2 instance.