1.查看磁盘占用
root@wwyt-prod06-hlsh:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 793M 50M 744M 7% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 29G 29G 0 100% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda2 976M 108M 802M 12% /boot
/dev/loop0 72M 72M 0 100% /snap/lxd/16099
/dev/loop1 45M 45M 0 100% /snap/snapd/15534
/dev/loop2 68M 68M 0 100% /snap/lxd/22753
/dev/loop3 44M 44M 0 100% /snap/snapd/15177
/dev/loop4 62M 62M 0 100% /snap/core20/1405
/dev/loop5 55M 55M 0 100% /snap/core18/1880
/dev/loop6 62M 62M 0 100% /snap/core20/1376
/dev/loop7 56M 56M 0 100% /snap/core18/2344
发现磁盘已占满,需要扩容;
2.查看系统卷组:
root@wwyt-prod06-hlsh:~# 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 <59.00 GiB
PE Size 4.00 MiB
Total PE 15103
Alloc PE / Size 7552 / 29.50 GiB
Free PE / Size 7551 / <29.50 GiB
VG UUID P0V2bc-ClZT-rZXH-P8RU-fT4R-Jrhx-176qNw
其中,Free PE / Size 7551 / <29.50 GiB 是剩余还可使用的空间,
3.执行扩容指令(示例):
root@wwyt-prod06-hlsh:~# lvextend -L 50G /dev/mapper/ubuntu--vg-ubuntu--lv //增大至50G
Size of logical volume ubuntu-vg/ubuntu-lv changed from 49.50 GiB (12672 extents) to 50.00 GiB (12800 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
4.重新计算磁盘大小
root@wwyt-prod06-hlsh:~# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 7
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 13107200 (4k) blocks long.
5.再次查看磁盘情况
root@wwyt-prod06-hlsh:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 793M 1.6M 792M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 50G 29G 19G 61% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda2 976M 108M 802M 12% /boot
/dev/loop2 56M 56M 0 100% /snap/core18/2344
/dev/loop3 72M 72M 0 100% /snap/lxd/16099
/dev/loop1 62M 62M 0 100% /snap/core20/1405
/dev/loop0 62M 62M 0 100% /snap/core20/1376
/dev/loop4 55M 55M 0 100% /snap/core18/1880
/dev/loop5 68M 68M 0 100% /snap/lxd/22753
/dev/loop6 45M 45M 0 100% /snap/snapd/15534
/dev/loop7 44M 44M 0 100% /snap/snapd/15177
tmpfs 793M 0 793M 0% /run/user/0
root@wwyt-prod06-hlsh:~# vgdisplay
--- Volume group ---
VG Name ubuntu-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
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 <59.00 GiB
PE Size 4.00 MiB
Total PE 15103
Alloc PE / Size 12800 / 50.00 GiB
Free PE / Size 2303 / <9.00 GiB
VG UUID P0V2bc-ClZT-rZXH-P8RU-fT4R-Jrhx-176qNw
网友评论