هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
The quick answer
Step by step
- See the layout — which LV, which VG, how much is free:
VFree 0 = no free space: add some first (step 2 or 3).
- Case A — a new disk (for example
/dev/sdb):
- Case B — the existing disk was made bigger (VMware, cloud disk resize). Grow the partition, then the PV:
growpart /dev/sda 3
pvresize /dev/sda3
vgsgrowpart is in the cloud-utils-growpart package. If the PV is the whole disk (no partition), only pvresize /dev/sdb.
- Grow the LV and the file system together:
The first adds 20 GB; the second takes all free space in the VG. Keep some free space when you use snapshots.
- **Forgot
-r?** Grow the file system yourself:
xfs_growfs /var
resize2fs /dev/rhel/varxfs_growfs takes the mount point; resize2fs (ext4) takes the device.
- Shrinking: XFS can not shrink. ext4 can, but only unmounted (
lvreduce -r) — plan the size well, and back up first.
Check that it worked
Common problems
| Problem | Cause | Fix |
|---|---|---|
Insufficient free space | No free extents in the VG. | Add a disk (vgextend) or grow the disk (growpart + pvresize). |
df still shows the old size | Only the LV grew, not the file system. | xfs_growfs MOUNTPOINT or resize2fs DEVICE. |
pvresize changes nothing | The partition was not grown. | growpart DISK PARTNUM first. |
growpart: NOCHANGE | The disk itself is not bigger (yet). | Grow it in the hypervisor/cloud; on VMware rescan: echo 1 > /sys/class/block/sda/device/rescan. |
New disk not visible in lsblk | The kernel did not see it. | Rescan SCSI hosts or reboot (in a window). |
| Want to shrink XFS | Not possible. | Create a new smaller LV, copy the data, switch. |
Go further
- Command pages: lvextend, vgextend, pvcreate, lvs, vgs, xfs_growfs, resize2fs, lsblk.
- Next how-tos: Check disk space and find what fills the disk, Add swap space, Mount a disk at boot with fstab, Grow an XFS file system online.
- Learn it: RHCSA — LVM layers, RHCSA — vgextend, RHCSA — lvextend, RH134 — Extend an LV.
- Practise: Lab: create LVM volumes, Lab: grow and shrink logical volumes.
1What does -r do in lvextend -r -L +20G?
It grows the file system together with the logical volume.
2The disk was made bigger in the cloud, but vgs shows no free space. What is missing?
Grow the partition (growpart) and then the PV (pvresize).