root@xserver:~# 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 <930.01 GiB
PE Size 4.00 MiB
Total PE 238082
Alloc PE / Size 51200 / 200.00 GiB
Free PE / Size 186882 / <730.01 GiB
VG UUID y2MIFl-1LSQ-LdlQ-OE3W-U7E3-f0zB-Hrlq45
可以看到还有Free PE/Size 186882/<730.01 GiB,下面就要把这部分空间利用起来
看磁盘目录
root@tboyserver:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 32G 0 32G 0% /dev
tmpfs 6.3G 1.6M 6.3G 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 196G 12G 175G 6% /
tmpfs 32G 4.0K 32G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/nvme0n1p2 976M 107M 802M 12% /boot
/dev/nvme0n1p1 511M 5.3M 506M 2% /boot/efi
/dev/loop0 56M 56M 0 100% /snap/core18/2246
/dev/loop1 56M 56M 0 100% /snap/core18/2253
/dev/loop3 33M 33M 0 100% /snap/snapd/12704
/dev/loop4 68M 68M 0 100% /snap/lxd/21835
/dev/loop2 71M 71M 0 100% /snap/lxd/21029
/dev/loop5 33M 33M 0 100% /snap/snapd/13640
/dev/loop6 62M 62M 0 100% /snap/core20/1242
tmpfs 6.3G 0 6.3G 0% /run/user/1000
扩展磁盘空间
root@xserver:~# lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 200.00 GiB (51200 extents) to <930.01 GiB (238082 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
重新计算磁盘大小
root@xserver:~# 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 = 25, new_desc_blocks = 117
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 243795968 (4k) blocks long.
再次查看磁盘情况:
root@xserver:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 32G 0 32G 0% /dev
tmpfs 6.3G 1.6M 6.3G 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 915G 12G 865G 2% /
tmpfs 32G 4.0K 32G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/nvme0n1p2 976M 107M 802M 12% /boot
/dev/nvme0n1p1 511M 5.3M 506M 2% /boot/efi
/dev/loop0 56M 56M 0 100% /snap/core18/2246
/dev/loop1 56M 56M 0 100% /snap/core18/2253
/dev/loop3 33M 33M 0 100% /snap/snapd/12704
/dev/loop4 68M 68M 0 100% /snap/lxd/21835
/dev/loop2 71M 71M 0 100% /snap/lxd/21029
/dev/loop5 33M 33M 0 100% /snap/snapd/13640
/dev/loop6 62M 62M 0 100% /snap/core20/1242
tmpfs 6.3G 0 6.3G 0% /run/user/1000
root@xserver:~# 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 <930.01 GiB
PE Size 4.00 MiB
Total PE 238082
Alloc PE / Size 238082 / <930.01 GiB
Free PE / Size 0 / 0
VG UUID y2MIFl-1LSQ-LdlQ-OE3W-U7E3-f0zB-Hrlq45
评论 (0)