LVM and filesystem resize commands require a small amount of free space to write metadata. If the disk is truly at 100%, these commands may fail.
Action | Command |
|---|---|
Clear Package Cache |
|
Truncate Logs |
|
Clear Temp Files |
|
Note: Truncating logs is safer than deleting them, as it preserves file descriptors and avoids "file in use" issues.
Phase 2: Physical Volume (PV) Expansion
Before the Operating System can see the extra space, you must update the LVM Physical Volume layer.
Scenario A: Resizing an existing partition
If you increased the size of an existing disk (e.g., /dev/xvda):
-
Resize the partition table:
growpart /dev/xvda 3 -
Update LVM metadata:
pvresize /dev/xvda3
Scenario B: Adding a brand new disk/partition
If you attached a second disk (e.g., /dev/xvdb):
-
Initialize for LVM:
pvcreate /dev/xvdb -
Add to Volume Group:
vgextend centos /dev/xvdb
Phase 3: Extending the Logical Volume (LV)
Now that the Volume Group has free space, you must tell the Logical Volume (the "container") to expand.
-
Command:
lvextend -l +100%FREE /dev/mapper/centos-root -
Alternative: Use
-L +50Gif you only want to add a specific amount.
Phase 4: Expanding the Filesystem
The final step is to grow the actual filesystem so the OS recognizes the new capacity. Identify your filesystem type first using df -T.
Option A: XFS (Standard on RHEL/CentOS 7+)
XFS must be grown using the mount point.
- Command:
xfs_growfs /
Option B: Ext4 (Standard on Ubuntu/Debian)
Ext4 must be grown using the device path.
- Command:
resize2fs /dev/mapper/centos-root
Phase 5: Verification & Summary
Verification Table
Level | Command | What to check |
|---|---|---|
Physical |
| Ensure the parent disk reflects the total hardware size. |
LVM |
| Ensure |
Filesystem |
| Ensure "Avail" is positive and "Use%" is below 100%. |
Master Command Reference
Layer | Action | Command |
|---|---|---|
Physical | Resize Partition |
|
LVM | Resize PV |
|
LVM | Resize LV |
|
XFS | Grow Space |
|
Ext4 | Grow Space |
|