Expand AWS Disk Space in Linux (Without LVM) EC2
Got a request from team saying that expand the disk space of AWS EC2 instance. When i verify the disk it does not have LVM then how to expand AWS Disk space in Linux without LVM. Remember it is a production instance.
Lets see how to do it.
Expand AWS disk space in Linux without LVM
Snapshot first (safety).
Increase EBS volume size in the AWS Console or with aws ec2 modify-volume.
On the EC2 instance:
- a) Verify the new size: lsblk
- b) If there’s a partition, expand it: growpart DISK PART#
- c) Grow the filesystem:
ext4 → resize2fs xfs → xfs_growfs
Confirm: df -hT.
If your Linux EC2 instance uses plain partitions (no LVM), expanding EBS is straightforward. This article shows every command you’ll need to increase AWS disk space safely for ext4 and XFS filesystems on Amazon Linux, Ubuntu, RHEL, CentOS, Rocky, Alma—covering both Nitro (NVMe /dev/nvme0n1) and older Xen (/dev/xvda) device naming.
Prerequisites
-
EC2 instance uses EBS (not ephemeral instance-store).
-
You have SSH access with sudo privileges.
-
Filesystem is ext4 or xfs (check with
df -hT
). -
AWS CLI optional (only if you prefer CLI to Console).
-
Install tools:
# Debian/Ubuntu sudo apt update && sudo apt install -y cloud-guest-utils gdisk xfsprogs # RHEL/CentOS/Alma/Rocky/Amazon Linux 2+ sudo yum install -y cloud-utils-growpart gdisk xfsprogs || sudo dnf install -y cloud-utils-growpart gdisk xfsprogs
Tip: cloud-utils-growpart provides growpart, the safest way to expand partitions.
Take a Snapshot (Always!)
Before changing disk layout:
# Identify the root device and volume ID (NVMe shows volume ID in serial) sudo lsblk -o NAME,SIZE,TYPE,MOUNTPOINT # If NVMe: sudo nvme list | awk '/Amazon Elastic Block Store/{print}'
In the AWS Console: EC2 → Elastic Block Store → Volumes → Select volume → Actions → Create snapshot.
# Replace with your actual volume-id aws ec2 create-snapshot --volume-id vol-0abc123def456 --description "Pre-expansion snapshot"
2) Increase the EBS Volume Size
Option A — AWS Console
EC2 → Volumes → select your volume → Actions → Modify volume → set new size (e.g., 100 GiB) → Modify → Accept.
Option B — AWS CLI
# Increase to 100 GiB (example) aws ec2 modify-volume --volume-id vol-0abc123def456 --size 100 # (Optional) Watch progress aws ec2 describe-volumes-modifications --volume-id vol-0abc123def456 --query "VolumesModifications[0].{State:ModificationState,Progress:Progress,TargetSize:TargetSize}"
You can continue while the modification is optimizing; you only need the new size recognized by the OS.
3) Verify the OS Sees the New Size
SSH into the instance:
# Show block devices and partitions lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT # Check filesystem type and mount points df -hT
You’ll typically see one of these root layouts:
-
Partitioned disk:
/
on/dev/nvme0n1p1
(Nitro) or/dev/xvda1
(Xen). -
No partition (rare): filesystem directly on
/dev/nvme0n1
or/dev/xvda
.
4) Expand the Partition (if you have one)
Skip this section if your filesystem is directly on the disk (no
p1
or1
).
Find your root device & partition
# Find the block device backing / ROOT_SRC=$(findmnt -n -o SOURCE /) echo "Root is on: $ROOT_SRC" # e.g., /dev/nvme0n1p1 or /dev/xvda1 # Derive the base disk and partition number if [[ "$ROOT_SRC" =~ nvme.*p([0-9]+)$ ]]; then PARTNUM="${BASH_REMATCH[1]}" DISK="${ROOT_SRC%p$PARTNUM}" # /dev/nvme0n1 elif [[ "$ROOT_SRC" =~ ([0-9]+)$ ]]; then PARTNUM="${BASH_REMATCH[1]}" DISK="${ROOT_SRC%$PARTNUM}" # /dev/xvda else echo "Unrecognized root device naming; handle manually." fi echo "Disk: $DISK Partition: $PARTNUM"
Run growpart
# Expand the partition to use all free space sudo growpart "$DISK" "$PARTNUM" # Re-read partition table sudo partprobe "$DISK" || true # Confirm the partition grew lsblk -o NAME,SIZE,TYPE,MOUNTPOINT | sed -n '1p;/nvme0n1/p;/xvda/p'
If growpart isn’t available or fails, use parted as a fallback (see Troubleshooting).
5) Grow the Filesystem (ext4 or XFS)
ext4
# For partitioned root sudo resize2fs "$ROOT_SRC" # If filesystem is directly on the disk (no partition) # sudo resize2fs /dev/nvme0n1 OR sudo resize2fs /dev/xvda
XFS
XFS grows online (while mounted) by mount point:
# Grow root filesystem mounted at / sudo xfs_growfs -d / # For a data volume mounted elsewhere (e.g., /data) # sudo xfs_growfs -d /data
-d
tells XFS to use all available space in the underlying device or partition.
6) Validate
df -hT # Check new size and filesystem type lsblk -o NAME,SIZE,MOUNTPOINT,FSTYPE
You should now see the expanded size for /
(or whichever mount you resized).
Common Scenarios
A) Expand the root partition on Amazon Linux/Ubuntu (ext4)
# 1) After increasing EBS size in AWS sudo lsblk # 2) Identify root ROOT_SRC=$(findmnt -n -o SOURCE /) DISK="/dev/$(lsblk -no pkname "$ROOT_SRC")" PARTNUM=$(echo "$ROOT_SRC" | sed -E 's/.*[^0-9]([0-9]+)$/\1/') # 3) Grow partition sudo growpart "$DISK" "$PARTNUM" sudo partprobe "$DISK" # 4) Grow filesystem sudo resize2fs "$ROOT_SRC" # 5) Validate df -hT
B) Expand the root partition on Amazon Linux/RHEL/CentOS (XFS)
# 1) After increasing EBS size in AWS sudo lsblk # 2) Identify root ROOT_SRC=$(findmnt -n -o SOURCE /) DISK="/dev/$(lsblk -no pkname "$ROOT_SRC")" PARTNUM=$(echo "$ROOT_SRC" | sed -E 's/.*[^0-9]([0-9]+)$/\1/') # 3) Grow partition sudo growpart "$DISK" "$PARTNUM" sudo partprobe "$DISK" # 4) Grow XFS (by mount point!) sudo xfs_growfs -d / # 5) Validate df -hT
C) Data disk with no partition (filesystem directly on block device)
# Example: /dev/nvme1n1 mounted at /data (no partition like p1) # After increasing EBS size: sudo lsblk # ext4 sudo resize2fs /dev/nvme1n1 # xfs (use mount point) sudo xfs_growfs -d /data df -hT
One-Command Helper Script (No LVM)
Use at your own risk. Tested for common setups only.
This script detects your root device, expands the partition if needed, and grows ext4/XFS accordingly.
cat <<'EOF' > ~/expand-root-ebs.sh #!/usr/bin/env bash set -euo pipefail # Detect root source, disk, partition, and fs type ROOT_SRC=$(findmnt -n -o SOURCE /) FSTYPE=$(findmnt -n -o FSTYPE /) echo "Root source: $ROOT_SRC" echo "Filesystem: $FSTYPE" # Determine if partitioned or not if [[ "$ROOT_SRC" =~ ^/dev/(nvme[0-9]+n[0-9]+)p([0-9]+)$ ]]; then DISK="/dev/${BASH_REMATCH[1]}" PARTNUM="${BASH_REMATCH[2]}" PARTITIONED=1 elif [[ "$ROOT_SRC" =~ ^/dev/([a-z]+)([0-9]+)$ ]]; then DISK="/dev/${BASH_REMATCH[1]}" PARTNUM="${BASH_REMATCH[2]}" PARTITIONED=1 else DISK="$ROOT_SRC" PARTITIONED=0 fi echo "Disk: $DISK" if [[ $PARTITIONED -eq 1 ]]; then echo "Partition: $PARTNUM"; fi # Grow partition if needed if [[ $PARTITIONED -eq 1 ]]; then command -v growpart >/dev/null 2>&1 || { echo "growpart not found. Install cloud-utils-growpart."; exit 1; } echo "Expanding partition..." sudo growpart "$DISK" "$PARTNUM" sudo partprobe "$DISK" || true fi # Expand filesystem case "$FSTYPE" in ext4|ext3) echo "Growing ext filesystem with resize2fs..." sudo resize2fs "$ROOT_SRC" ;; xfs) echo "Growing XFS filesystem..." sudo xfs_growfs -d / ;; *) echo "Unsupported filesystem: $FSTYPE" exit 1 ;; esac echo "Done. New sizes:" df -hT / EOF chmod +x ~/expand-root-ebs.sh sudo ~/expand-root-ebs.sh
Troubleshooting & Edge Cases
growpart: command not found
Install it:
# Ubuntu/Debian sudo apt update && sudo apt install -y cloud-guest-utils # RHEL/CentOS/Amazon Linux sudo yum install -y cloud-utils-growpart || sudo dnf install -y cloud-utils-growpart
xfs_growfs: not found
# Ubuntu/Debian sudo apt install -y xfsprogs # RHEL/CentOS/Amazon Linux sudo yum install -y xfsprogs || sudo dnf install -y xfsprogs
resize2fs: Device or resource busy
(rare for root)
It grows online for ext4 on mounted root in most modern kernels. If you hit issues, ensure the partition was expanded (lsblk
) and try again. As a last resort, grow offline from a rescue instance.
growpart
fails or partition table is unusual
Use parted
:
# Example for /dev/nvme0n1, partition 1 sudo parted /dev/nvme0n1 ---pretend-input-tty <<PARTEDCMDS unit % print resizepart 1 100% Yes quit PARTEDCMDS sudo partprobe /dev/nvme0n1 # Then grow FS: # ext4: sudo resize2fs /dev/nvme0n1p1 # xfs (by mount point): sudo xfs_growfs -d /
Map NVMe device to EBS volume ID
On Nitro, the serial holds the EBS volume ID:
sudo nvme list # or sudo nvme id-ctrl -H /dev/nvme0n1 | grep -E 'sn|mn'
Converted gp2 → gp3?
You can change volume type independently of size:
aws ec2 modify-volume --volume-id vol-0abc123def456 --volume-type gp3 --iops 3000 --throughput 125
FAQ
Q: Do I need to reboot?
A: No, expanding EBS + partition + filesystem for ext4/XFS normally works online, no reboot required.
Q: Will data be lost?
A: Growing is non-destructive, but always snapshot first.
Q: LVM vs non-LVM?
A: This guide is without LVM. If you use LVM, expand the PV → VG → LV → FS chain.
Thanks for your wonderful Support and Encouragement