linux磁盘分为物理盘和逻辑盘,可以通过挂载操作将物理盘的空间拓展到逻辑盘中。
步骤 1:检查当前 LVM 状态
sudo pvdisplay # 查看物理卷(PV)
--- Physical volume ---
PV Name /dev/sda3
VG Name ubuntu-vg
PV Size <98.00 GiB / not usable 0
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 25087
Free PE 0
Allocated PE 25087
PV UUID JHy9yT-0nox-XO3s-npPX-9gus-Hg4y-ZAgeEK
sudo vgdisplay # 查看卷组(VG)
--- 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 <98.00 GiB
PE Size 4.00 MiB
Total PE 25087
Alloc PE / Size 25087 / <98.00 GiB
Free PE / Size 0 / 0
VG UUID NrhLNt-fRv4-BQQ4-jTq0-YsMn-uluU-tfuk1X
sudo lvdisplay # 查看逻辑卷(LV)
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID HdVniS-7Tpe-GHaV-9LZp-SMPc-G6vV-2TBJQP
LV Write Access read/write
LV Creation host, time ubuntu-server, 2025-10-19 06:51:33 +0000
LV Status available
# open 1
LV Size <98.00 GiB
Current LE 25087
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
步骤 2:初始化 /dev/sdc 为物理卷(PV) (根据lsblk获得物理盘名称)
sudo pvcreate /dev/sdc
步骤 3:将 /dev/sdc 添加到 ubuntu-vg 卷组
sudo vgextend ubuntu-vg /dev/sdc
步骤 4:扩展逻辑卷 ubuntu-lv
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
如果物理盘的一部分空间挂载到逻辑盘中,拓展空间直接从此步骤开始即可。
步骤 5:调整文件系统大小
如果是 ext4(默认): sudo resize2fs /dev/ubuntu-vg/ubuntu-lv 如果是 xfs: sudo xfs_growfs /
步骤 6:验证扩展结果
df -h / # 检查 `/` 的总大小 lsblk # 查看所有磁盘和 LVM 结构 sudo pvdisplay # 确认 `/dev/sdc` 已被使用