Skip to main content
Graduate Track

Increasing an AWS EBS Volume Size and Extending the Linux File System

Resized an EBS volume but df still shows the old size? Snapshot, run modify-volume, then growpart and xfs_growfs or resize2fs, checking each layer with lsblk.

Increasing an AWS EBS Volume Size and Extending the Linux File System
KBY Technologies10 min readFoundation9 min

In this lesson

Advertising disclosure: this article includes partner links. KBY may earn a commission if you sign up or buy through one, at no extra cost to you. How we make money.

Share

Before you begin

  • An isolated lab AWS account and a lab Linux instance of a current generation type.
  • Shell access with sudo and the AWS CLI configured for the instance's Region.
  • Permission to create snapshots and modify volumes in the lab.

Track this tutorial

Choose your current status and tick each safety check as you complete it. Sign in to sync progress between devices.

Current status

Before you apply the change

Confirm these production-safety controls during the tutorial.

0 of 6 safety checks completed

To give a Linux EC2 instance more disk space, take a snapshot of the EBS volume, increase its size with aws ec2 modify-volume --volume-id volume-id --size new-size, wait until describe-volumes-modifications shows the modification as optimizing or completed, then grow the partition with growpart (if the volume has one) and the file system with xfs_growfs or resize2fs. With Elastic Volumes on a supported instance type, none of this needs the volume detached or the instance restarted. The key constraint is that it only goes one way: AWS documents that you cannot decrease a volume’s size or cancel a modification once submitted, so the snapshot is your only way back.

Resizing has two halves that beginners often confuse. Changing the volume makes the block device bigger in AWS; it does nothing to the partition table or file system inside the instance, so df still shows the old size until you extend them. This guide teaches both halves, then has you practise on a lab instance and check each layer as you go.

#Learning Objectives

  • Explain the three layers involved, volume, partition and file system, and which tool changes each.
  • Take a snapshot before a change and explain why it is the only rollback for a size increase.
  • Request a size increase with aws ec2 modify-volume and track it with describe-volumes-modifications.
  • Use lsblk and df -hT to decide whether the partition and file system need extending.
  • Extend an XFS or Ext4 file system and interpret the common error messages.

#Prerequisites

  • An isolated lab or sandbox AWS account, never production, and an IAM identity that may create snapshots and modify volumes there.
  • A lab Linux instance of a current generation instance type, which AWS lists as supporting Elastic Volumes, with an EBS volume that holds nothing you need.
  • Shell access to the instance with sudo. If a new instance will not accept your SSH connection, work through Fixing AWS EC2 SSH Connection Timed Out After Launching an Instance first.
  • The AWS CLI configured for the lab account and the instance’s Region, and the volume ID of the disk you will grow.

#Content

#
Three layers, three tools

An EBS volume is a block device that AWS attaches to the instance. Inside the instance the operating system sees it as a disk, such as nvme0n1 on Nitro-based instances or xvda on Xen-based ones. That disk may carry a partition, such as nvme0n1p1, and the partition (or the bare disk) carries a file system, such as XFS or Ext4, mounted at a path such as /. Each layer has its own size:

What changes each layer during a resize
LayerChanged byHow you see its size
EBS volumeaws ec2 modify-volume or the console’s Modify volumeThe disk line in lsblk; TargetSize in the modification output
Partition (if any)growpartThe part line in lsblk
File systemxfs_growfs for XFS, resize2fs for Ext4df -hT

Work from the outside in. A file system cannot grow beyond its partition, and a partition cannot grow beyond the volume. If you use logical volumes (LVM), there is an extra layer, and AWS points you to LVM’s own tools to extend the logical volume.

#
What the modification does on the AWS side

A modification moves through the states modifying, optimizing and completed. AWS documents that a size increase takes effect once the modification reaches optimizing, which usually takes a few seconds, and that you can extend the file system from that point. Performance changes can take far longer. The modification page, “Modify an Amazon EBS volume using Elastic Volumes operations”, also sets the rules you plan around: you cannot cancel a request, you can only increase size, you must wait for completed before the next modification of the same volume, and you can modify a volume up to four times in a rolling 24-hour period. There is no charge for the modification itself, but you are charged for the new configuration from when it starts.

#
Why the snapshot comes first

Because a size increase cannot be undone, the rollback for this change is not “make it smaller again”. It is the snapshot you took before you started, from which the data can be recovered if a later step damages it. AWS recommends a snapshot before modifying a volume that contains valuable data and lists it first under “Before you begin” for extending the file system. Snapshot creation is asynchronous: the snapshot stays pending until its data has been copied, and you can keep using the volume meanwhile. For a root volume, AWS recommends stopping the instance before taking the snapshot, and for any volume it recommends pausing writes so the snapshot is consistent and complete.

Detailed view of a server rack with a focus on technology and data storage.
Photo by panumas nikhomkhai on Pexels

#Examples

#
Worked example: reading lsblk before and after

AWS’s Nitro example shows a 16 GiB root volume whose partition is still 8 GiB after the volume was enlarged:

1[ec2-user ~]$ sudo lsblk
2NAME          MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
3nvme1n1       259:0    0  30G  0 disk /data
4nvme0n1       259:1    0  16G  0 disk
5└─nvme0n1p1   259:2    0   8G  0 part /
6└─nvme0n1p128 259:3    0   1M  0 part

Interpretation: the volume nvme0n1 is already 16G, so the AWS half worked, but the partition nvme0n1p1 is 8G and needs sudo growpart /dev/nvme0n1 1. Note the space between the device name and the partition number. The second volume, nvme1n1, has no partition, so for that disk you would skip growpart and go straight to the file system. After growpart, lsblk shows the partition at 16G.

#
Worked example: choosing the file system command

Run df -hT and read the Type column. In AWS’s example, /dev/nvme0n1p1 is xfs, 8.0G, mounted on /, so the command is sudo xfs_growfs -d /, which takes the mount point. For Ext4, resize2fs takes the device name instead, for example sudo resize2fs /dev/nvme0n1p1. Mixing the two up produces the clear errors described under Common Mistakes.

#Exercises

#
Exercise: grow a lab volume by 2 GiB and prove each layer

Objective: increase one lab EBS volume by a small amount and show the new space at the volume, partition and file system layers.

Safe setup and backup: in the lab account, record the volume ID and its current size. On the instance, save the output of sudo lsblk and df -hT. Then take a snapshot:

1aws ec2 create-snapshot \
2  --volume-id volume-id \
3  --description "Before resize lab"

Wait until the snapshot is no longer pending in the console’s Snapshots page before continuing, so your rollback point is complete.

  1. Request the increase: aws ec2 modify-volume --volume-id volume-id --size current-size-plus-2. Expected result: a VolumeModification object with "ModificationState": "modifying", your TargetSize and the OriginalSize.
  2. Track it: aws ec2 describe-volumes-modifications --volume-ids volume-id. Expected result: ModificationState becomes optimizing and later completed. Continue once it shows optimizing.
  3. Run sudo lsblk. Expected result: the disk shows the new size. If it has a partition that is smaller than the disk, run sudo growpart /dev/device partition-number, then lsblk again. Expected result: the partition equals the disk size.
  4. Run df -hT to find the type and mount point, then sudo xfs_growfs -d mount-point for XFS or sudo resize2fs device-name for Ext4.
  5. Run df -hT again. Expected result: the file system size now matches the volume size.

Pass condition: the volume, the partition (if any) and the file system all show the new size, and the files you had before are still present.

Stop conditions: stop if the volume ID is not the lab volume, if modify-volume returns an error, if the instance type is not one AWS lists as supporting Elastic Volumes, or if any command reports a different device or file system than you recorded. Do not detach volumes or stop production instances to work around an error.

Rollback boundary: the size increase stays. If a file system step reports one of the errors under Common Mistakes, correct the device, partition or mount point it names and retry. If data was damaged, recover it from the snapshot and escalate; do not experiment further on the damaged volume. Tag the snapshot so it can be found and cleaned up later; why consistent tags matter is covered in Enforcing AWS Resource Tagging with Tag Policies and SCPs.

#Validation Guidance

Validate each layer with its own evidence rather than one final df. The modification output proves AWS accepted the target size; describe-volumes-modifications showing optimizing or completed proves the size is usable; lsblk proves the disk and partition sizes; and df -hT proves the file system can use the space. If df is unchanged, walk back one layer at a time: is the partition the full size of the disk, and is the disk the full target size? AWS’s own troubleshooting tip when the volume still shows its original size is to confirm that the modification succeeded. Rarely, a transient AWS fault leaves a modification in a failed state; AWS says this does not indicate volume health and that you should retry the modification.

Contemporary computer on support between telecommunication racks and cabinets in modern data center
Photo by Brett Sayles on Pexels

#Common Mistakes

#
Expecting df to change on its own

Modifying the volume enlarges the block device only. Until you run growpart (where there is a partition) and the file system command, df -hT shows the old size.

#
Wrong growpart arguments

must supply partition-number means the partition was wrong or the space between device and number was missing. NOCHANGE: partition 1 is size ... it cannot be grown means the partition already fills the volume; AWS’s advice is to confirm that the volume modification succeeded. failed to make temp dir with No space left on device means the disk is too full for growpart to work; free some space and try again.

#
Using the wrong file system command

xfs_growfs: /data is not a mounted XFS filesystem means the wrong mount point or a file system that is not XFS. resize2fs: Bad magic number in super-block means the file system is not Ext4. data size unchanged, skipping or Nothing to do! means the file system already fills its partition, so check the partition step.

#
Planning to shrink it back later

You cannot decrease an EBS volume’s size. If you over-allocate, AWS’s documented path is to create a smaller volume and move the data with an application-level tool such as rsync. Size the increase deliberately.

#Key Takeaways

  • Volume, partition and file system each have a size; change them from the outside in.
  • A size increase cannot be cancelled or reversed, so the snapshot is the rollback.
  • Extend the file system once the modification reaches optimizing.
  • Use xfs_growfs with the mount point for XFS and resize2fs with the device for Ext4.
  • A volume can be modified up to four times in a rolling 24-hour period, each after the last has completed.

#Before You Resize a Production Volume

In production, the same steps carry more weight. Confirm a recent, completed snapshot or backup exists and that you know how to restore it. Agree the target size with the application owner, because the increase is permanent and billed from the start of the modification. Check that the new size stays within what the file system and partition scheme support; AWS notes that Linux boot volumes of 2 TiB or larger need GPT partitioning and GRUB 2. Give operators permission to modify volumes only where they own the workload. If the instance type does not support Elastic Volumes, AWS’s alternative for a root volume involves stopping the instance, which is a change window and an escalation, not a lab step. Your next safe decision is to record the volume ID, snapshot ID, old and new sizes and the final df -hT output in the change ticket, then delete the lab snapshot only once you no longer need it.

About this page

Credited to

Dates

Published

Sources

This page lists no external sources.

Corrections

No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.

Reader Interaction

Comments

Add a thoughtful note on Increasing an AWS EBS Volume Size and Extending the Linux File System. Comments are checked for spam and held for moderation before appearing.

Loading comments...

Discover more

Was this useful?

Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.

Build practical engineering skills.

Receive new lessons, learning paths, practical exercises and early-career guidance.