Interview Prep/Linux/Storage, disks and filesystems

A cloud VM's root disk was enlarged from 30 GB to 80 GB in the console, but `df` still shows 30 GB. What do you do?

BeginnerScenarioStorage, disks and filesystems
Answer

Situation read → The block device grew, but the partition and filesystem did not.

What I'd do →

lsblk                                  # disk 80G, partition still 30G
sudo growpart /dev/nvme0n1 1           # from cloud-guest-utils / cloud-utils-growpart
sudo xfs_growfs /                      # XFS
# or: sudo resize2fs /dev/nvme0n1p1    # ext4
df -h /

If root is on LVM: growpart, then pvresize /dev/nvme0n1p3, then lvextend -r.

Why → Three layers must each be resized: disk, partition, filesystem.

Interview tip → Note that cloud-init's growpart module does this automatically at boot on many images.

All Linux questions Roadmap: Linux

More on Storage, disks and filesystems