How to Shrink /home and Expand the Root Partition on CentOS 7
This guide explains how to safely reduce the /home partition size, free up space, and extend the root filesystem on a CentOS 7 server by unmounting /home, locating and terminating lingering processes, resizing the filesystem, installing required tools, and remounting the adjusted partitions.
Background
The original log server was set up with an improperly sized partition layout, leaving the /home filesystem consuming excessive space while the root partition ( /) lacked room for growth.
Goal
Reduce the /home partition to about 100 GB.
Expand the root filesystem to use the freed space.
Unmount /home safely, handling the "target busy" error.
Step 1 – Identify and Stop Processes Using /home
Attempting to unmount /home yields:
# umount /home
umount: /home:目标忙。Use fuser (or lsof) to locate the processes. On a minimal CentOS 7 installation the fuser command may be missing, so install it first: # yum install psmisc -y After installation, run: # fuser -m /home Kill the listed processes (example PID 11757): # kill -9 11757 Now the filesystem can be unmounted:
# umount /homeStep 2 – Resize the /home Filesystem
Assuming /home is an ext4 logical volume, shrink it with: # resize2fs -p /dev/mapper/centos-home 100G Verify the filesystem type; if it is XFS, the approach differs (XFS cannot be shrunk directly). Check the /etc/fstab entry:
# cat /etc/fstab | grep centos-homeStep 3 – Prepare for XFS Expansion (if applicable)
If the partition uses XFS, install the xfsdump utility, which is required for certain XFS operations:
# yum install xfsdump -yStep 4 – Re‑mount and Verify
After shrinking, attempt to mount /home again:
# mount /home
mount: /dev/mapper/centos-home:不能读超级块The error indicates the filesystem needs to be recreated; therefore, back up any data from /home before proceeding.
Once the backup is complete, format and mount the resized partition:
# mkfs.xfs /dev/mapper/centos-home
# mount /homeResult
The /home partition is now limited to 100 GB, freeing space for the root filesystem to be expanded. Remember to always back up critical data before resizing or reformatting partitions.
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.
