When a disk fills up on a Linux server, an application that can’t write logs may stop, and a database may switch to read-only mode. If the root file system is on LVM, you can usually solve this without a restart, while the service is running. The steps below go in order from growing the virtual disk to extending the file system; they also cover the difference between XFS and ext4, the method for adding a new disk, and what an LVM snapshot does and doesn’t save. The commands are for RHEL/Rocky/Alma and Debian/Ubuntu distributions; for growpart, the cloud-utils-growpart package must be installed on the RHEL family and cloud-guest-utils on Debian/Ubuntu. Before running the commands on a production server, verify the backup and, if possible, try them on a test server.
LVM layers: PV, VG, LV
LVM puts a flexible layer between the physical disk and the file system:
| Layer | What it represents | Example |
|---|---|---|
| PV (Physical Volume) | A disk or partition given to LVM | /dev/sdb, /dev/sda3 |
| VG (Volume Group) | A pool of space made up of one or more PVs | vg_data |
| LV (Logical Volume) | A volume allocated from the pool, on which the file system is built | /dev/vg_data/lv_data |
Expansion is always done from the bottom up: first the PV grows or a new PV is added to the VG, then the LV is grown, and finally the file system is extended to the LV’s new size. If the order is broken, the next step gives a “no free space” error or the file system stays at its old size.
Reading the current state: lsblk, pvs, vgs, lvs
Before any change, get a full picture of the structure and save the output somewhere:
lsblk -f # disks, partitions, LVs and file system types
df -hT # mounted file systems, type and usage
pvs # PVs, the VG they belong to and free space (PFree)
vgs # VGs and free space in the pool (VFree)
lvs # LVs and their sizes
findmnt /data # which device a mount point comes from
The first value to look at on the console is the VFree column in the vgs output. If the VG already has free space, there is no need to grow the disk; the LV and file system are extended directly. This is common on Ubuntu Server installs: the installer may not give the whole VG to the root LV, and while the server looks “full,” unallocated space sits waiting in the pool. Looking at this column before opening a disk growth request on the hypervisor can make a change record unnecessary.
Also note whether the PV is a partition (/dev/sda3) or an unpartitioned disk (/dev/sdb); the steps after growing the virtual disk differ accordingly. On the root disk, the PV is usually on a partition; on a data disk added later, the whole disk is often used as the PV.
Extending after growing the virtual disk
After the virtual disk is grown in the VMware, Hyper-V, Proxmox or cloud console, the Linux kernel doesn’t always see the new size on its own. This is a common sticking point: the disk has been grown, lsblk shows the old size, and the team thinks the operation failed on the hypervisor. The flow below is for the typical root disk scenario where the PV is on a partition:
# 1. Make the kernel read the disk's new size (for sda)
echo 1 > /sys/class/block/sda/device/rescan
lsblk /dev/sda # the new size should appear
# On NVMe disks (some cloud VMs): nvme ns-rescan /dev/nvme0 (nvme-cli)
# 2. Grow the partition to the end of the disk (partition 3)
growpart /dev/sda 3 # RHEL: cloud-utils-growpart, Debian/Ubuntu: cloud-guest-utils
# 3. Extend the PV to the partition's new size
pvresize /dev/sda3
vgs # VFree should have increased
# 4. LVM layer: grow the LV as much as needed (example 20 GiB), leave headroom in the VG
lvextend -L +20G /dev/rhel/root # Ubuntu default: /dev/ubuntu-vg/ubuntu-lv
# 5. File system layer: only one, depending on the type
xfs_growfs / # XFS: give the mount point
resize2fs /dev/rhel/root # ext4: give the device path
On NVMe devices, partition names are different: the disk is /dev/nvme0n1 and the third partition is /dev/nvme0n1p3; growpart is still called with the disk path and partition number (growpart /dev/nvme0n1 3). Don’t guess the LV path; take it from the lvs or findmnt / output.
If the PV is directly on the disk (no partition), the second step is skipped and pvresize /dev/sdb is enough. This is the practical advantage of using data disks as unpartitioned PVs: one step and one chance of error fewer.
The LVM layer and the file system are two separate steps. lvextend only grows the LV; the file system is then extended with xfs_growfs on XFS and resize2fs on ext4. The -r (--resizefs) option of lvextend combines the two steps via fsadm; it can be used when you are sure of the file system type.
-l +100%FREE gives all free space in the VG to a single LV; don’t use it as the default option in production. Grow the LV as much as needed (such as -L +20G) and leave free space in the VG. That headroom is needed later for taking snapshots or urgently growing another LV; since XFS can’t be shrunk, space given in excess can’t be taken back.
Adding space with a new disk
If growing the existing disk isn’t possible (such as the 2 TiB limit of the MBR partition table or a storage-side constraint), or you want to spread data across a different storage tier, a new disk is added to the VG:
# Detect the new SCSI disk (host numbers vary from system to system)
for h in /sys/class/scsi_host/host*/scan; do echo "- - -" > "$h"; done
lsblk # the new disk, e.g. /dev/sdc
pvcreate /dev/sdc
vgextend vg_data /dev/sdc
lvextend -r -L +200G /dev/vg_data/lv_data
This method has a price: the LV is now spread across two disks, and losing one of them affects the whole LV. Two disks, two points of failure. In a virtual environment, as long as the two virtual disks sit on the same datastore, the difference is small in practice; in physical server infrastructure, make sure there is RAID under each PV. Also check separately that the hypervisor-level backup job covers the new disk. Some backup jobs select by disk, and a disk added later is silently left out.
Growing by file system: XFS and ext4
After the LV is grown, the file system is extended separately (if you used lvextend -r, this step has been done). The command depends on the file system type:
| Feature | XFS | ext4 |
|---|---|---|
| Online growth | Yes | Yes |
| Grow command | xfs_growfs /data (mount point) |
resize2fs /dev/vg_data/lv_data (device) |
| Shrinking | Not supported | Only while unmounted (offline) |
| Distributions where it is the default | RHEL and derivatives | Debian, Ubuntu |
That XFS can’t be shrunk is a design constraint: if you gave an XFS volume too much space, the only way back is to create a new, smaller volume and move the data. That’s why XFS volumes should be grown gradually rather than beyond what’s needed. ext4 can be shrunk, but the volume must be unmounted and e2fsck -f must be run first; for the root file system, this means booting from a rescue environment. In other words, a maintenance window.
To verify, compare the new size with df -hT and the LV size with lvs. If the LV is large but df shows the old size, the file system extension step was skipped. This is a common cause of the “I extended it but the disk is still full” complaint.
LVM snapshots and their limits
A classic (thick) LVM snapshot keeps an image of an LV at a given moment using copy-on-write. Each block that changes on the original LV is copied to the snapshot area before it changes. Typical use: creating a rollback point before a risky update, or freezing data for a consistent backup.
# Snapshot reserving space for 10 GB of changes
lvcreate -s -L 10G -n lv_data_snap /dev/vg_data/lv_data
# Monitor the state: the Data% column is the snapshot area's usage
lvs vg_data
# If you need to roll back: merge the snapshot into the original
lvconvert --merge /dev/vg_data/lv_data_snap
# Remove it if no longer needed
lvremove /dev/vg_data/lv_data_snap
Don’t use snapshots without knowing their limits:
- It becomes invalid if it fills up: When the allocated space fills with changes, the snapshot becomes unusable. Choose the size based on the amount of change expected during the snapshot’s lifetime and monitor its usage.
- It lowers write performance: Every first write causes an extra copy operation; don’t keep snapshots for long.
- It needs free space in the VG: If VFree is zero, a snapshot can’t be created. Another reason not to distribute all space to LVs.
- It isn’t a backup: A snapshot sits on the same disks; it is lost along with them if the disk or VG is lost.
- Mounting XFS: To mount an XFS snapshot at the same time as the original, the
-o nouuidoption is needed because of the identical UUID. - Merging on the root volume: A merge into a mounted LV that is in use completes at the next activation (usually at reboot).
Snapshot behavior is different on LVs using thin provisioning: no separate size is allocated; it consumes from the pool. This time, the pool filling up affects all thin LVs at once; monitor thin pool usage separately. For lasting protection you need an independent backup; the principles are in the 3-2-1-1-0 backup rule article.
Safe implementation checklist
- The date of the last successful backup has been checked; restorability is known for critical servers.
- The
lsblk -f,pvs,vgs,lvsanddf -hToutputs were saved before the operation. - The right disk and the right partition number were verified twice; device names (
sdb,sdc) can change between reboots. /etc/fstabentries use UUIDs or LV paths (/dev/mapper/…) instead of device names.- After the extension,
df -hTshows the new size; there are no I/O errors in the application logs. - The hypervisor snapshot was removed after the operation; the LVM snapshot was deleted if not in use.
- The disk threshold and capacity report in the monitoring system were updated for the new size.
To avoid noticing the need for expansion at the last minute, track the disk growth rate and calculate the exhaustion date in advance; the method is in the server monitoring metrics and thresholds article. If the server runs in Azure, see the running virtual servers in Azure article for the cost impact of disk type and size tier. All options of the commands are in the lvextend(8) and xfs_growfs(8) man pages. Storage and capacity management of Linux servers is within the scope of Linux and open-source platform services.
Frequently asked questions
Does the server need a restart to expand a disk with LVM?
In most cases, no. The disk’s new size is read with a rescan; then pvresize, lvextend and the file system growth are done while the service is running. XFS and ext4 support online growth.
Why does df show the old size after lvextend?
The LV has grown but the file system hasn’t been extended. Run xfs_growfs with the mount point for XFS, or resize2fs with the device path for ext4. If the -r option is used with the lvextend command, this step is done automatically.
Can an XFS file system be shrunk?
No. XFS can only be grown. To shrink an XFS volume that was given too much space, you need to create a new, smaller volume and move the data; ext4, on the other hand, can be shrunk while unmounted.
Can an LVM snapshot be used instead of a backup?
It can’t. A snapshot is kept on the same disks, becomes invalid when its allocated space fills up, and is lost together with the original if the disk is lost. Use it as a short-term rollback point before a risky change.