Expanding EBS Volumes on AWS: A Step-by-Step Guide for Linux Instances

Prateek Malhotra
3 min readSep 22, 2023

--

You can extend the EBS (Elastic Block Store) volume of a running EC2 instance in Linux without shutting down the server by following these steps:

Important Note: Before proceeding, ensure that you have a backup of your data and understand the risks associated with storage operations.

Create a Snapshot (Optional but Recommended):

It’s a good practice to create a snapshot of your EBS volume before making any changes. Snapshots act as backups and can be used to restore data if anything goes wrong.

a. Go to the AWS Management Console.

b. Navigate to the “EC2” service.

c. In the left sidebar, click on “Volumes.”

d. Select the EBS volume you want to extend.

e. Click on the “Actions” dropdown menu and select “Create Snapshot.”

f. Follow the prompts to create the snapshot.

Resize the EBS Volume:

  1. Once you have the snapshot (or if you choose to skip this step), go to the “Volumes” section in the EC2 dashboard.
  1. Select the EBS volume you want to extend.
  2. Click on the “Actions” dropdown menu and select “Modify Volume.”
  1. In the “Modify Volume” dialog, increase the size of the volume to your desired size.
  1. Click the “Modify” button.
  2. The volume size is now increased, but the Linux file system is not yet aware of the change.
The new Size will reflect after the volume state goes 100% completed
Volume state shows — in use and the size shows the correct update size of EBS volume
  1. Resize the File System:
  2. To make the Linux file system aware of the increased volume size, you’ll need to resize it.
  3. SSH into your EC2 instance and identify the block device of the volume you want to resize. You can use the lsblk or df -h command to list the devices and their sizes. For example:
lsblk # or df -h

Use the resize2fs (for ext2, ext3, and ext4 file systems) or xfs_growfs (for XFS file systems) command to resize the file system. Replace /dev/xvdf with your actual block device:

Use the growpart command to resize (grow) a partition on a block device to occupy all available space.

sudo growpart  /dev/xvdf 

For ext2/3/4:


sudo resize2fs /dev/xvdf

For XFS:


sudo xfs_growfs /mnt/myvolume

After resizing the file system, you can verify the new size with df -h.

Your EBS volume should now be successfully extended without shutting down the EC2 instance. Remember that the specific commands and file system tools may vary depending on the Linux distribution you are using. Always make sure to back up your data and understand the risks before performing any storage operations.

--

--

Prateek Malhotra

I am Prateek Malhotra , a passionate DevOps Engineer with a deep love for implementing new technologies.