Skip to main content

Ubuntu Expand Volume Ext4

📖 Resizing an ext4 Disk to 100% and Expanding the Filesystem

This guide explains how to resize an ext4 partition to use all available space, expand the filesystem, and verify /etc/fstab for proper system mounting.

🛠 Prerequisites

  • Root or sudo access
  • A disk with unallocated space (you can check with lsblk or fdisk -l)
  • The partition to be resized should be formatted as ext4
  • A backup is recommended before modifying partitions

1️⃣ Check Current Disk and Partition Layout

Before making changes, check the existing disk space and partition layout:

lsblk
df -h
fdisk -l

Look for unallocated space on the disk where your root partition (/) is located.

2️⃣ Resize the Partition to Use 100% Disk Space

If your partition does not already use all available space, you need to resize it.

🔹 Resize Using parted

  1. Open the partition editor:
    sudo parted /dev/sda
  2. When prompted about "GPT PMBR size mismatch", choose:
    Fix
  3. Select partition number 1 (assuming root partition is /dev/sda1):
    Partition number? 1
  4. Expand the partition to 100%:
    End? [current-size] 100%
  5. Write changes and exit:
    quit

3️⃣ Expand the ext4 Filesystem

Now that the partition size is increased, resize the ext4 filesystem:

sudo resize2fs /dev/sda1

If successful, you will see output similar to:

Filesystem at /dev/sda1 is mounted on /; on-line resizing required
The filesystem on /dev/sda1 is now XXXXX blocks long.

4️⃣ Verify Changes

Check if the partition and filesystem have expanded to 100%:

df -h /
lsblk

Your root (/) partition should now reflect the full disk size.

5️⃣ Check and Update /etc/fstab

The /etc/fstab file controls how filesystems are mounted at boot. Ensure your root partition is correctly referenced.

🔹 Find the Partition UUID

blkid /dev/sda1

Example output:

/dev/sda1: UUID="47e1437c-ca95-45e2-a3e1-45ad10ae9474" TYPE="ext4"

🔹 Update /etc/fstab (If Needed)

Open the file:

sudo nano /etc/fstab

If your root (/) partition is referenced by LABEL, change it to UUID:

Before:

LABEL=cloudimg-rootfs   /   ext4   discard,errors=remount-ro   0 1

After (with UUID):

UUID=47e1437c-ca95-45e2-a3e1-45ad10ae9474   /   ext4   discard,errors=remount-ro   0 1

Save the file (CTRL + X, then Y, then Enter).


6️⃣ (Optional) Reboot and Validate

To ensure the changes persist, reboot your system:

sudo reboot

After reboot, verify everything is working:

df -h /
lsblk

🎯 Summary

Resized the partition to use 100% of available space
Expanded the ext4 filesystem using resize2fs
Checked and updated /etc/fstab to use UUID
(Optional) Rebooted to confirm changes

🔹 Troubleshooting

  • If resize2fs fails, ensure the partition is formatted as ext4:
    sudo file -s /dev/sda1
  • If /etc/fstab is incorrect after reboot, boot into rescue mode and manually fix it.

🚀 You're Done!

Your ext4 disk is now fully expanded and properly mounted. 🎉