安装ubuntu20.04 server后使用df查看挂载的可用空间只有100G而我安装系统的硬盘为500G。因此尝试从网上找寻相关的解决办法。亲测可行的办法如下:
1,执行df -h
查看当前存储设备挂载情况
huangjunjie@ubuntu:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 784M 12M 772M 2% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 98G 19G 75G 21% /
tmpfs 3.9G 60K 3.9G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 131M 1.7G 8% /boot
/dev/sda1 1.1G 6.1M 1.1G 1% /boot/efi
tmpfs 784M 4.0K 784M 1% /run/user/1000
查询到/dev/mapper/ubuntu--vg-ubuntu--lv
只有100G左右。因此需要将剩余空间分配给它。
2.执行sudo sudo vgdisplay
查询可分配空间
huangjunjie@ubuntu:~$ sudo vgdisplay
[sudo] password for huangjunjie:
--- 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 <462.71 GiB
PE Size 4.00 MiB
Total PE 118453
Alloc PE / Size 25600 / 100.00 GiB
Free PE / Size 92853 / <362.71 GiB
VG UUID DtyFC3-ko26-ynbz-Q4iU-xEOg-pKeK-UfqdLc
查询到可分配的分区Free PE / Size
还有300多G
3.执行sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
将剩余空间分配给/dev/mapper/ubuntu--vg-ubuntu--lv
huangjunjie@ubuntu:~$ sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 100.00 GiB (25600 extents) to <462.71 GiB (118453 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
4.执行sudo resize2fs /dev/mapper/ubuntu–vg-ubuntu–lv
重新计算大小
huangjunjie@ubuntu:~$ sudo resize2fs /dev/mapper/ubuntu–vg-ubuntu–lv
resize2fs 1.46.5 (30-Dec-2021)
open: No such file or directory while opening /dev/mapper/ubuntu–vg-ubuntu–lv
huangjunjie@ubuntu:~$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 58
5.执行df -h
再次看到挂载分区大小
huangjunjie@ubuntu:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 784M 12M 772M 2% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 455G 19G 417G 5% /
tmpfs 3.9G 60K 3.9G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 131M 1.7G 8% /boot
/dev/sda1 1.1G 6.1M 1.1G 1% /boot/efi
tmpfs
此时/
已经把剩余的空间全部分配了
特别鸣谢:
https://blog.csdn.net/weixin_43302340/article/details/120341241