Linux Server 3d ago 7 views 4 min read

How to configure LVM logical volumes on AlmaLinux 9

Create physical volumes, volume groups, and logical volumes on AlmaLinux 9 to expand storage or separate data partitions.

Roy S
Updated 18h ago
Sponsored

Cloud Hosting — blazing fast websites

Fully managed cloud hosting with free SSL, auto-backups and a friendly cPanel. Built for WordPress, Laravel and custom PHP apps.

This guide walks you through creating physical volumes, volume groups, and logical volumes on AlmaLinux 9. The steps target AlmaLinux 9.0 and later versions using the standard lvm2 package. You will configure storage for new applications or expand existing root partitions.

Prerequisites

  • AlmaLinux 9.0 or later with a fresh installation.
  • Root access or sudo privileges to execute storage commands.
  • At least one unpartitioned disk or partition (e.g., /dev/sdb or /dev/nvme0n1p2).
  • lvm2 package installed (usually pre-installed on AlmaLinux 9).

Step 1: Identify available disk space

Before creating volumes, check existing partitions to ensure you have free space. Use the fdisk or lsblk command to list block devices and partitions. Look for unpartitioned space or empty partitions marked as available.

lsblk -f

You will see a tree view of disks and partitions. Note the device names like /dev/sdb or /dev/nvme0n1p2. If you see a partition with no filesystem type, mark it for use.

NAME   FSTYPE LABEL MOUNTPOINT
sda    ext4  root /
sdb
├─sdb1
├─sdb2
└─sdb3

Step 2: Create a physical volume

Initialize the unpartitioned disk or partition as a physical volume. Run the pvcreate command with the device path. This marks the space for LVM management.

pvcreate /dev/sdb

The command outputs a success message confirming the physical volume is ready. If you have multiple disks, repeat the command for each one.

Physical volume "/dev/sdb" successfully created

Verify the physical volume exists using the pvdisplay command. You should see the device size and UUID listed.

pvdisplay /dev/sdb

Step 3: Create a volume group

Combine one or more physical volumes into a volume group. Use the vgcreate command with a descriptive name and the list of physical volumes. This pool of storage is where logical volumes will be created.

vgcreate vg_data /dev/sdb

The command creates the volume group named vg_data. If you add more physical volumes later, you can extend the volume group using vgeextend.

Volume group "vg_data" successfully created

Check the volume group details with vgdisplay. Confirm the total size and free space available.

vgdisplay vg_data

Step 4: Create a logical volume

Create a logical volume inside the volume group. Use the lvcreate command with the volume group name, desired size, and optional name. For example, create a 50GB logical volume for application data.

lvcreate -L 50G -n lv_app_data vg_data

The command creates a 50GB logical volume named lv_app_data. You can also create multiple volumes with different sizes for different purposes.

Logical volume "lv_app_data" successfully created

Verify the logical volume with lvdisplay. Check the logical volume size, volume group, and mount point.

lvdisplay /dev/vg_data/lv_app_data

Step 5: Format the logical volume

Create a filesystem on the logical volume. Use mkfs.xfs for XFS or mkfs.ext4 for ext4. XFS is the default filesystem on AlmaLinux 9 and handles large files well.

mkfs.xfs /dev/vg_data/lv_app_data

The command formats the logical volume with an XFS filesystem. You will see a progress bar and a message indicating the filesystem is ready.

meta-data=/dev/vg_data/lv_app_data  isize=511    agcount=4, agsize=655360 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1     name=64      lazyit=1
         data   =                       bsize=4096   blocks=3276800, imaxpct=25
         =                       sunit=0       swidth=0 blks
         file-  =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         log   =                       bsize=4096   blocks=25600, version=2, sectsz=512
         log   =                       inodes=512   agcount=1, agsize=25600, iterval=8192
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         name   =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  fsgroup=0
         =                       blocks=0,  fsgroup=0, blocks=0,  f      
Sponsored

Powerful Dedicated Servers — Linux & Windows

Bare-metal performance with SSD storage, DDoS protection and 24/7 expert support. Ideal for production workloads, databases and high-traffic sites.

Tags: LinuxStorageAlmaLinuxSystemd
0
Was this helpful?

Related tutorials

Comments 0

Login to leave a comment.

No comments yet — be the first to share your thoughts.