When you increase the disk size of a Linux VPS in VMmanager, the virtual disk becomes larger. However, Linux may not automatically use the newly added space. In most cases, you also need to extend the partition and then resize the file system inside the VPS.
This guide explains how to increase the partition and file system size for a Linux VPS after the disk size has been expanded in VMmanager.
The examples in this article use the following disk and partition:
- Disk:
/dev/vda - Partition:
/dev/vda2 - Root file system mount point:
/
Before You Start
Important: Before performing any actions with disk partitions or file systems, contact support and ask them to create a backup of your VPS.
Resizing partitions and file systems is a sensitive operation, and having a backup helps prevent data loss if something goes wrong.
Make sure that:
- The VPS disk size has already been increased in VMmanager.
- You have root or sudo access to the VPS.
- Support has created a backup of your VPS.
- The partition you want to extend is
/dev/vda2. - The VPS uses a supported Linux file system such as EXT4 or XFS.
Note: In most cases, these actions can be performed while the VPS is running.
EXT4 and XFS file systems support online expansion in most modern Linux distributions. However, it is recommended to perform disk operations during a maintenance window or when the server load is low.
Step 1. Check the Current Disk Layout
Connect to the VPS via SSH and run:
lsblk -f
Example output:
NAME FSTYPE SIZE MOUNTPOINT
vda 40G
├─vda1 ext4 1G /boot
└─vda2 ext4 20G /
In this example:
- The disk is
/dev/vda - The root partition is
/dev/vda2 - The file system is
ext4 - The partition
/dev/vda2does not yet use the full disk size
Step 2. Install the Required Utility
To extend the partition, install growpart.
For Debian or Ubuntu:
apt update
apt install cloud-guest-utils
For AlmaLinux:
dnf install cloud-utils-growpart
For CentOS:
yum install cloud-utils-growpart
Step 3. Extend the /dev/vda2 Partition
Use growpart to extend partition /dev/vda2.
Since the disk is /dev/vda and the partition number is 2, run:
growpart /dev/vda 2
Important: There must be a space between the disk name and the partition number:
Correct:
growpart /dev/vda 2Incorrect:
growpart /dev/vda2
After that, check the partition size again:
lsblk
Example output after extending the partition:
NAME SIZE MOUNTPOINT
vda 40G
├─vda1 1G /boot
└─vda2 39G /
The partition /dev/vda2 should now be larger.
Step 4. Resize the File System on /dev/vda2
After the partition has been extended, resize the file system.
First, check the file system type:
lsblk -f
Example output:
NAME FSTYPE SIZE MOUNTPOINT
vda 40G
├─vda1 ext4 1G /boot
└─vda2 ext4 39G /
For EXT4
If /dev/vda2 uses EXT4, run:
resize2fs /dev/vda2
Example:
resize2fs /dev/vda2
For XFS
If /dev/vda2 uses XFS and it is mounted as /, run:
xfs_growfs /
For XFS, specify the mount point, not the block device.
Correct:
xfs_growfs /
Incorrect:
xfs_growfs /dev/vda2
Step 5. Verify the New Size
Run:
df -h
Example output:
Filesystem Size Used Avail Use% Mounted on
/dev/vda2 39G 12G 27G 31% /
If the new size is shown for /dev/vda2, the partition and file system were expanded successfully.
You can also check the block device layout again:
lsblk -f
Example:
NAME FSTYPE SIZE MOUNTPOINT
vda 40G
├─vda1 ext4 1G /boot
└─vda2 ext4 39G /