Linux LVM Partition Management: Safely Resize `/home` and Extend Root Filesystem on AlmaLinux and RHEL
Introduction
Linux disk management is one of the most important skills for system administrators and developers.
Many enterprise Linux distributions, including:
- Red Hat Enterprise Linux (RHEL)
- AlmaLinux
- Rocky Linux
- CentOS Stream
One common situation is:
- `/home` has too much unused space
- `/root` is running out of space
- The system partition needs expansion
Instead of reinstalling the operating system, we can safely:
- Backup `/home`
- Remove the old `/home` logical volume
- Expand the root logical volume
- Recreate `/home`
- Restore user data
This article demonstrates the complete process.
Important Warnings Before Operation
Disk operations are powerful but dangerous.
A small mistake can make the system unbootable.
Before executing any command, carefully check the following.
1. Make Sure `/opt` Has Enough Backup Space
Potential Risk
The first step creates a complete `/home` backup:
The backup file is stored under /opt.
However, many Linux installations place /opt inside the root filesystem.
Example:
If / is already almost full, the backup process may fail.
At that point:
/home data is not fully backed up
The migration process becomes dangerous
Check Available Space
Run:
df -h /opt
Make sure:
Available space > current /home usage
Example:
/home used: 60G
/opt available: 120G
This is safe.
2. Never Use a /home User for Remote SSH Operations
Critical Risk
Do not perform this migration while logged in as:
admin
user
developer
if the user's home directory is:
/home/admin
/home/user
Example:
This looks safe, but it is not.
When executing:
fuser -km /home
the system will terminate all processes using /home.
Your SSH session will immediately disappear.
The result can be:
SSH disconnected
Backup unfinished
Old volume removed
New volume not created
The server may become unusable.
Recommended Solutions
Use one of these methods:
Option 1
Enable direct root SSH login temporarily.
Option 2
Use a persistent terminal:
tmux
or:
screen
Run the migration inside that session.
3. Confirm Filesystem Type
This procedure uses:
mkfs.xfs
and:
xfs_growfs
Therefore the filesystem must be XFS.
Check:
df -T /home
Example:
Filesystem Type
/dev/mapper/almalinux-home xfs
Correct.
If you see:
ext4
do not continue.
Ext4 requires different tools.
Check Current Disk Layout
Before changing anything:
df -hT
Also check LVM structure:
lsblk
Example:
Backup and Unmount /home
Create Backup
tar -zcvf /opt/home.tar.gz -C /home .
This creates:
/opt/home.tar.gz
containing all user data.
Stop Processes Using /home
fuser -km /home
Unmount /home
umount /home
Verify:
df -hT
Remove Old Home Logical Volume
Delete the old /home LV:
lvremove /dev/mapper/almalinux-home
Confirm when asked.
Expand Root Logical Volume
Use all remaining free space:
lvextend -l +100%FREE /dev/mapper/almalinux-root
Expand XFS Root Filesystem
xfs_growfs /dev/mapper/almalinux-root
Check:
df -h
The root filesystem should now be larger.
Create New 97GB Home Volume
Create a new /home logical volume:
lvcreate -L 97G -n home almalinux
Format it:
mkfs.xfs /dev/mapper/almalinux-home
Mount:
mount /dev/mapper/almalinux-home /home
Check:
df -h
Restore User Data
Extract backup:
tar -zxvf /opt/home.tar.gz -C /home/
Restore ownership:
chown -R jey:jey /home/jey/
AlmaLinux and RHEL Difference
For RHEL systems:
replace:
almalinux
with:
rhel
Example:
Complete RHEL Example
Final Notes
This method is suitable for:
AlmaLinux
RHEL
Rocky Linux
CentOS Stream
with:
LVM
XFS filesystem
The most important rules:
1.Always backup first
2.Always operate as root
3.Never run from a /home user SSH session
4.Confirm filesystem type before resizing
5.Use tmux or screen for remote servers
With proper preparation, you can resize Linux storage layouts safely without reinstalling the operating system.
Explore More
› Linux Disk Resize Tool: Automated LVM Home Partition Resize and Root Expansion
› My Favorite Linux Distributions: RHEL, AlmaLinux, and Fedora from a Developer's Perspective
› Redis Key Management Explained: Managing Keys, Expiration, and Memory Usage
› PHP-FPM pm.max_requests Explained: Configuration, Memory Management, and Best Practices