KB
Storage & Filesystems

Extending partition size LVM Linux

5 min read1013 words17 code blocks

At a glance#

  • Purpose: Grow an LVM logical volume after enlarging an existing virtual disk.
  • Applies to: Linux VMs on VMware or any hypervisor where the disk can be resized.
  • Risk: High — involves editing the partition table of an in-use disk.
  • Time: About 30 minutes.

Overview#

When a VM's disk is enlarged at the hypervisor, the extra space does not appear automatically inside the guest. Four things have to happen in order:

  1. The kernel must notice the disk is bigger.
  2. A new partition must be created in the extra space.
  3. That partition must be added to the volume group.
  4. The logical volume and its filesystem must be grown into it.
Warning: This procedure edits the partition table of a live, in-use disk. Take a VM snapshot or a full backup before starting. If the partition table is written incorrectly, the machine may not boot.
Note: If the volume group already has free space (vgs shows a non-zero VFree), skip straight to step 5 — no partitioning is needed. If you are adding a new disk rather than growing an existing one, use Extending partition size by adding new disk LVM Linux, which is simpler and safer.

Before you start#

  • A VM snapshot or verified backup.
  • Root access and console access as a fallback.
  • The disk already enlarged in vSphere (Edit Settings → Hard disk → new size → OK).

Record the current state so you can prove the change worked:

bash
df -hT
lsblk
sudo pvs
sudo vgs
sudo lvs

Procedure#

1. Rescan the disk#

The guest kernel caches the disk size and needs prompting to look again.

bash
echo 1 | sudo tee /sys/class/block/sda/device/rescan

Substitute sda with the disk you enlarged.

If that has no effect, rescan the whole SCSI bus:

bash
echo "- - -" | sudo tee /sys/class/scsi_host/host0/scan

2. Confirm the kernel sees the new size#

bash
lsblk
sudo fdisk -l /dev/sda

The disk should now report the larger size while its partitions still show the old ones. If it still shows the old size, the rescan did not work — a reboot will always pick it up.

3. Create a partition in the free space#

bash
sudo fdisk /dev/sda

Inside fdisk:

PromptEnterMeaning
CommandnNew partition
Partition typepPrimary
Partition number(accept default)Next free number, e.g. 3
First sector(accept default)Start of free space
Last sector(accept default)End of disk — uses all of it
CommandtChange partition type
Partition number(the new one)e.g. 3
Hex code8eLinux LVM
CommandwWrite and exit
Warning: Use n (new) only. Never use d (delete) on a disk holding live data. fdisk makes no changes until w, so if you lose track of where you are, press q to quit without saving and start again.

If fdisk warns that the device is in use and the kernel will use the old table, that is expected — step 4 addresses it.

4. Refresh the kernel's partition table#

bash
sudo partprobe -s
lsblk

The new partition, e.g. /dev/sda3, should now be listed.

Note: On some systems partprobe cannot refresh a disk with mounted partitions. If the new partition does not appear, reboot. This is expected behaviour, not a fault — and it is the most common reason pvcreate fails with "device not found" in the next step.

5. Add the new partition to LVM#

bash
sudo pvcreate /dev/sda3

Identify the volume group to extend:

bash
sudo vgdisplay

Extend it with the new physical volume:

bash
sudo vgextend centos /dev/sda3

Replace centos with the actual VG name from vgdisplay.

Confirm the free space has appeared:

bash
sudo pvscan
sudo vgs

VFree should now show the added capacity.

6. Extend the logical volume#

Identify the target LV:

bash
sudo lvdisplay

Grow it into all available free space:

bash
sudo lvextend -l +100%FREE /dev/centos/root

Or add a specific amount:

bash
sudo lvextend -L +10G /dev/centos/root

7. Grow the filesystem#

Extending the volume does not extend the filesystem inside it. Check which type you have:

bash
df -hT /

Then run the matching command:

bash
# xfs — the default on RHEL 7+
sudo xfs_growfs /

# ext4
sudo resize2fs /dev/centos/root
Note: xfs_growfs takes the mount point; resize2fs takes the device path. Using the wrong argument is a common cause of "not a valid block device" or "not mounted" errors.

Both are online operations — the filesystem stays mounted and in use.

Tip: From RHEL 8 onwards, lvextend -r combines steps 6 and 7 and picks the right filesystem tool automatically: ``bash sudo lvextend -r -l +100%FREE /dev/centos/root ``

Verification#

bash
df -hT
sudo lvs
sudo vgs

The mount point should show the new capacity. Then reboot to confirm the change is stable and the machine still boots cleanly:

bash
sudo reboot

Verify again after it returns. Only then remove the VM snapshot.

Troubleshooting#

SymptomCause and fix
Disk still shows old size after rescanRescan did not take. Reboot the VM — it always works.
Device /dev/sda3 not found (or ignored by filtering)The kernel has not reread the partition table. Reboot, then re-run pvcreate.
partprobe reports the device is busyNormal on a disk with mounted partitions. Reboot to apply.
Insufficient free extents on lvextendThe VG has less space than requested. Check vgs and use -l +100%FREE.
xfs_growfs: not a mounted XFS filesystemYou passed the device path. Pass the mount point instead.
df unchanged after lvextendFilesystem was not grown. Run step 7.
System will not boot after the changeBoot from rescue media or restore the snapshot. This is why the snapshot is taken first.