centos7 卸载home 扩大root空间

https://www.dounaite.com/article/627547a2ac359fc9132072b6.html
https://www.cnblogs.com/straycats/p/7769105.html

————————————–
1.2 修改fstab(这一步非常重要,千万别漏了)

准备卸载/home文件系统,centos启动时会对/etc/fstab的内容逐一检测,由于fstab默认有/home,如果不修改fstab,重启之后会发现centos跪了。

所以卸载之前,要先注释掉/home,不让系统开机检测/home。

# 编辑fstab

vi /etc/fstab

注释掉/home的内容,wq保存。

#/dev/mapper/centos-home /home xfs defaults 0 0

——————————————————–

linux将home目录下的磁盘挂载到root
卸载磁盘

umount /dev/mapper/centos-home

删除LVM逻辑卷

[root@localhost /]# lvremove /dev/mapper/centos-home
# 输入命令后输入 y
Do you really want to remove active logical volume centos/home? [y/n]: y
Logical volume “home” successfully removed

拓展root 所在卷的Lvm逻辑卷

[root@localhost /]# lvextend -L +141G /dev/mapper/centos-root
Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 191.00 GiB (48896 extents).
Logical volume centos/root successfully resized.

拓展root 文件系统

[root@localhost /]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=13107200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=6400, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13107200 to 500695047

若需新增卷至home,则需以下步骤

# 1、重建home lvm逻辑卷 (需先查看磁盘剩余大小)
[root@localhost /]# lvcreate -L 100G -n /dev/mapper/centos-home

# 2、创建文件系统
[root@localhost /]# mkfs.xfs /dev/mapper/centos-home

# 3、挂载
[root@localhost /]# mount /dev/mapper/centos-home