总体过程:
把/home内容备份,然后将/home文件系统所在的逻辑卷删除,扩大/root文件系统,新建/home ,恢复/home内容
[root@test1 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 20G 1.5G 19G 8% /
devtmpfs 983M 0 983M 0% /dev
tmpfs 993M 0 993M 0% /dev/shm
tmpfs 993M 8.6M 985M 1% /run
tmpfs 993M 0 993M 0% /sys/fs/cgroup
/dev/sda1 497M 108M 390M 22% /boot
/dev/mapper/centos-home 28G 33M 28G 1% /home
tmpfs 199M 0 199M 0% /run/user/0
[root@test1 ~]# tar cvf /tmp/home.tar /home/
yum install -y psmisc
[root@test1 ~]# fuser -km /home/
[root@test1 ~]# umount /home/
[root@test1 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 20G 1.6G 19G 8% /
devtmpfs 983M 0 983M 0% /dev
tmpfs 993M 0 993M 0% /dev/shm
tmpfs 993M 17M 977M 2% /run
tmpfs 993M 0 993M 0% /sys/fs/cgroup
/dev/sda1 497M 108M 390M 22% /boot
tmpfs 199M 0 199M 0% /run/user/0
[root@test1 ~]# lvremove /dev/mapper/centos-home
Do you really want to remove active logical volume home? [y/n]: y
Logical volume "home" successfully removed
[root@test1 ~]# lvextend -L +10G /dev/mapper/centos-root
Size of logical volume centos/root changed from 20.00 GiB (5120 extents) to 30.00 GiB (7680 extents).
Logical volume root successfully resized.
[root@test1 ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=1310720 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=5242880, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 5242880 to 7864320
##查看root已经加大了10G
[root@test1 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 30G 1.6G 29G 6% /
devtmpfs 983M 0 983M 0% /dev
tmpfs 993M 0 993M 0% /dev/shm
tmpfs 993M 17M 977M 2% /run
tmpfs 993M 0 993M 0% /sys/fs/cgroup
/dev/sda1 497M 108M 390M 22% /boot
tmpfs 199M 0 199M 0% /run/user/0
[root@test1 ~]# lvcreate -L 18G -n /dev/mapper/centos-home
Volume group "centos" has insufficient free space (4482 extents): 4608 required.
##若与到以上问题,磁盘空间不足导致,减小创建的lv即可
[root@test1 ~]# lvcreate -L 17G -n /dev/mapper/centos-home
Logical volume "home" created.
[root@test1 ~]# mkfs.xfs /dev/mapper/centos-home
meta-data=/dev/mapper/centos-home isize=256 agcount=4, agsize=1114112 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=4456448, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@test1 ~]# mount /dev/mapper/centos-home
##查看home
[root@test1 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 30G 1.6G 29G 6% /
devtmpfs 983M 0 983M 0% /dev
tmpfs 993M 0 993M 0% /dev/shm
tmpfs 993M 17M 977M 2% /run
tmpfs 993M 0 993M 0% /sys/fs/cgroup
/dev/sda1 497M 108M 390M 22% /boot
tmpfs 199M 0 199M 0% /run/user/0
/dev/mapper/centos-home 17G 33M 17G 1% /home
tar xvf /tmp/home.tar -C /home/
cd /home/home/
mv * ../