Expanding EBS Volume on an EC2 Instance without restarting
Overview
If you've increased your AWS EBS volume size but it's not reflecting inside your VM, follow these steps to make the new space available.
Step 1: Verify the EBS Volume Size on AWS
Run the following command to check if the volume size has been updated on AWS:
aws ec2 describe-volumes --volume-ids vol-xxxxxxxxxxxxxxxxx
Step 2: Check if the OS Recognizes the New Size
Run the following command inside the VM:
lsblk
Example output:
nvme0n1 259:0 0 30G 0 disk
├─nvme0n1p1 259:1 0 19.9G 0 part /
├─nvme0n1p14 259:2 0 4M 0 part
└─nvme0n1p15 259:3 0 106M 0 part /boot/efi
Step 3: Expand the Partition
Since the partition (nvme0n1p1
) is still at 19.9GB while the disk is 30GB, you need to extend it using growpart
:
sudo growpart /dev/nvme0n1 1
Verify the change:
lsblk
Step 4: Resize the Filesystem
After expanding the partition, resize the filesystem.
-
For EXT4 Filesystem (Ubuntu/Debian):
sudo resize2fs /dev/nvme0n1p1
-
For XFS Filesystem (Amazon Linux 2, RHEL, CentOS 7+):
sudo xfs_growfs /
Step 5: Verify the Disk Space
Check if the root partition reflects the new size:
df -h
Example output:
Filesystem Size Used Avail Use% Mounted on
/dev/root 29G 16G 13G 56% /
tmpfs 969M 0 969M 0% /dev/shm
tmpfs 388M 912K 387M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/nvme0n1p15 105M 6.1M 99M 6% /boot/efi
tmpfs 194M 4.0K 194M 1% /run/user/0
Now your root volume is successfully resized to 30GB! 🚀