الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

lvextend

Make a logical volume bigger — with -r also its file system, while it stays mounted.

المستوى
امتحان RHCSA
المجموعة
LVM
يحتاج root
نعم
الحزمة
lvm2
يُسمّى أيضًا
lvresize

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

lvextend -L +SIZE adds space; -L SIZE sets the total size; -l +N / -l +100%FREE work with extents. The VG needs enough free space (add disks with vgextend).

Always add -r (--resizefs): it runs xfs_growfs or resize2fs after the LV grew. Without it the file system keeps its old size. lvresize can grow and shrink with the same options.

طريقة الكتابة

lvextend (-L [+]SIZE | -l [+]EXTENTS) [-r] [OPTION]... VG/LV [PV...]
lvresize (-L [+|-]SIZE | -l [+|-]EXTENTS) [-r] [OPTION]... VG/LV

الخيارات 28

الأكثر استخدامًا

-L, --size [+]SIZE
New size or + added size, like +2G or 10G.
-l, --extents [+]N[%VG|%LV|%PVS|%FREE|%ORIGIN]
In extents or percent, like +100%FREE.
-r, --resizefs
Also grow the file system.
-n, --nofsck
Do not check the file system before resizing.
--fs checksize|resize|resize_fsadm|ignore
How to handle the file system (newer lvm2).
--fsmode manage|offline|nochange
May LVM mount or unmount for the resize (newer lvm2).
-i, --stripes N, -I, --stripesize SIZE
Stripes for the new part.
-m, --mirrors N
Mirrors (mirror LVs).
--alloc POLICY
Allocation policy.
--poolmetadatasize [+]SIZE
Grow the metadata of a thin pool.
--type TYPE
Segment type.
--nosync
Do not sync new mirror parts.
--usepolicies
Use the autoextend policy from lvm.conf (thin pools, snapshots).
-f, --force
Do not ask.
-A, --autobackup y|n
Back up the metadata.
--noudevsync
Do not wait for udev.
--reportformat basic|json
Output format.

Common LVM options

-t, --test
Test only; change nothing.
-v, --verbose
More output (repeat for more).
-q, --quiet
Less output.
-y, --yes
Answer yes to questions.
-d, --debug
Debug output.
--config STRING
Override lvm.conf settings for this command only.
--commandprofile STRING, --profile STRING
Use a configuration profile.
--devices PV, --devicesfile STRING
Limit the devices LVM looks at.
--driverloaded y|n, --nolocking, --lockopt STRING, --nohints, --journal STRING
Special and debug settings.
-h, --help, --longhelp
Show help.
--version
Show the version.

أمثلة 10

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Add 2 GiB with the file system

    lvextend -r -L +2G /dev/vgdata/lvdata
      Size of logical volume vgdata/lvdata changed from 5.00 GiB to 7.00 GiB.
      Logical volume vgdata/lvdata successfully resized.

    Works online for XFS and ext4.

  2. 2Set a total size

    lvextend -r -L 10G /dev/vgdata/lvdata

    10 GiB in total (no +).

  3. 3Use all free space in the VG

    lvextend -r -l +100%FREE /dev/vgdata/lvweb

    Common after vgextend.

  4. 4Add extents

    lvextend -r -l +25 /dev/vgfiles/lvfiles

    25 × PE size.

  5. 5Check the result

    df -h /data; lvs vgdata

    df must show the new size too.

  6. 6Forgot -r? Grow the file system later

    xfs_growfs /data
    resize2fs /dev/vgdata/lvweb

    XFS by mount point, ext4 by device.

  7. 7Grow the root file system

    lvextend -r -L +5G /dev/rhel/root

    Online, no reboot.

  8. 8Grow a swap LV

    swapoff /dev/rhel/swap; lvextend -L +1G /dev/rhel/swap; mkswap /dev/rhel/swap; swapon -a

    Swap must be recreated (check that the UUID in fstab still matches, or use the LV path).

  9. 9Only use space of a chosen PV

    lvextend -r -L +2G /dev/vgdata/lvdata /dev/vdd

    New extents come from vdd.

  10. 10Grow a thin pool before it fills

    lvextend -L +5G vgdata/pool1

    A full thin pool stops all writes in its volumes.

انتبه

  • Without -r: LV bigger, file system not. df -h shows the problem.
  • "Insufficient free space": add a PV with vgextend first.

رموز الخروج

0 :: Done. 5 :: Error.

الدليل الكامل

هذه الصفحة تشرح الأمر بكلمات بسيطة. الدليل الأصلي فيه كل التفاصيل.

في الطرفية: man 8 lvextend