df -h |grep -w / 命令查看根分区空间不够用。
lsblk 发现 / 分区所用的 nvme0n1p3 并没有完全用完。
bash
lsblk
bash
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
nvme0n1 259:0 0 931.5G 0 disk
├─nvme0n1p1 259:1 0 1G 0 part /boot/efi
├─nvme0n1p2 259:2 0 2G 0 part /boot
└─nvme0n1p3 259:3 0 928.5G 0 part
└─ubuntu--vg-ubuntu--lv 253:0 0 100G 0 lvm /
继续查看 lv 名字
bash
lvdisplay
bash
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID gQCUed-wjGN-zXaD-C4Q4-2jSH-Fz1k-8OS7m1
LV Write Access read/write
LV Creation host, time ubuntu-server, 2023-03-20 22:39:29 +0800
LV Status available
# open 1
LV Size 100.00 GiB
Current LE 25600
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
查看 vg 状态是否有剩余的 PE
bash
vgdisplay
bash
--- 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 <928.46 GiB
PE Size 4.00 MiB
Total PE 237685
Alloc PE / Size 25600 / 100.00 GiB
Free PE / Size 212085 / <828.46 GiB
VG UUID leSGau-INYq-JT47-Zydr-CjMn-4Cff-G1NeUX
扩容
/dev/ubuntu-vg/ubuntu-lv 为根分区的 lv 的名字
bash
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
调整文件系统大小
bash
resize2fs /dev/ubuntu-vg/ubuntu-lv
查看扩容是否成功
bash
df -h |grep -w /
bash
/dev/mapper/ubuntu--vg-ubuntu--lv 914G 70G 807G 8% /