How to Safely Remove /home and Expand /root on CentOS with LVM
This guide walks you through backing up the /home partition, editing /etc/fstab to prevent boot errors, uninstalling /home, removing its logical volume, and then extending the /root logical volume and filesystem on a CentOS system using LVM tools such as vgdisplay, lvextend, and xfs_growfs.
Removing /home
Backup /home partition files
# New system ignores
tar cvf /tmp/home.tar /homeBefore uninstalling the /home filesystem, CentOS checks /etc/fstab at boot; because fstab contains a /home entry by default, you must comment it out to avoid boot failure.
Edit /etc/fstab
vim /etc/fstab
# Comment out the /home line
#/dev/mapper/centos-home /home xfs defaults 0 0Install psmisc
yum install -y psmiscThe psmisc package provides utilities for managing the /proc directory, including fuser, killall, pstree, and pstree.x11.
fuser: shows PIDs of processes using a specified file or filesystem.
killall: terminates all processes with a given name.
pstree: displays a tree view of running processes.
pstree.x11: same as pstree but requires confirmation before exiting.
Unmount /home filesystem
umount /homeIf unmount fails because a process is using /home, stop those processes:
fuser -km /home/Remove the /home logical volume
lvremove /dev/mapper/centos-homeExpand root
Extend the LV that holds /root
Use vgdisplay to view free space after removing /home.
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name centos
...
Free PE / Size 61727 / 241.12 GiBFree PE/Size indicates the space that can be added to /root.
lvextend -L +241G /dev/mapper/centos-rootAfter extending, df may still show the old size until the filesystem is grown.
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos-root 52403200 1813004 50590196 4% /
...Extend the /root filesystem
xfs_growfs /dev/mapper/centos-rootCheck root filesystem space
Finally, verify the new size with df -h:
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 291G 1.8G 290G 1% /
...Link: https://www.cnblogs.com/thankcat/p/18018048
(© Original author, all rights reserved)
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
