Skip to content

Expanding an EBS Volume

Step 1: Modify the EBS Volume in the AWS Console

  1. Select the instance where we want to expand the EBS volume.

  1. Scroll down to the storage section and click on the EBS volume.

  1. Click the EBS volume ID to view its details.

  1. Click the Modify button.

  1. Modify the volume size from 8 GiB to 12 GiB and click Modify.

  1. Wait for Update:
  2. AWS will modify the volume in the background. You can monitor the State in the Volumes section until it shows as available.

lsblk


Step 1.1: Modify the EBS Volume Using AWS CLI

  1. Check the Volume ID:
  2. Run the following command to list all the volumes in the region:
aws ec2 describe-volumes

lsblk

  • 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 to 16 GiB:
aws ec2 modify-volume \
    --volume-id <VolumeId> \
    --size 16

lsblk

Step 2: Reflect the Changes on the EC2 Instance Using SSH Connection

  1. Verify the New Size on the Instance:
  2. SSH into your EC2 instance.

lsblk

  • Check if the OS recognizes the new volume size, and lets use it to see the file system type:
lsblk

lsblk

lsblk -f

lsblk

From the output, we can see that the file system type is xfs.

  1. Resize the partition
sudo growpart /dev/xvda 1

lsblk

This command will resize the storage partition to the maximum size available.

  1. Expand the File System:

  2. Run the following commands based on the file system type.

  3. For ext2/ext3/ext4 file systems:

    sudo resize2fs /dev/xvdf
    
  4. For XFS file systems, the same one that we had in the instance:

    sudo xfs_growfs -d /mount/point
    
  5. Replace /dev/xvdf and /mount/point with your specific device name or mount point as listed by lsblk. From the output of lsblk, you can see the mount point of the volume. Use that mount point in the command.

lsblk

  • 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:
sudo xfs_growfs -d /

lsblk

  1. Verify Expansion:
  2. Run df -h to ensure the file system reflects the new volume size.

lsblk

We have successfully expanded the EBS volume and the file system on the EC2 instance.