Chapter 13: Amazon EBS (Elastic Block Store)
13.5 Increasing the size of a volume (root or data)
Quick answer: the short, self-contained version of this lesson is the guide How to Increase EBS Volume Size Without Downtime.
In my class students always ask: "Sir, I increased the size in the console, so why does df -h still show 8G?" See – the disk grew, but the partition and filesystem inside Linux did not. Come on, let's fix it in two parts.
माझ्या क्लासमध्ये स्टुडंट्स नेहमी विचारतात: "सर, कन्सोलमध्ये साइज वाढवला, मग df -h अजून 8G का दाखवतो?" बघा – डिस्क वाढली, पण Linux मधलं पार्टिशन आणि फाइलसिस्टम नाही वाढले. चला, दोन भागांत ठीक करूया.
मेरी क्लास में स्टूडेंट्स हमेशा पूछते हैं: "सर, कंसोल में साइज़ बढ़ाया, फिर df -h अब भी 8G क्यों दिखाता है?" देखो – डिस्क बढ़ी, पर Linux के अंदर का पार्टीशन और फ़ाइलसिस्टम नहीं बढ़े. चलो, दो हिस्सों में ठीक करते हैं.
You can grow a volume without stopping the instance. It is a two-part job: (A) make the EBS volume bigger in AWS, then (B) make the partition and filesystem inside Linux use the new space.
Before: [ EBS 8 GiB ][ partition 8 GiB ][ filesystem 8 GiB ]
Step A: [ EBS 20 GiB ][ partition 8 GiB ][ filesystem 8 GiB ] ← lsblk shows 20G disk, df still 8G
Step B1 growpart: [ partition 20 GiB ]
Step B2 xfs_growfs / resize2fs: [ filesystem 20 GiB ] ← df now shows 20G
Take a snapshot first
Always create a snapshot of the volume before resizing. Also note: EBS volumes can only be made bigger, never smaller, and after a modification you must wait (usually up to 6 hours) before modifying the same volume again.
Part A — Modify the volume in the console
- EC2 → Instances → select instance → Storage tab → click the Volume ID.
- Select the volume → Actions → Modify volume.
- Enter the new Size (e.g. 20 GiB); optionally change type to gp3 → Modify → confirm.
- Wait until the Volume state shows in-use – optimizing or completed (the new size is usable as soon as it enters optimizing).
CLI alternative: aws ec2 modify-volume --volume-id vol-0123456789abcdef0 --size 20
Part B — Extend partition and filesystem in Linux
Step 1 — check the current layout:
lsblk
df -hT
Example output on a Nitro instance after Part A (root volume grown from 8 to 20 GiB):
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
nvme0n1 259:0 0 20G 0 disk
├─nvme0n1p1 259:1 0 8G 0 part /
├─nvme0n1p127 259:2 0 1M 0 part
└─nvme0n1p128 259:3 0 10M 0 part /boot/efi
Filesystem Type Size Used Avail Use% Mounted on
/dev/nvme0n1p1 xfs 8.0G 1.9G 6.1G 24% /
The disk is 20G but partition nvme0n1p1 and the filesystem are still 8G.
Step 2 — grow the partition (note the space between disk and partition number):
# growpart is in package cloud-utils-growpart (AL2023/CentOS) or cloud-guest-utils (Ubuntu) - usually pre-installed
sudo growpart /dev/nvme0n1 1 # Nitro instance
# sudo growpart /dev/xvda 1 # older Xen instance (t2)
lsblk # nvme0n1p1 should now be 20G
Step 3 — grow the filesystem. First check the type with df -hT:
# XFS (default on Amazon Linux 2023, Amazon Linux 2 and CentOS Stream 9) - give the MOUNT POINT
sudo xfs_growfs -d /
# ext4 (default on Ubuntu) - give the PARTITION DEVICE
sudo resize2fs /dev/nvme0n1p1 # Ubuntu root is usually /dev/nvme0n1p1 (or /dev/xvda1 on Xen)
Step 4 — verify:
df -hT /
lsblk
Data volume without a partition
If you formatted a whole disk directly (e.g. /dev/nvme1n1 with no p1 partition, as we do in 13.6), skip growpart. Just run sudo xfs_growfs -d /data (XFS) or sudo resize2fs /dev/nvme1n1 (ext4) after modifying the volume.
Ubuntu often auto-grows the root on reboot
cloud-init on Ubuntu and Amazon Linux grows the root partition automatically at boot. If you increased the root volume and rebooted, df -h may already show the new size — the manual steps above are for doing it live without a reboot.
Ravindra Bagale's Tip
Many students run resize2fs on XFS or forget the space in growpart /dev/nvme0n1 1. First check the filesystem type with df -hT: XFS takes xfs_growfs -d / (mount point), ext4 takes resize2fs (partition device). And always take a snapshot before a resize.
Ravindra Bagale's Tip – मराठी
खूप students XFS वर resize2fs चालवतात किंवा growpart /dev/nvme0n1 1 मधली space विसरतात. आधी df -hT ने filesystem type बघा: XFS ला xfs_growfs -d / (mount point), ext4 ला resize2fs (partition device). आणि resize आधी snapshot नक्की घ्या.
Ravindra Bagale's Tip – हिंदी
बहुत students XFS पर resize2fs चलाते हैं या growpart /dev/nvme0n1 1 का space भूल जाते हैं. पहले df -hT से filesystem type देखो: XFS के लिए xfs_growfs -d / (mount point), ext4 के लिए resize2fs (partition device). और resize से पहले snapshot ज़रूर लो.
Lab
Chala, snapshot ghetlyavar Amazon Linux 2023 cha root volume 8 GiB varun 12 GiB kara. lsblk madhe disk aani partition cha farak bagha, sudo growpart /dev/nvme0n1 1 aani sudo xfs_growfs -d / chalva, aani df -hT / ne navin size confirm kara.
Got it? Growing the volume in the console is only half the job – the partition and filesystem inside must grow too. Now let's move on to adding a new disk.
समजलं का? कन्सोलमध्ये व्हॉल्यूम वाढवला की काम अर्धंच होतं – आतलं पार्टिशन आणि फाइलसिस्टम पण वाढवावे लागतात. आता पुढे जाऊया नवीन डिस्क जोडायला.
समझ आया? कंसोल में वॉल्यूम बढ़ाया तो काम आधा ही होता है – अंदर का पार्टीशन और फ़ाइलसिस्टम भी बढ़ाने पड़ते हैं. अब आगे चलते हैं नई डिस्क जोड़ने.