Extending an LVM Disk on AlmaLinux (Step-by-Step Guide)
When a server starts to run out of disk space, you don’t always need to reinstall or migrate. If your AlmaLinux system uses LVM (Logical Volume Manager), you can usually extend the existing disk and grow the filesystem online with minimal downtime.
Table of Contents
- Prerequisites
- Step 1 – Check current disk usage
- Step 2 – Detect and prepare the new disk
- Step 3 – Create the new Physical Volume (PV)
- Step 4 – Extend the Volume Group (VG)
- Step 5 – Extend the Logical Volume (LV)
- Step 6 – Grow the filesystem (XFS or Ext4)
- Step 7 – Verify the extended disk
- Frequently Asked Questions
Prerequisites
- AlmaLinux server using LVM for the filesystem you want to extend (for example,
/dev/mapper/almalinux-root). - Additional disk space attached from your hypervisor or provider.
- Root or sudo access to the server.
Step 1 – Check current disk usage
Start by checking the current filesystem layout and usage:
df -khTThis shows the mounted filesystems, their types, and how much space is used on each.
Step 2 – Detect and prepare the new disk
After your provider adds a new virtual disk (or enlarges an existing one), make sure the OS can see it. Tools like lsblk, fdisk -l, or cfdisk are useful here.
Create a new partition on the free disk space and mark it as an LVM partition:
- Select the empty disk and create a New partition.
- Set the Type to 8e Linux LVM.
Write the changes and exit the partitioning tool.
Then ask the kernel to re-read the new partition table:
partprobepartprobe is safe to run online.Step 3 – Create the new Physical Volume (PV)
Assuming the new partition is /dev/sda3, initialize it as an LVM Physical Volume:
pvcreate /dev/sda3You can list all physical volumes to confirm:
pvdisplayStep 4 – Extend the Volume Group (VG)
Next, add the new PV to your existing Volume Group. In this example the VG name is almalinux:
vgextend almalinux /dev/sda3After this step, the free space of /dev/sda3 becomes available to any Logical Volume inside the almalinux VG.
Step 5 – Extend the Logical Volume (LV)
To extend the root filesystem, extend the corresponding Logical Volume. For a typical AlmaLinux installation, this is /dev/mapper/almalinux-root:
lvextend -l +100%FREE /dev/mapper/almalinux-root-l +100%FREEuses all free space in the Volume Group.- You can also specify a fixed size (for example,
-L +50G).
Step 6 – Grow the filesystem (XFS or Ext4)
Extending the LV only changes the block device size. You still need to grow the filesystem itself. Use the command that matches your filesystem type.
If the filesystem is XFS:
xfs_growfs /dev/mapper/almalinux-rootIf the filesystem is Ext4:
resize2fs /dev/mapper/almalinux-rootlsblk -f or df -T before running grow/resize commands.Step 7 – Verify the extended disk
Finally, verify that the filesystem has been extended correctly:
df -khTThe size of / (or whichever mount point you extended) should now reflect the new total capacity.
Frequently Asked Questions
Do I need to reboot after extending an LVM disk?
In most cases, no reboot is required. As long as the kernel can see the new partition (after partprobe) and you grow the LV and filesystem correctly, the change is applied online.
Can I extend the root filesystem while the server is running?
Yes, extending the root filesystem is usually safe on a running system when using LVM, especially with XFS. However, you should schedule the operation during a maintenance window and have recent backups.
How do I know whether I should use xfs_growfs or resize2fs?
Check the filesystem type with df -T or lsblk -f. If the type is xfs, use xfs_growfs. If it is ext4, use resize2fs.
What happens if I choose the wrong disk or partition?
Using the wrong device in pvcreate, lvextend, or filesystem commands can destroy existing data. Always verify device names carefully before executing any command.
Can I shrink an LVM filesystem instead of extending it?
Shrinking is much riskier than extending and is not supported for XFS. If you must reduce size, plan a backup and restore or rebuild the layout instead.









