When you upgrade your VPS to a plan with a bigger disk, the virtual disk grows straight away, but the partition and filesystem inside your server may not grow by themselves. Until they do, your server can't use the extra space. This guide shows you how to check, and how to expand them if needed.

It works on every operating system we offer: Ubuntu 22.04, 24.04 and 26.04, Debian 12 and 13, AlmaLinux 8, 9 and 10, and Rocky Linux 9 and 10.

Before you start

  • SSH access as root or as a user with sudo rights. If you're logged in as root, you can leave sudo off the commands.
  • Take a backup first. Growing a partition is usually safe, but a mistake, such as resizing the wrong partition, can stop your server booting or lose data. Use our VPS backups add-on if you have it, or make your own off-server backup with restic.
  • Check the disk and partition names in each command match your server before you run it. Don't run commands against a partition you haven't identified.
  • If your server doesn't come back after a reboot, use Open Console on your VPS's management page to see what's happening. See Use the web console to access your VPS.

Step 1: Reboot your VPS

After the upgrade, restart your VPS with sudo reboot, or the Reboot button on your VPS's management page (Services → My Services → Manage). This makes sure the server sees the new disk size, and on many servers it grows everything automatically (see below).

Step 2: Check the sizes

lsblk
df -Th /

lsblk shows your disks and partitions. It will look something like this:

NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda       8:0    0   80G  0 disk
├─sda1    8:1    0 39.9G  0 part /
├─sda14   8:14   0    4M  0 part
└─sda15   8:15   0  106M  0 part /boot/efi
  • The line with TYPE disk is the disk. Here it's sda (on some servers it's vda), and it should show your new plan's size.
  • The partition with / under MOUNTPOINTS is your root partition. Here it's sda1, so the disk is /dev/sda and the partition number is 1. Write these down.
  • If the root partition is already about the same size as the disk, the partition has been grown.
  • If you see lines with TYPE lvm, your server uses LVM. Skip to If your server uses LVM below.

df -Th / shows the filesystem's Type (usually ext4 or xfs) and Size. If the size matches your new disk, you're done.

Did it grow automatically?

The Ubuntu, Debian, AlmaLinux and Rocky Linux cloud images use cloud-init, which by default tries to grow the root partition and filesystem to fill the disk every time the server boots. If your VPS uses cloud-init, the reboot in Step 1 has probably done the job. You can check whether it's installed with cloud-init status.

cloud-init can't do it if the growpart tool isn't installed, cloud-init has been removed or turned off, the root filesystem is on LVM, or another partition sits after the root partition. In those cases, carry on with the steps below.

Step 3: Install growpart

Ubuntu/Debian

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

AlmaLinux/Rocky

sudo dnf install -y cloud-utils-growpart

If cloud-init is installed, it may now be able to do the rest for you. Reboot, then check again with lsblk and df -Th /.

Step 4: Grow the partition

growpart takes the disk and the partition number, with a space between them (/dev/sda 1, not /dev/sda1). Use the names you found in Step 2. Do a dry run first, which shows what would change without changing anything:

sudo growpart --dry-run /dev/sda 1

If it shows the new size with no errors, run it for real:

sudo growpart /dev/sda 1

It should report CHANGED. Run lsblk again to confirm the partition is bigger. If it says NOCHANGE, see Troubleshooting below.

Step 5: Grow the filesystem

Check the filesystem type in the Type column of df -Th /, then run the matching command. Both work while the server is running.

ext4 (usual on Ubuntu and Debian). Use the partition name, with no space:

sudo resize2fs /dev/sda1

xfs (usual on AlmaLinux and Rocky Linux). Use the mount point:

sudo xfs_growfs /

Check the new size:

df -h /

If your server uses LVM

With LVM, your root filesystem sits on a logical volume inside a partition. lsblk looks something like this:

NAME               MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda                  8:0    0   80G  0 disk
├─sda1               8:1    0    1G  0 part /boot
└─sda2               8:2    0   39G  0 part
  ├─almalinux-root 253:0    0   35G  0 lvm  /
  └─almalinux-swap 253:1    0    4G  0 lvm  [SWAP]

cloud-init can't grow LVM, so you'll need to do it yourself. Install growpart (Step 3), then:

  1. Grow the partition that holds LVM, sda2 in this example: sudo growpart /dev/sda 2
  2. Tell LVM the partition is bigger: sudo pvresize /dev/sda2
  3. Find your root logical volume. It's shown in the first column of df -h /, for example /dev/mapper/almalinux-root. You can also list them with sudo lvs.
  4. Give it all the free space and grow its filesystem in one step. The -r option grows ext4 or XFS for you:
    sudo lvextend -r -l +100%FREE /dev/mapper/almalinux-root
  5. Check the new size with df -h /.

If you have more than one logical volume, for example a separate one for /home, you can split the space instead, for example -l +50%FREE.

Can I shrink the disk later?

Not simply. Disks can be grown, but they can't easily be shrunk, and XFS filesystems can't be shrunk at all. If you're thinking of downgrading to a plan with a smaller disk, open a support ticket first.

Troubleshooting

  • growpart says "NOCHANGE ... it cannot be grown": there's no free space straight after the partition. Run lsblk. If the partition is already the full size, cloud-init may have grown it, so go to Step 5. If the disk itself still shows the old size, reboot and check again. If it's still the old size after a reboot, open a support ticket. Otherwise, another partition is probably in the way (see below).
  • The root partition isn't the last partition on the disk: growpart can only grow a partition into free space directly after it. It can't move other partitions. To see the real order, run sudo parted /dev/sda unit GB print free: the Free Space should be on the line straight after your root partition. Partition numbers don't always match their order on the disk, so go by this list. If something other than swap is in the way, the safest fix is usually to back up, reinstall your VPS and restore your data.
  • A swap partition is in the way: this is common on Debian servers set up with the standard installer, where swap is often partition 5 inside an extended partition 2. You can replace it with a swap file. Check the partition numbers with sudo parted /dev/sda print first, as removing the wrong partition destroys its data:
    1. Turn off swap: sudo swapoff -a
    2. Remove the swap partition, then the extended partition that held it, if there is one: sudo parted /dev/sda rm 5 then sudo parted /dev/sda rm 2
    3. Open /etc/fstab with sudo nano /etc/fstab and put a # at the start of the swap line.
    4. If the file /etc/initramfs-tools/conf.d/resume exists, change its contents to RESUME=none and run sudo update-initramfs -u, so the server doesn't wait for the old swap partition when it boots.
    5. Grow the root partition and filesystem (Steps 4 and 5).
    6. Create a 2 GB swap file:
      sudo fallocate -l 2G /swapfile
      sudo chmod 600 /swapfile
      sudo mkswap /swapfile
      sudo swapon /swapfile
      echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
  • resize2fs says "Bad magic number in super-block": the filesystem is XFS, not ext4. Use sudo xfs_growfs / instead.
  • xfs_growfs says "is not a mounted XFS filesystem": the filesystem is probably ext4. Use resize2fs instead.
  • The server won't boot after resizing: use Open Console to see the error. If you can't fix it, restore from your backup, or open a support ticket.

Related guides

Need help?

Our Cloud VPS plans are self-managed, so you're responsible for installing, securing and maintaining the software on your server. If something on our side isn't working, such as the network, or your VPS won't boot, open a support ticket. New to your VPS? Start with our Cloud VPS Getting Started Guide.

Was this answer helpful? 0 Users Found This Useful (0 Votes)