Resize root partition on an AlmaLinux OS
Resizing Root Partition on AlmaLinux 10 (LVM + XFS)
Since XFS filesystems cannot be shrunk, increasing the root partition requires backing up the /home partition, deleting it, expanding /root, and then recreating /home.
Prerequisites
- A backup location with enough space (e.g.,
/mnt/w). - Root or sudo access.
Step 1: Backup Home Data
Backup all data from /home to a temporary location.
sudo mkdir -p /mnt/w/home_backup
sudo rsync -aHAX --progress /home/ /mnt/w/home_backup/
Step 2: Unmount and Remove the Home Volume
Ensure no processes are using /home, then unmount it and remove the Logical Volume (LV).
sudo fuser -mk /home
sudo umount /home
sudo lvremove /dev/almalinux/home
Step 3: Extend the Root Volume
Extend the root LV by the desired amount (e.g., 100GB) and grow the XFS filesystem.
sudo lvextend -L +100G /dev/almalinux/root
sudo xfs_growfs /
Step 4: Recreate the Home Volume
Create a new LV using the remaining free space and format it with XFS.
sudo lvcreate -l 100%FREE -n home almalinux
sudo mkfs.xfs /dev/almalinux/home
Step 5: Update /etc/fstab
The new volume has a different UUID. You must update /etc/fstab to prevent boot/mount failures.
- Get the new UUID:
lsblk -f /dev/almalinux/home - Edit
/etc/fstab:sudo vi /etc/fstab - Replace the old UUID for
/homewith the new one, or use the device path:/dev/mapper/almalinux-home /home xfs defaults 0 0
Step 6: Mount and Restore Data
Mount the new partition and restore your files.
sudo mount -a
sudo rsync -aHAX --progress /mnt/w/home_backup/ /home/