As others have pointed out, XFS filesystem cannot be shrunk.

So your best bet is to backup /home, remove and recreate its volume in a smaller size and give the rest to your /root volume just as Koen van der Rijt outlined in his post.


# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   50G  9.1G   41G   19% /
devtmpfs                  63G     0   63G    0% /dev
tmpfs                     63G     0   63G    0% /dev/shm
tmpfs                     63G  9.8M   63G    1% /run
tmpfs                     63G     0   63G    0% /sys/fs/cgroup
/dev/sda2               1014M  239M  776M   24% /boot
/dev/mapper/centos-home  0.3T  147G  0.1T    2% /home
tmpfs                     13G     0   13G    0% /run/user/0


stop services: apache, tomcat, mysql etc. on home

systemctl stop mysql

systemctl stop tomcat


systemctl status mysql

systemctl status tomcat



backup the contents of /home

> tar -czvf /home/home.tgz -C /home .

• test the backup

> tar -tvf /home/home.tgz
copy /home/home.tgz to other PC

• unmount home

> umount /dev/mapper/centos-home

fuser -m -v -i -k /home
yum install psmisc

• remove the home logical volume

> lvremove /dev/mapper/centos-home

  • 扩展/root所在的lv,增加200G : lvextend -L +200G /dev/mapper/centos-root
  • 扩展/root文件系统 : xfs_growfs /dev/mapper/centos-root


重新创建home lv 分区的大小,根据 vgdisplay 中的free PE 的大小确定

lvcreate -L 300G -n home centos

  • 创建文件系统: mkfs.xfs /dev/centos/home
  • 挂载 home: mount /dev/centos/home /home

• restore your backup

> tar -xzvf /root/home.tgz -C /home

• check /etc/fstab for any mapping of /home volume. IF it is using UUID you should update the UUID portion. (Since we created a new volume, UUID has changed)

That's it.

Hope this helps.




posted @ 2018-12-25 08:21  emanlee  阅读(4822)  评论(0编辑  收藏  举报