安装ubuntu时,如果选择的是自动分组,就会按照逻辑卷的形式来分区,并且只分配100G其余的并不会被分配
下面将Ubuntu 磁盘未分配空间进行全挂载
查看磁盘现状
查看挂载信息
根目录挂载了97G
root@ubuntu:/home/johnny/gitea# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 795M 1.5M 793M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 97G 6.6G 86G 8% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 94M 1.7G 6% /boot
tmpfs 795M 12K 795M 1% /run/user/1000
查看磁盘信息
sda3一共是198G,实际ubuntu–vg-ubuntu–lv挂载了99G
root@ubuntu:/home/johnny/gitea# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 44.3M 1 loop /snap/snapd/23258
loop1 7:1 0 73.9M 1 loop /snap/core22/1722
loop2 7:2 0 139.6M 1 loop /snap/docker/2963
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 198G 0 part
└─ubuntu--vg-ubuntu--lv 252:0 0 99G 0 lvm /
sr0 11:0 1 1024M 0 rom
挂载未分配空间
采用 LV(Logical Volume) 使用全部 VG(Volume Group)
命令 vgdisplay
可以查看lvm卷组的信息;
root@ubuntu:/home/johnny/gitea# 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 <198.00 GiB
PE Size 4.00 MiB
Total PE 50687
Alloc PE / Size 25343 / <99.00 GiB
Free PE / Size 25344 / 99.00 GiB
VG UUID JkHV8i-gcYv-xxxx-8fdj-xxxx-ezsq-xxxxxx
看到 Free PE / Size > 0,表示还有扩容空间。
使用 lvresize
扩容剩下所有空间。
root@ubuntu:/home/johnny/gitea# lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <99.00 GiB (25343 extents) to <198.00 GiB (50687 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
执行resize2fs使扩容生效
注意:执行这个命令以上修改才会生效的!
root@ubuntu:/home/johnny/gitea# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 25
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 51903488 (4k) blocks long.
查看结果
root@ubuntu:/home/johnny/gitea# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 795M 1.5M 793M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 195G 6.6G 179G 4% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 94M 1.7G 6% /boot
tmpfs 795M 12K 795M 1% /run/user/1000
root@ubuntu:/home/johnny/gitea# 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 <198.00 GiB
PE Size 4.00 MiB
Total PE 50687
Alloc PE / Size 50687 / <198.00 GiB
Free PE / Size 0 / 0
VG UUID JkHV8i-gcYv-xxxx-8fdj-xxxx-ezsq-xxxxxx
参考:
https://www.cnblogs.com/guangdelw/p/17822292.html
https://blog.csdn.net/weixin_43896211/article/details/144455267