How to Shrink /home and Expand the Root Partition on CentOS 7
This guide walks through diagnosing a mis‑partitioned CentOS 7 log server, installing missing tools, safely unmounting and shrinking the /home XFS filesystem, expanding the root volume, and remounting while emphasizing backup and proper command usage.
Phenomenon
The log server was originally set up with an unreasonable partition layout, leaving the /home directory oversized.
Goal
Reduce the size of the /home partition and extend the root (/) partition to use the freed space.
Step 1 – Identify why /home cannot be unmounted
Attempting umount /home returns “target busy”. The usual way to find the holding process is fuser -m /home, but the fuser command is missing.
# umount /home
umount: /home: target busy.Step 2 – Install the missing utility
On CentOS 7 the fuser command is provided by the psmisc package.
# yum install psmiscStep 3 – Locate and kill the offending process
Run fuser -m /home to list PIDs, then terminate them.
# fuser -m /home // shows PIDs using /home
# kill -9 11757 // stop the processAfter the processes are stopped, unmount the filesystem.
# umount /homeStep 4 – Verify the filesystem type
Check /etc/fstab to confirm that /home uses XFS.
# cat /etc/fstab | grep centos-homeStep 5 – Install XFS tools (if needed)
Resizing an XFS filesystem requires the xfsdump utility.
# yum install xfsdump -yStep 6 – Shrink the /home partition
Resize the logical volume and filesystem to the desired size (e.g., 100 GB).
# resize2fs -p /dev/mapper/centos-home 100GStep 7 – Expand the root partition
After freeing space from /home, extend the root logical volume and resize its filesystem accordingly (commands omitted for brevity).
Step 8 – Remount /home
Attempt to mount the resized /home. If the superblock cannot be read, the partition must be reformatted, so back up all data before proceeding.
# mount /home
mount: /dev/mapper/centos-home: cannot read superblockBackup /home, format if necessary, then mount again.
Important Note
Always back up the contents of /home before shrinking or reformatting the partition.
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.
