root@ubuntu:~# vgdisplay --- Volume group --- VG Name ubuntu-vg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size <498.00 GiB #VG卷组总空间 PE Size 4.00 MiB Total PE 127487 Alloc PE / Size 25600 / 100.00 GiB # 当前空间 Free PE / Size 101887 / <398.00 GiB #剩余可扩容的空间 VG UUID 7VfFQ1-HLxt-Noty-N7sM-wqee-JSqz-7qoqIK root@ubuntu:~#
root@ubuntu:~# lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv Size of logical volume ubuntu-vg/ubuntu-lv changed from 100.00 GiB (25600 extents) to <498.00 GiB (127487 extents). Logical volume ubuntu-vg/ubuntu-lv successfully resized. root@ubuntu:~# resize2fs /dev/ubuntu-vg/ubuntu-lv resize2fs 1.46.5 (30-Dec-2021) Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required old_desc_blocks = 13, new_desc_blocks = 63 The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 130546688 (4k) blocks long. root@ubuntu:~#
**注意:**不同文件系统类型使用不同的指令。
xfs文件系统类型使用xfs_groufs进行扩容。
1
xfs_growfs 逻辑卷完整路径(如/dev/vg1/lv1)
ext文件系统类型用resize2fs命令进行扩容。
1
resize2fs 逻辑卷完整路径(如/dev/vg1/lv1)
当前根路径逻辑卷空间
1
lvdisplay
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
root@ubuntu:~# lvdisplay --- Logical volume --- LV Path /dev/ubuntu-vg/ubuntu-lv LV Name ubuntu-lv VG Name ubuntu-vg LV UUID CRdFXA-z5pS-K4jA-Wevg-4UZK-Y47L-iMj3Uv LV Write Access read/write LV Creation host, time ubuntu-server, 2023-08-30 15:08:07 +0000 LV Status available # open 1 LV Size <498.00 GiB Current LE 127487 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 root@ubuntu:~#
root@ubuntu:~# vgdisplay --- Volume group --- VG Name ubuntu-vg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size <498.00 GiB PE Size 4.00 MiB Total PE 127487 Alloc PE / Size 127487 / <498.00 GiB Free PE / Size 0 / 0 #可以看到已经没有可以扩容的空间了 VG UUID 7VfFQ1-HLxt-Noty-N7sM-wqee-JSqz-7qoqIK root@ubuntu:~#