1. 备份 /home 目录

[root@centos ~]# cp -r /home /home_backup

2. 查看目前磁盘使用的情况, 需要将 /dev/mapper/centos-home 244G 中大部分空间转移到 /dev/mapper/centos-root

[root@centos nat123]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 50G 13G 38G 25% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 4.0K 1.9G 1% /dev/shm
tmpfs 1.9G 193M 1.7G 11% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 215M 800M 22% /boot
overlay 50G 13G 38G 25% /var/lib/docker/overlay2/264f9446379658fba158fa8c8d6f3e45c7f304d4ccc7fe52c8daf960e88c679d/merged
overlay 50G 13G 38G 25% /var/lib/docker/overlay2/2d60515a51ca0c17176fc57daadd158d2d72627319d936edb78ff634a46586f8/merged
shm 64M 304K 64M 1% /var/lib/docker/containers/b71b26397d3161b6111153b1235fac5cd7b8fd4689d2b42152323581ee841f9c/mounts/shm
shm 64M 0 64M 0% /var/lib/docker/containers/207876d113a78e5774c5f37baa7bd72902dc66421bd4bf613e054690b58cb271/mounts/shm
overlay 50G 13G 38G 25% /var/lib/docker/overlay2/9bc02eae04e25d1df9099a90799cddb0480853a327200aa73cf2b94673e32fb9/merged
shm 64M 0 64M 0% /var/lib/docker/containers/50bd6e7b1a981b9022bdba41c570de5aabe1b711c01a1cf7372f3f60ec3aedc0/mounts/shm
overlay 50G 13G 38G 25% /var/lib/docker/overlay2/afb063ab2596eb30c05e17e82908cbf4a0fc8a871f60019851a608ed95dab0af/merged
overlay 50G 13G 38G 25% /var/lib/docker/overlay2/6d0a46fd532806790f9fe09c2d1f9655fef69766254807393269c5715e01ecde/merged
shm 64M 0 64M 0% /var/lib/docker/containers/ed8b06752134db6c037a00b9bc346336f69fc0fb4763b92018de433cc748c905/mounts/shm
shm 64M 0 64M 0% /var/lib/docker/containers/bb3a31de127a8707b10717ca840c895891fc0248174a01a3555d41a580d0f052/mounts/shm
overlay 50G 13G 38G 25% /var/lib/docker/overlay2/5fecce6d83b0fde7f444ec5f1ac99f2832f827d824a2c0065abc51086c35fb3a/merged
shm 64M 0 64M 0% /var/lib/docker/containers/7769655d4fa38b534ff7a4c0be81bc54e36aac8192d04440081c804b7cb6beae/mounts/shm
tmpfs 380M 0 380M 0% /run/user/0
/dev/mapper/centos-home 244G 100M 243G 1% /home


3. 首先卸载  /home

[root@centos ~]# umount -v /home
umount: /home:目标忙。
(有些情况下通过 lsof(8) 或 fuser(1) 可以
找到有关使用该设备的进程的有用信息)

3.1 先把繁忙中的进程杀死

2.1.1 查看繁忙中的进程
[root@centos ~]# fuser -mv /home
用户 进程号 权限 命令
/home: root kernel mount /home
root 22037 ..c.m mono

3.1.2 kill 22037

[root@centos ~]# kill -9 22037
[root@centos ~]# fuser -mv /home
用户 进程号 权限 命令
/home: root kernel mount /home

4. 确定文件系统类型

[root@centos ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sat Nov 10 15:06:20 2018
#
# 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=39b284f4-969c-44b6-9ac7-9849e37688f9 /boot xfs defaults 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0

 

5. 调整分区

[root@centos ~]# lvremove /dev/mapper/centos-home
Do you really want to remove active logical volume centos/home? [y/n]: y
Logical volume "home" successfully removed

[root@centos ~]# lvcreate centos -L 50G -n home
WARNING: xfs signature detected on /dev/centos/home at offset 0. Wipe it? [y/n]: y
Wiping xfs signature on /dev/centos/home.
Logical volume "home" created.

[root@centos ~]# mkfs.xfs /dev/centos/home
meta-data=/dev/centos/home isize=512 agcount=4, agsize=3276800 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=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 log bsize=4096 blocks=6400, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

 

[root@centos ~]# lvextend -l +100%FREE /dev/mapper/centos-root
Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 243.21 GiB (62262 extents).
Logical volume centos/root successfully resized.


[root@centos ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 50G 13G 38G 25% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 4.0K 1.9G 1% /dev/shm
tmpfs 1.9G 193M 1.7G 11% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 215M 800M 22% /boot
overlay 50G 13G 38G 25% /var/lib/docker/overlay2/264f9446379658fba158fa8c8d6f3e45c7f304d4ccc7fe52c8daf960e88c679d/merged
overlay 50G 13G 38G 25% /var/lib/docker/overlay2/2d60515a51ca0c17176fc57daadd158d2d72627319d936edb78ff634a46586f8/merged
shm 64M 304K 64M 1% /var/lib/docker/containers/b71b26397d3161b6111153b1235fac5cd7b8fd4689d2b42152323581ee841f9c/mounts/shm
shm 64M 0 64M 0% /var/lib/docker/containers/207876d113a78e5774c5f37baa7bd72902dc66421bd4bf613e054690b58cb271/mounts/shm
overlay 50G 13G 38G 25% /var/lib/docker/overlay2/9bc02eae04e25d1df9099a90799cddb0480853a327200aa73cf2b94673e32fb9/merged
shm 64M 0 64M 0% /var/lib/docker/containers/50bd6e7b1a981b9022bdba41c570de5aabe1b711c01a1cf7372f3f60ec3aedc0/mounts/shm
overlay 50G 13G 38G 25% /var/lib/docker/overlay2/afb063ab2596eb30c05e17e82908cbf4a0fc8a871f60019851a608ed95dab0af/merged
overlay 50G 13G 38G 25% /var/lib/docker/overlay2/6d0a46fd532806790f9fe09c2d1f9655fef69766254807393269c5715e01ecde/merged
shm 64M 0 64M 0% /var/lib/docker/containers/ed8b06752134db6c037a00b9bc346336f69fc0fb4763b92018de433cc748c905/mounts/shm
shm 64M 0 64M 0% /var/lib/docker/containers/bb3a31de127a8707b10717ca840c895891fc0248174a01a3555d41a580d0f052/mounts/shm
overlay 50G 13G 38G 25% /var/lib/docker/overlay2/5fecce6d83b0fde7f444ec5f1ac99f2832f827d824a2c0065abc51086c35fb3a/merged
shm 64M 0 64M 0% /var/lib/docker/containers/7769655d4fa38b534ff7a4c0be81bc54e36aac8192d04440081c804b7cb6beae/mounts/shm
tmpfs 380M 0 380M 0% /run/user/0
/dev/mapper/centos-home 50G 33M 50G 1% /home

[root@centos ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks
= sectsz=4096 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=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13107200 to 63756288


[root@centos ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 244G 13G 231G 6% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 4.0K 1.9G 1% /dev/shm
tmpfs 1.9G 193M 1.7G 11% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 215M 800M 22% /boot
overlay 244G 13G 231G 6% /var/lib/docker/overlay2/264f9446379658fba158fa8c8d6f3e45c7f304d4ccc7fe52c8daf960e88c679d/merged
overlay 244G 13G 231G 6% /var/lib/docker/overlay2/2d60515a51ca0c17176fc57daadd158d2d72627319d936edb78ff634a46586f8/merged
shm 64M 304K 64M 1% /var/lib/docker/containers/b71b26397d3161b6111153b1235fac5cd7b8fd4689d2b42152323581ee841f9c/mounts/shm
shm 64M 0 64M 0% /var/lib/docker/containers/207876d113a78e5774c5f37baa7bd72902dc66421bd4bf613e054690b58cb271/mounts/shm
overlay 244G 13G 231G 6% /var/lib/docker/overlay2/9bc02eae04e25d1df9099a90799cddb0480853a327200aa73cf2b94673e32fb9/merged
shm 64M 0 64M 0% /var/lib/docker/containers/50bd6e7b1a981b9022bdba41c570de5aabe1b711c01a1cf7372f3f60ec3aedc0/mounts/shm
overlay 244G 13G 231G 6% /var/lib/docker/overlay2/afb063ab2596eb30c05e17e82908cbf4a0fc8a871f60019851a608ed95dab0af/merged
overlay 244G 13G 231G 6% /var/lib/docker/overlay2/6d0a46fd532806790f9fe09c2d1f9655fef69766254807393269c5715e01ecde/merged
shm 64M 0 64M 0% /var/lib/docker/containers/ed8b06752134db6c037a00b9bc346336f69fc0fb4763b92018de433cc748c905/mounts/shm
shm 64M 0 64M 0% /var/lib/docker/containers/bb3a31de127a8707b10717ca840c895891fc0248174a01a3555d41a580d0f052/mounts/shm
overlay 244G 13G 231G 6% /var/lib/docker/overlay2/5fecce6d83b0fde7f444ec5f1ac99f2832f827d824a2c0065abc51086c35fb3a/merged
shm 64M 0 64M 0% /var/lib/docker/containers/7769655d4fa38b534ff7a4c0be81bc54e36aac8192d04440081c804b7cb6beae/mounts/shm
tmpfs 380M 0 380M 0% /run/user/0
/dev/mapper/centos-home 50G 33M 50G 1% /home

6. 最后回复/home 目录