هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
The quick answer
lsblk /dev/sdb
growpart /dev/sdb 1
xfs_growfs /data
df -h /dataStep by step
- Snapshot first — a disk snapshot in the cloud takes seconds and makes every next step safe.
- Make the disk bigger in the cloud console or CLI (for example
az disk update --size-gb 256,aws ec2 modify-volume --size 256). Most clouds allow it while the VM runs. - Let Linux see the new size — usually automatic; if
lsblkstill shows the old size, rescan:
echo 1 > /sys/class/block/sdb/device/rescan- Grow the partition (quick answer, line 2) —
growpart(packagecloud-utils-growpart/cloud-guest-utils) moves the end of partition 1 to the end of the disk, while mounted. Without growpart:parted /dev/sdb resizepart 1 100%. - Grow the file system (line 3) —
xfs_growfstakes the mount point. It uses all the new space of the partition. - With LVM — grow the physical volume, then the logical volume and the file system in one step:
pvresize /dev/sdb1
lvextend -r -l +100%FREE /dev/vg_data/lv_data-r calls xfs_growfs (or resize2fs) for you.
- ext4 — the same steps, but the last one is
resize2fs /dev/sdb1(it takes the device). - No shrinking — XFS can only grow. To make it smaller you must create a new, smaller file system and copy the data. Plan sizes with that in mind; start smaller and grow.
Check that it worked
lsblk /dev/sdb shows the partition with the new size; df -h /data shows the new size and more free space; the app kept running the whole time.
Common problems
| Problem | Cause | Fix |
|---|---|---|
NOCHANGE: partition 1 … cannot be grown | Kernel still sees the old disk size. | Rescan the device (step 3), then growpart again. |
xfs_growfs: … is not a mounted XFS filesystem | Device given instead of the mount point, or not XFS. | Use the mount point; check findmnt. |
growpart: command not found | Package missing. | Install cloud-utils-growpart / cloud-guest-utils, or use parted resizepart. |
| LV did not grow | PV not resized. | pvresize first; check vgs for free space. |
Space still the same after xfs_growfs | Partition not grown. | growpart before xfs_growfs. |
| Need a smaller XFS | XFS cannot shrink. | New smaller file system and copy (rsync -aHAX). |
Go further
- Command pages: xfs_growfs, lvextend, resize2fs, lsblk.
- Next how-tos: Extend an LVM volume and its file system, Check disk space and find what fills the disk, Partition and format a new disk, Find big files and folders fast.
- Learn it: RHCSA — XFS, RHCSA — lvextend, RH134 — Extend a logical volume.
1Which three layers must grow after a cloud disk is made bigger?
The disk as seen by Linux, the partition (or LVM volume), and the file system.
2Can an XFS file system be made smaller?
No — XFS can only grow; to shrink, create a smaller file system and copy the data.