MaruOpsInfrastructure and AI notes

About (Korean)Contact (Korean)

Expand a Linux Root Filesystem with LVM, XFS or ext4

Plextor SSD as a PCIe expansion card

Reference photo · Plextor SSD as a PCIe expansion card · Photo: Jacek Halicki / Source / CC BY-SA 4.0 · Resized for listings; illustrative photo, not the tested environment

If a larger VMware virtual disk leaves df -h / unchanged, inspect the layers between the disk and filesystem. The partition, LVM physical volume, logical volume and filesystem each track their own size. Identify the first layer that has not grown before selecting a command.

This procedure expands an XFS or ext4 root filesystem on ordinary linear LVM. The same layering principles apply to Rocky Linux 9 and Ubuntu 24.04 or 26.04, but device names vary. Shrinking, LUKS, RAID, multipath, thin pools, Btrfs and ZFS are outside its scope. For a different layout, check the expansion procedure for the additional layer first.

Linux operation articles seen together · Rocky 9 Fixed IP · Ubuntu 24.04 Netplan · Ubuntu 26.04·nmtui·systemd service·log·LVM root extension·general partition root Expand

On this page

1. Check what / is on top of

findmnt -no SOURCE,FSTYPE,OPTIONS /
df -hT /
df -ih /
lsblk -e 7 -o NAME,PATH,SIZE,TYPE,FSTYPE,MOUNTPOINTS
sudo pvs -o pv_name,pv_size,pv_free,vg_name
sudo vgs -o vg_name,vg_size,vg_free
sudo lvs -a -o lv_path,lv_size,segtype,devices

Check the source/file system of / at findmnt and follow it to the parent device at lsblk. Do not judge that it is a simple LVM just by looking at the name /dev/mapper. Also check the segtype of lvs and whether there is a crypt·raid layer in the middle. If the root does not use LVM, go to Extend normal partition root.

가상 디스크 /dev/sda
  └─ 파티션 /dev/sda3
      └─ PV: LVM에 제공한 물리 공간
          └─ VG: rl 같은 공간 풀
              └─ LV: /dev/rl/root
                  └─ XFS 또는 ext4 → /
current statusWhere to expand
VG has as much VFree as you needLV → file system
Only the virtual disk grows and the PV partition remains the same.Partition → PV → LV → File system
The partition has grown, but the PV size remains the same.PV → LV → File system
Planning to add a new blank disk to the same VGNew PV → VG → LV → File System

Also check whether the inode is full at df -ih. Even if there is remaining storage space, creation may fail if there are a large number of small files. If the problem is that a process continues to open a deleted file or the log continues to grow, the cause of the increase must be found separately from expansion.

2. What to leave behind and tools to prepare before work

Secure restorable VM/data backups to other storage locations. Do not use snapshots as the only backups. Partition table and LVM metadata backups are recovery materials, but are not a substitute for file data backups. Package installation and metadata recording may also fail if / is full, so free up work space first.

# Rocky Linux 9
sudo dnf install -y lvm2 xfsprogs e2fsprogs cloud-utils-growpart util-linux
# Ubuntu 24.04 / 26.04
sudo apt update
sudo apt install -y lvm2 xfsprogs e2fsprogs cloud-guest-utils util-linux

The following example assumes VG rl, root LV /dev/rl/root and PV /dev/sda3. An Ubuntu installation may use a name such as /dev/ubuntu-vg/ubuntu-lv. Substitute the values from your own findmnt, pvs and lvs output, and record the current paths and sizes.

ROOT_LV='/dev/rl/root'
sudo vgcfgbackup rl
sudo sfdisk --dump /dev/sda > partition-table-before.sfdisk

The results of vgcfgbackup are stored in /etc/lvm/backup by default. Copy it to separate storage along with the partition table dump. Afterwards, A·B·C are different paths to secure space. Choose the path that suits your condition and leave a record of execution to avoid adding the same capacity multiple times.

A. If there is already free space in the VG

If vgs‘s VFree is sufficient, you don’t need to touch the disk or partition. Below is an example of adding 10GiB to the root LV. -L +10G is the increment and -L 10G is the target total size. Before execution, double-check that ROOT_LV is the actual LV of /.

sudo vgs -o vg_name,vg_size,vg_free
sudo lvs "$ROOT_LV" -o lv_path,lv_size,segtype
sudo lvextend -L +10G "$ROOT_LV"

Next, run the command for the actual filesystem type in the expansion section below. -l +100%FREE can consume all free space in the VG, including space needed for other LVs or later work. Decide the allocation before specifying the increase. See the lvextend size options.

B. When space is added to the end of an existing virtual disk

Increase the virtual disk size first

Workstation checks the backup and disk snapshot/status, then shuts down the VM and increases capacity using the Expand function of the hard disk. Expansion restrictions are checked according to the installed product and disk type. Snapshot files are not randomly deleted from Explorer. Broadcom’s virtual disk expansion guide also explains that VMDK expansion and guest partition expansion are separate.

Boot the VM and check whether the overall size of /dev/sda has grown at lsblk. If the OS doesn’t recognize the new size, a rescan or planned reboot for your device will come first. The size remains the same, but it does not repeat from the next command.

Increase the partition containing the PV

This example requires contiguous unallocated space after /dev/sda3, with the starting sector preserved. Another partition after it prevents extending across that occupied space. Inspect the dry-run target and proposed change first.

sudo growpart -N /dev/sda 3
sudo growpart /dev/sda 3
lsblk -o NAME,PATH,SIZE,TYPE,FSTYPE,MOUNTPOINTS /dev/sda
sudo blockdev --getsize64 /dev/sda3

The argument of growpart is divided into /dev/sda and 3. /dev/sda3 is not a command that takes one argument. If the kernel has not been able to reflect changes to the partition table in use, it will stall until the device size is updated. Plan for any necessary reboots and check again after booting. Check the dry-run and change conditions of growpart manual .

Notify PV of increased size

sudo pvresize /dev/sda3
sudo pvs -o pv_name,pv_size,pv_free,vg_name
sudo vgs -o vg_name,vg_size,vg_free

Configurations identified as /dev/sda, where the PV is the entire disk rather than a partition, omit the growpart and examine pvresize /dev/sda. This branch only applies if pvs actually marks the entire disk as PV. This is not a procedure to initialize a boot disk with existing partitions to a new PV. Document pvresize describes this layer.

After checking the increase in VFree, run lvextend in Section A once and increase the file system. This is why free space does not appear in VG if you omit PV after extending partition.

C. When adding a new blank disk to the VG

This route is a different choice than traditional disk expansion. Verify that the new virtual disk /dev/sdb is an empty deviceassigned for this operation with the hypervisor’s disk identification information. Don’t just trust the device name. The next two commands are confirmation steps that read the partition/signature.

lsblk -o NAME,PATH,SIZE,TYPE,FSTYPE,MOUNTPOINTS /dev/sdb
sudo wipefs -n /dev/sdb
sudo pvs

Proceed with the initialization below only after confirming whether you are using any mounts, existing partitions, file systems, or other VGs, and whether you own the device. An output of no signature alone does not guarantee that the disk is free of sensitive data. pvcreate is a change command that writes new PV metadata. Do not run on an existing root PV.

# 새 빈 디스크 /dev/sdb를 디스크 전체 PV로 쓰기로 확인한 경우만 실행
sudo pvcreate /dev/sdb
sudo vgextend rl /dev/sdb
sudo vgs -o vg_name,vg_size,vg_free

Afterwards, expand the LV and file system. Adding disks to a VG does not create RAID. If the root LV is placed across two disks, failure of either disk can affect the root data, so this is reflected in the backup and availability design. Please check the official procedure for adding PV to VG based on .

3. Increase the file system

If the LV has grown through one of A·B·C, check the actual form of / again. Of the two paths below, only format, , runs. This is not an mkfs operation that creates a new file system.

findmnt -no SOURCE,FSTYPE /
sudo lvs "$ROOT_LV" -o lv_path,lv_size

For XFS

sudo xfs_growfs /

An XFS extension specifies the mount point of a mounted filesystem. It runs with a large block device, where / in this article is the root XFS mount point. As of RHEL 9, XFS shrink is not supported, so the LV size is not reduced to undo the expansion. Please refer to the XFS extension document.

For ext4

sudo resize2fs "$ROOT_LV"

ext4 specifies the block device path. Online expansion during mount is possible under supported conditions. Does not add a procedure to force e2fsck to run on mounted /. If an offline inspection is required, prepare a separate recovery environment and inspection time. resize2fs Manual explains the relationship between file system and partition size.

You can also run it bundled with lvextend -r.

Instead of two separate steps, you can request expansion of the LV and supporting file system with sudo lvextend -r -L +10G "$ROOT_LV". If you already added +10G earlier, you will not run this command again. Since only the filesystem expansion step may have failed, the error is followed by a comparison of lvs and df. If you repeat lvextend while the LV has grown, it may become larger than planned. RHEL 9’s LV expansion procedure also guides you through the resizefs option.

4. Check if it has increased to /

findmnt -no SOURCE,FSTYPE,OPTIONS /
df -hT /
df -ih /
sudo lvs -o lv_path,lv_size,vg_name
sudo vgs -o vg_name,vg_size,vg_free
sudo journalctl -k -b -p warning --no-pager

If lvs has grown but df is the same, check the file system level first. If the root changes to read-only or an I/O error occurs, do not run any more extended commands and check the status of the storage device and file system. A simple extension that preserves the existing boot path and UUID usually does not require changing fstab to the new device, but you should also check whether reboot is possible and the app’s write behavior.

Check Scope · 2026-10-18: On an additional virtual disk of Ubuntu 24.04.5 VM, I extended ext4·XFS over plain linear LVM, increased the size of PV partition and disk-wide PV, added VG of new PV and ran lvextend -r. Existing files in the lab volume were verified with a before-and-after SHA-256 comparison. This is not the result of directly expanding the actual root LVM volume of each distribution, and the example increase of +10G should be adjusted to fit your free space needs.

Download the network·systemd example file·Netplan YAML, bundled scripts that read service·environment files and storage structures. Change the address and device name to match the actual environment. It does not include scripts to auto-expand disks.