Linux Disk Extend

AlmaLinux extend disk LVM step-by-step guide

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.

Warning: A wrong disk or partition name can cause data loss. Always double-check device names and, if possible, test the procedure on a non-production system first.

Table of Contents

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.
Tip: Take a recent backup or snapshot before modifying partitions, LVM, or filesystems.

Step 1 – Check current disk usage

Start by checking the current filesystem layout and usage:

df -khT

This shows the mounted filesystems, their types, and how much space is used on each.

AlmaLinux df output showing current disk usage before LVM extend

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.

Selecting the empty disk to create a new LVM partition

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.

Setting partition type to 8e Linux LVM in AlmaLinux

Write the changes and exit the partitioning tool.

Then ask the kernel to re-read the new partition table:

partprobe
Note: On busy systems you may need a short maintenance window if the disk is in heavy use, but in most cases partprobe 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/sda3

You can list all physical volumes to confirm:

pvdisplay

pvdisplay output showing the new LVM physical volume on AlmaLinux

Step 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/sda3

After 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%FREE uses all free space in the Volume Group.
  • You can also specify a fixed size (for example, -L +50G).
Tip: If you host multiple filesystems in the same VG, consider leaving some free space for future growth or snapshots.

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-root

If the filesystem is Ext4:

resize2fs /dev/mapper/almalinux-root
Warning: Always confirm the correct device and filesystem type with lsblk -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 -khT

The size of / (or whichever mount point you extended) should now reflect the new total capacity.

Note: These steps cover the general approach to expanding an LVM-managed disk on AlmaLinux. Details may differ slightly depending on your storage layout, hypervisor, or disk setup.

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.

You May Also Like