Centos下将home分区合并到root分区

1、先备份/home下文件:

[root@localhost ~]# mkdir /backup
[root@localhost ~]# mv /home/*  /backup

2、卸载/home:

[root@localhost ~]# umount /home

3、从逻辑卷中删除home分区:

[root@localhost ~]# echo y|lvremove /dev/mapper/centos-home

4、将腾出的空间扩展到centos-root分区下:

[root@localhost ~]# lvextend -l+100%FREE /dev/mapper/centos-root

5、使扩展生效:

[root@localhost ~]# xfs_growfs /dev/mapper/centos-root

6、 注释掉fstab中的启动挂载项:

[root@localhost ~]# sed -i 's;/dev/mapper/centos-home;#/dev/mapper/centos-home;g' /etc/fstab

7、恢复备份数据到/home下:

[root@localhost ~]# mv /backup/* /home
[root@localhost ~]# rm -rf /backup