How to Increase Disk Size on a VPS After Changing the Plan

Step 1: Increase the partition size
The first step is to expand the partition on the disk. For this, use the parted command. It allows you to resize the partition so that it takes up all available space.

Important: Replace /dev/xvda with the name of your disk and 2 with the number of the partition you want to expand. You can check this using the lsblk command.

sudo parted /dev/xvda resizepart 2 100%

This command will expand partition number 2 on disk /dev/xvda to 100% of the available space.

Step 2: Increase the filesystem size
After expanding the partition, you need to “inform” the filesystem (ext4) that it can now use all the new space. For this, use the resize2fs command.

Important: Here you specify the partition, not the disk itself. For example, /dev/xvda2.

sudo resize2fs /dev/xvda2

After running this command, the ext4 filesystem will be expanded to the new partition size, and you’ll be able to use the full disk capacity.

Step 3: Verify the result
To make sure everything was successful, check the disk size with the df -h command.