ubuntu22.04安装完后硬盘变小
2024年9月5日大约 1 分钟约 341 字
ubuntu22.04安装完后硬盘变小
1、200G的硬盘,安装完后发现只有不足100G可用
df -hl

2、fdisk查看明明有个198GB
fdisk -l

3、发现有99G,25344没有分配
#查看lvm卷信息
vgdisplay
# 如果看到 Free PE / Size > 0,表示还有扩容空间
或
lvm vgdisplay -v

4、分配并退出
扩容命令
//按百分比扩
lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
#lvextend -l+25344 /dev/mapper/ubuntu--vg-ubuntu--lv
#lvextend -L 10G /dev/mapper/ubuntu--vg-ubuntu--lv //增大或减小至19G
#lvextend -L +10G /dev/mapper/ubuntu--vg-ubuntu--lv //增加10G
#lvreduce -L -10G /dev/mapper/ubuntu--vg-ubuntu--lv //减小10G

5、使调整生效,看看是ext还是xfs的文件系统
df -lhT

如果是xfs
xfs_growfs /dev/mapper/ubuntu--vg-ubuntu--lv
如果是ext
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

6、查看结果
df -lhT
#检查扩容结果
vgdisplay
