Operations 5 min read

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.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Safely Remove /home and Expand /root on CentOS with LVM

Removing /home

Backup /home partition files

# New system ignores
tar cvf /tmp/home.tar /home

Before 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 0

Install psmisc

yum install -y psmisc

The 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 /home

If unmount fails because a process is using /home, stop those processes:

fuser -km /home/

Remove the /home logical volume

lvremove /dev/mapper/centos-home

Expand 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 GiB

Free PE/Size indicates the space that can be added to /root.

lvextend -L +241G /dev/mapper/centos-root

After 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-root

Check 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)

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxLVMFilesystemCentOSHome UnmountRoot Expansion
MaGe Linux Operations
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.