Skip to content

Grow a disk inside the guest

Growing a disk happens in two halves. We do the first: the virtual disk your server sees gets bigger. The second half happens inside your server, and nothing does it automatically — the partition and the filesystem on it still end where they used to.

So immediately after a disk grow, df -h shows the old size. That’s expected, and this page is the missing step.

Terminal window
lsblk

You’re looking for a disk that is larger than the partition on it — here a 150 GB disk carrying a 50 GB partition:

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 150G 0 disk
└─sda1 8:1 0 50G 0 part /

If the disk itself still shows the old size, the guest hasn’t noticed yet. Reboot the server, or rescan without one:

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

Install growpart if you don’t have it — it handles the partition table safely and in place.

Terminal window
apt install -y cloud-guest-utils # Debian, Ubuntu
dnf install -y cloud-utils-growpart # RHEL, Rocky, Oracle Linux

Then grow partition 1 on disk sda, noting the space between them:

Terminal window
growpart /dev/sda 1

Check which filesystem you have:

Terminal window
findmnt -no FSTYPE /

ext4:

Terminal window
resize2fs /dev/sda1

xfs — note this takes the mount point, not the device:

Terminal window
xfs_growfs /
Terminal window
df -h /

The size should now match what you asked for. Both resize2fs and xfs_growfs work on a mounted, running filesystem, so there’s no downtime and no need to reboot.

The server’s Disk figure in the panel reads the same numbers from inside the guest, so it should agree with df -h on the next refresh. If it still shows the old size — or a dash — the guest agent isn’t running.

Grow the physical volume, then the logical volume. -r resizes the filesystem in the same step.

Terminal window
growpart /dev/sda 3 # the partition holding the PV
pvresize /dev/sda3
lvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

Use lvs to get the exact logical volume name — the one above is Ubuntu’s default and yours may differ.

  1. Open Disk Management (diskmgmt.msc).
  2. If the new space doesn’t appear, right-click Disk Management and choose Rescan Disks.
  3. Right-click the partition, choose Extend Volume, and accept the maximum.

growpart: NOCHANGE: partition 1 is size … it cannot be grown — the disk isn’t bigger yet from the guest’s point of view. Go back to step 1 and rescan or reboot.

Unallocated space sits after a swap or recovery partition. growpart can only extend into space that directly follows the partition. If something sits in between, the simplest path is to delete the partition in the way (swap can be recreated) and then grow. This is worth a snapshot first, or a ticket from Support if the layout looks awkward.

The filesystem grew but an application still reports the old size. Databases and container runtimes often cache their view of free space. Restart the service.