Skip to content

Instantly share code, notes, and snippets.

@adarsh-chakraborty
Last active May 27, 2026 09:21
Show Gist options
  • Select an option

  • Save adarsh-chakraborty/305d912f3647ae1a67cbde73c4f88835 to your computer and use it in GitHub Desktop.

Select an option

Save adarsh-chakraborty/305d912f3647ae1a67cbde73c4f88835 to your computer and use it in GitHub Desktop.
# Increase EC2 Storage Without Downtime (Ubuntu)

## 1. Increase EBS Volume Size

AWS Console → EC2 → Volumes → Select Volume → Actions → Modify Volume

Increase storage size (Example: 80GB → 250GB)

Wait until volume state becomes:
- optimizing
or
- completed

---

# 2. SSH Into Server

```bash
ssh ubuntu@YOUR_SERVER_IP

3. Identify Root Disk & Partition Properly

Run:

lsblk

Example output:

NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
nvme0n1      259:0    0   250G  0 disk
├─nvme0n1p1  259:1    0    74G  0 part /
├─nvme0n1p15 259:3    0   106M  0 part /boot/efi
└─nvme0n1p16 259:4    0   913M  0 part /boot

Find the partition mounted on /

In this example:

nvme0n1p1   ...   /

So:

Item Value
Root Partition /dev/nvme0n1p1
Root Disk /dev/nvme0n1
Partition Number 1

Important Rule

If root partition is:

/dev/nvme0n1p1

Then:

  • Disk = /dev/nvme0n1
  • Partition Number = 1

If root partition is:

/dev/xvda1

Then:

  • Disk = /dev/xvda
  • Partition Number = 1

4. Install growpart

sudo apt update
sudo apt install cloud-guest-utils -y

5. Expand Partition

Example For NVMe Disk

sudo growpart /dev/nvme0n1 1

Example For Older EC2 Instances

sudo growpart /dev/xvda 1

6. Resize Filesystem

EXT4 Filesystem (Most Ubuntu Servers)

sudo resize2fs /dev/nvme0n1p1

Older Device Naming

sudo resize2fs /dev/xvda1

7. Verify New Storage

df -h

Example:

Filesystem       Size  Used Avail Use% Mounted on
/dev/root        246G   45G  201G  19% /

Done ✅


Recommended Safety Step

Before resizing:

EC2 → Volumes → Actions → Create Snapshot

This allows rollback if anything goes wrong.


Full Example

sudo apt update
sudo apt install cloud-guest-utils -y

lsblk

sudo growpart /dev/nvme0n1 1
sudo resize2fs /dev/nvme0n1p1

df -h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment