环境:
Ubuntu 20.04.3-live-server
问题描述:
Ubuntu 20.04.3-live-server 磁盘如何扩容,磁盘空间有50G,新安装的系统默认只分配20G
1.查看磁盘信息
df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 790M 1.2M 789M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 19G 0.9G 17G 5% /
tmpfs 3.9G 16K 3.9G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/loop0 56M 56M 0 100% /snap/core18/2128
/dev/loop2 71M 71M 0 100% /snap/lxd/21029
/dev/loop1 33M 33M 0 100% /snap/snapd/12704
/dev/vda2 976M 108M 801M 12% /boot
/dev/loop3 44M 44M 0 100% /snap/snapd/14549
/dev/loop4 56M 56M 0 100% /snap/core18/2284
/dev/loop5 62M 62M 0 100% /snap/core20/1328
/dev/loop6 68M 68M 0 100% /snap/lxd/21835
tmpfs 790M 0 790M 0% /run/user/0
2.显示存在的卷组信息
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 <499.00 GiB
PE Size 4.00 MiB
Total PE 127743
Alloc PE / Size 51200 / 200.00 GiB
Free PE / Size 76543 / <29.00 GiB
VG UUID kynKuT-rtTy-Sk9v-txe6-0VKJ-JFxK-2soNbx
Free PE/size显示还有29G可以扩容
解决方案:
1.调整方案
1.例如增大至220G
lvextend -L 220G /dev/mapper/ubuntu--vg-ubuntu--lv
2.例如减小至80G
lvreduce -L 80G /dev/mapper/ubuntu--vg-ubuntu--lv
3.例如增加120G
lvextend -L +120G /dev/mapper/ubuntu--vg-ubuntu--lv
4.例如减小10G
lvreduce -L -10G /dev/mapper/ubuntu--vg-ubuntu--lv
5.例如调整为50G
lvresize -L 50G /dev/mapper/ubuntu--vg-ubuntu--lv
6.例如扩容利用Free PE/size全部空间
lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
(以上选择自己需要扩容的命令)
7.最后执行变更
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
2.扩容
1.这选择输入lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 20.00 GiB (51200 extents) to <499.00 GiB (127743 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
2.执行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 = 63
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 130808832 (4k) blocks long.
3.查看磁盘信息
df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 790M 1.2M 789M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 49G 0.9G 46G 2% /
tmpfs 3.9G 16K 3.9G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/loop0 56M 56M 0 100% /snap/core18/2128
/dev/loop2 71M 71M 0 100% /snap/lxd/21029
/dev/loop1 33M 33M 0 100% /snap/snapd/12704
/dev/vda2 976M 108M 801M 12% /boot
/dev/loop3 44M 44M 0 100% /snap/snapd/14549
/dev/loop4 56M 56M 0 100% /snap/core18/2284
/dev/loop5 62M 62M 0 100% /snap/core20/1328
/dev/loop6 68M 68M 0 100% /snap/lxd/21835
tmpfs 790M 0 790M 0% /run/user/0
可以看到:
/dev/mapper/ubuntu–vg-ubuntu–lv 49G 0.9G 46G 2% /
扩容完成
原创文章,作者:中国IPv6网,如若转载,请注明出处:https://www.ipv6s.com/basis/application/202208282120.html