Extending partition size LVM Linux
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:
- The kernel must notice the disk is bigger.
- A new partition must be created in the extra space.
- That partition must be added to the volume group.
- 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 (vgsshows a non-zeroVFree), 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:
df -hT
lsblk
sudo pvs
sudo vgs
sudo lvsProcedure#
1. Rescan the disk#
The guest kernel caches the disk size and needs prompting to look again.
echo 1 | sudo tee /sys/class/block/sda/device/rescanSubstitute sda with the disk you enlarged.
If that has no effect, rescan the whole SCSI bus:
echo "- - -" | sudo tee /sys/class/scsi_host/host0/scan2. Confirm the kernel sees the new size#
lsblk
sudo fdisk -l /dev/sdaThe 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#
sudo fdisk /dev/sdaInside fdisk:
| Prompt | Enter | Meaning |
|---|---|---|
Command | n | New partition |
Partition type | p | Primary |
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 |
Command | t | Change partition type |
Partition number | (the new one) | e.g. 3 |
Hex code | 8e | Linux LVM |
Command | w | Write and exit |
Warning: Usen(new) only. Never used(delete) on a disk holding live data.fdiskmakes no changes untilw, so if you lose track of where you are, pressqto 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#
sudo partprobe -s
lsblkThe new partition, e.g. /dev/sda3, should now be listed.
Note: On some systemspartprobecannot 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 reasonpvcreatefails with "device not found" in the next step.
5. Add the new partition to LVM#
sudo pvcreate /dev/sda3Identify the volume group to extend:
sudo vgdisplayExtend it with the new physical volume:
sudo vgextend centos /dev/sda3Replace centos with the actual VG name from vgdisplay.
Confirm the free space has appeared:
sudo pvscan
sudo vgsVFree should now show the added capacity.
6. Extend the logical volume#
Identify the target LV:
sudo lvdisplayGrow it into all available free space:
sudo lvextend -l +100%FREE /dev/centos/rootOr add a specific amount:
sudo lvextend -L +10G /dev/centos/root7. Grow the filesystem#
Extending the volume does not extend the filesystem inside it. Check which type you have:
df -hT /Then run the matching command:
# xfs — the default on RHEL 7+
sudo xfs_growfs /
# ext4
sudo resize2fs /dev/centos/rootNote:xfs_growfstakes the mount point;resize2fstakes 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 -rcombines steps 6 and 7 and picks the right filesystem tool automatically: ``bash sudo lvextend -r -l +100%FREE /dev/centos/root``
Verification#
df -hT
sudo lvs
sudo vgsThe mount point should show the new capacity. Then reboot to confirm the change is stable and the machine still boots cleanly:
sudo rebootVerify again after it returns. Only then remove the VM snapshot.
Troubleshooting#
| Symptom | Cause and fix |
|---|---|
| Disk still shows old size after rescan | Rescan 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 busy | Normal on a disk with mounted partitions. Reboot to apply. |
Insufficient free extents on lvextend | The VG has less space than requested. Check vgs and use -l +100%FREE. |
xfs_growfs: not a mounted XFS filesystem | You passed the device path. Pass the mount point instead. |
df unchanged after lvextend | Filesystem was not grown. Run step 7. |
| System will not boot after the change | Boot from rescue media or restore the snapshot. This is why the snapshot is taken first. |
Related#
- Extending partition size by adding new disk LVM Linux — safer alternative that avoids editing an in-use partition table.
- Extending Non-LVM Disk Linux
- Creating new LVM Partition Linux
- Linux Storage & Filesystem