步骤
查看当前的分区结构
[root@localhost ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Jun 13 10:26:50 2024
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=644e8a4c-b0dd-4fe6-a6d7-f0e06c273aa8 /boot xfs defaults 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
取消 /home
盘挂载
umount /home/
删除 /home
对应的分区,加到 /
根目录下
lvremove /dev/mapper/centos-home
lvextend -l +100%free /dev/mapper/centos-root
刷新一下操作
xfs_growfs /dev/mapper/centos-root
注释掉 /etc/fstab
分区中对 home
分区的描述(示例注释的第三行),避免开机后的从新分区
/dev/mapper/centos-root / xfs defaults 0 0
UUID=644e8a4c-b0dd-4fe6-a6d7-f0e06c273aa8 /boot xfs defaults 0 0
#/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
注意
lventend
作用是扩展逻辑卷,xfs_growfs
是将xfs
文件系统扩展
- 该方法只适用于
xfs
文件系统,且卸载整个的 /home
目录,而不是按照指定值缩小