这里lsblk命令能看到, ubuntu逻辑分区只有29G, 但总分区60G,还有接近30G未使用。
root@x:/home/x# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 63.9M 1 loop /snap/core20/2105
loop1 7:1 0 40.4M 1 loop /snap/snapd/20671
loop2 7:2 0 87M 1 loop /snap/lxd/27037
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 58G 0 part
└─ubuntu--vg-ubuntu--lv 253:0 0 29G 0 lvm /
sr0 11:0 1 2G 0 rom
查找卷的名称
命令: vgs --noheadings --options name
ubuntu-vg
执行扩容命令: 扩容25G
lvextend -L+25G /dev/ubuntu-vg/ubuntu-lv
root@x:/home/x# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 63.9M 1 loop /snap/core20/2105
loop1 7:1 0 40.4M 1 loop /snap/snapd/20671
loop2 7:2 0 87M 1 loop /snap/lxd/27037
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 58G 0 part
└─ubuntu--vg-ubuntu--lv 253:0 0 54G 0 lvm /
sr0 11:0 1 2G 0 rom
-----------
root@xunao:~/dockerapps/zhongchuan# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 193M 1.4M 192M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 29G 25G 2.4G 92% /
tmpfs 964M 0 964M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 131M 1.7G 8% /boot
tmpfs 193M 4.0K 193M 1% /run/user/1000
root@xunao:~/dockerapps/zhongchuan# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 63.9M 1 loop /snap/core20/2105
loop1 7:1 0 63.9M 1 loop /snap/core20/2318
loop2 7:2 0 87M 1 loop /snap/lxd/27037
loop3 7:3 0 40.4M 1 loop /snap/snapd/20671
loop4 7:4 0 38.8M 1 loop /snap/snapd/21759
loop5 7:5 0 87M 1 loop /snap/lxd/29351
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 58G 0 part
└─ubuntu--vg-ubuntu--lv 253:0 0 54G 0 lvm /
sr0 11:0 1 2G 0 rom
扩展文件大小
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
最后:
root@xunao:~/dockerapps/zhongchuan# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 193M 1.4M 192M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 53G 25G 26G 49% /
tmpfs 964M 0 964M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 131M 1.7G 8% /boot
tmpfs 193M 4.0K 193M 1% /run/user/1000