Start typing to search across invoices, services, domains, tickets, and more...
When a server runs out of space and the system uses LVM (Logical Volume Manager), you can add capacity without reinstalling and usually without downtime. This guide covers extending a disk on Linux with LVM in the two most common situations — adding a new disk to the volume group and growing an existing disk that has been enlarged — and also shows how to expand a non-LVM root partition with growpart. Commands apply to Debian/Ubuntu and CentOS/Rocky/AlmaLinux and should be run as root.
Install lvm2 and the package that provides growpart, then use lsblk, pvs, vgs and lvs to see which disk is the physical volume (PV), the volume group (VG) name and where each logical volume (LV) is mounted. The examples use the VG vg0 and the LV /dev/vg0/root; replace them with your own names.
# Debian / Ubuntu
apt update && apt install -y lvm2 cloud-guest-utils
# CentOS / Rocky / AlmaLinux
dnf install -y lvm2 cloud-utils-growpart
# Inspect the current layout
lsblk
pvs
vgs
lvs
df -hT
If a second disk such as /dev/vdc has been attached, initialise it as a physical volume and add it to the existing volume group. VFree in vgs then increases, meaning the VG has free space to allocate. Do not run pvcreate on a disk that already holds data.
# Scenario A: a new disk /dev/vdc was added
pvcreate /dev/vdc
vgextend vg0 /dev/vdc
vgs vg0
If the existing disk has been resized (for example from 40 GB to 100 GB), first extend the partition to the end of the disk with growpart, then run pvresize so the physical volume sees the new space. Note the space between the disk name and the partition number in growpart.
# Scenario B: the existing disk /dev/vda was enlarged and the PV is partition 2
growpart /dev/vda 2
pvresize /dev/vda2
vgs
With free space in the VG, allocate it to the target LV. -l +100%FREE uses all remaining space, while -L +50G adds a fixed amount.
# Give all free space in the VG to the logical volume
lvextend -l +100%FREE /dev/vg0/root
# Or add a fixed amount
lvextend -L +50G /dev/vg0/data
The filesystem must be grown too before df shows the new size. For ext4 run resize2fs on the LV path; for XFS run xfs_growfs on the mount point. Alternatively, add -r to lvextend to resize the LV and filesystem in one step.
# ext4
resize2fs /dev/vg0/root
# XFS (pass the mount point)
xfs_growfs /
# Alternative: extend LV and filesystem in one step
lvextend -r -l +100%FREE /dev/vg0/root
df -hT
Many cloud images use a plain partition for / instead of LVM. After the disk has been upgraded, just grow the partition with growpart and then the filesystem — all online, with no reboot required.
# Root partition without LVM, e.g. /dev/vda1 mounted on /
growpart /dev/vda 1
resize2fs /dev/vda1 # ext4
xfs_growfs / # XFS
df -hT /
There is no free space after the partition: either the new disk size has not taken effect yet or the partition is already at its maximum. Check the disk size in lsblk and reboot the server if needed, then try again.
No, XFS can only grow. To shrink it you must back up, recreate the filesystem and restore. ext4 can be shrunk but only while unmounted, which is risky — proceed with caution.
You need to turn off and delete that swap partition, extend root, and then switch to a swap file or recreate swap in free space. This is an advanced task; open a ticket if you would like help.
Still stuck after following these steps? Open a support ticket and the IMIDC 24/7 technical team will help. Please include the server IP, operating system, the commands you ran and a screenshot of the error so we can pinpoint the issue faster.