How to Shrink /home and Expand Root on CentOS 7
This guide walks through diagnosing a busy /home mount, installing missing tools, safely unmounting, resizing the home partition, installing XFS utilities, and finally expanding the root filesystem on a CentOS 7 server.
The original log server had an ill‑designed partition layout: a large /home volume and an undersized root ( /) partition. The goal is to shrink /home to free space and then enlarge the root filesystem.
1. Diagnose the busy /home mount
Attempting to unmount fails:
umount /home
# umount: /home: target is busy.Normally fuser -m /home or lsof would reveal the holding processes, but the fuser command is missing.
2. Install the missing utility
yum install psmiscAfter installation, run: fuser -m /home # shows PIDs using /home Identify the offending PID (e.g., 11757) and terminate it: kill -9 11757 Now the mount can be released:
umount /home3. Resize the /home partition
If the filesystem is ext4, use resize2fs: resize2fs -p /dev/mapper/centos-home 100G First confirm the filesystem type: cat /etc/fstab | grep centos-home When the entry shows xfs, install the XFS dump tool before resizing: yum install xfsdump -y After the appropriate tool is present, shrink the home volume to the desired size (e.g., 100 GB).
4. Expand the root ( / ) partition
With free space reclaimed from /home, extend the logical volume that backs the root filesystem and then grow the filesystem accordingly. (The original article includes screenshots of the LVM commands and the resulting size increase.)
5. Remount /home
Attempting to mount the resized home fails with a superblock error, indicating the filesystem must be recreated:
mount /home
# mount: /dev/mapper/centos-home: cannot read superblockTherefore, before shrinking /home, back up its data, format the partition anew, and restore the data after the resize.
The article provides a series of screenshots illustrating each command and the resulting partition layout.
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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
