Skip to content

Instantly share code, notes, and snippets.

@salehi
Created January 4, 2026 17:21
Show Gist options
  • Select an option

  • Save salehi/9e2ea5dfd1c70e089a8661fb0cbb598d to your computer and use it in GitHub Desktop.

Select an option

Save salehi/9e2ea5dfd1c70e089a8661fb0cbb598d to your computer and use it in GitHub Desktop.

Resizing a Linux Disk After VM Expansion

1. Rescan the disk to detect new size

echo 1 > /sys/class/block/sda/device/rescan

Verify with lsblk — disk should now show the new size.

2. Extend the partition

growpart /dev/sda 1

3. Resize the filesystem

For ext4:

resize2fs /dev/sda1

For xfs:

xfs_growfs /

Notes

  • All commands require root
  • Works online (no reboot needed)
  • growpart is in the cloud-guest-utils package (Debian/Ubuntu) or cloud-utils-growpart (RHEL/CentOS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment