# LVM on a server: resizing a disk with no downtime

> Resizing a disk with LVM on a VDS with no downtime: pvresize, lvextend, resize2fs and xfs_growfs, checking the volume group, and common mistakes.

## What LVM is and why you'd resize a disk with no downtime

LVM (Logical Volume Manager) is an abstraction layer between physical disks and the file system. Instead of mounting a partition directly, LVM combines one or more disks into a volume group, then carves logical volumes of any size out of it. The main benefit for a VDS: after the hosting provider increases the disk size in the control panel, you extend the logical volume and the file system on the fly, without stopping services or rebooting.

Without LVM, growing a partition usually requires stopping services, recreating the partition table, or moving data. With LVM it's a few commands on a live system.

## Checking the current LVM configuration

Before resizing, check what the current structure looks like:

```
lsblk
pvs
vgs
lvs
```

`pvs` shows physical volumes, `vgs` shows volume groups with their total and free size, and `lvs` shows logical volumes with their mount points. The `lsblk` command checks the new disk size at the block device level after resizing it in the hosting panel.

## Step 1: growing the disk at the system level

After the disk is resized in the hosting provider's panel (with ZevsHost.net this happens in the client panel without rebooting the VDS), the kernel gets notified about the change:

```
echo 1 > /sys/class/block/sda/device/rescan
partprobe /dev/sda
lsblk
```

When using a partition (for example, `/dev/sda3`) that contains LVM, extend the partition with `growpart`:

```
apt install -y cloud-guest-utils
growpart /dev/sda 3
```

After that, `lsblk` shows the increased size of the `/dev/sda3` partition.

## Step 2: extending the physical volume and logical volume

LVM gets a signal that the physical volume has grown:

```
pvresize /dev/sda3
vgs
```

The `VFree` field in the `vgs` output shows the new free space in the volume group. Next, extend the logical volume — using all available space (`-l +100%FREE`) or a specific size:

```
lvextend -l +100%FREE /dev/mapper/vgname-root
```

Check the logical volume's name with `lvs` — it varies depending on the distribution and how the VDS was created.

## Step 3: extending the file system

Extending the logical volume does not automatically change the file system size — it needs a separate command, depending on the file system type:

| File system | Resize command |
| --- | --- |
| ext4 | `resize2fs /dev/mapper/vgname-root` |
| xfs | `xfs_growfs /` |

Both commands run on a mounted, live file system — no downtime is required. Check the result afterward:

```
df -h /
```

## Common mistakes when resizing LVM

The most common problem is skipping the `growpart` or `partprobe` step: then `pvresize` sees no new space, because the partition table entry is still the old size. The second mistake is mixing up device names: `lvextend` and `resize2fs` must point to the same logical volume, visible in `lvs` under the `LV Path` column. When free space still hasn't appeared after growing the disk, start diagnostics over with the article on [finding what's taking up disk space](https://www.zevshost.net/en/kb/disk-zapolnen-diagnostika/) — the space might already be there, but someone forgot to extend the file system.

## Summary: a checklist for resizing an LVM disk

- Grow the disk in the hosting panel, then run `partprobe` and, if needed, `growpart`.
- Check the structure: `pvs`, `vgs`, `lvs`.
- Extend the physical volume: `pvresize /dev/sdaN`.
- Extend the logical volume: `lvextend -l +100%FREE /dev/mapper/name`.
- Extend the file system: `resize2fs` for ext4 or `xfs_growfs` for xfs.
- Check the result with `df -h` and set up [VDS resource monitoring](https://www.zevshost.net/en/kb/monitoring-vds/) to catch the next time the disk fills up.

---

Source: https://www.zevshost.net/en/kb/lvm-rasshirenie-diska/
