Implementing LVM Storage Management on CentOS 7

Enviroment Overview

This guide demonstrates configuring Logical Volume Management on a CentOS 7 system with two newly attached storage devices. The setup enables flexible capacity planning and simplifies future storage expansion.

# Display current disk utilization
[root@srv-lvm-01 ~]# lsblk
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda    253:0    0  40G  0 disk 
└─vda1 253:1    0  40G  0 part /
vdb    253:16   0  60G  0 disk 
vdc    253:32   0  60G  0 disk

The system contains a 40GB system disk and two uninitialized 60GB data disks requiring configuration.

LVM Architecture Components

  • Physical Volume (PV): The foundation layer representing raw storage devices or partitions
  • Volume Group (VG): An aggregation pool combining multiple PVs into unified storage capacity
  • Logical Volume (LV): Virtual partitions created from VG space, hosting filesystems
  • Physical Extent (PE): The smallest allocation unit within a PV, consistently sized across a VG
  • Logical Extent (LE): The smallest addressable unit within an LV, mapping directly to PEs

Disk Partitioning

Initialize each data disk with a single LVM partition:

Configure /dev/vdb

[root@srv-lvm-01 ~]# parted -s /dev/vdb mklabel msdos
[root@srv-lvm-01 ~]# parted -s /dev/vdb mkpart primary 1MiB 100%
[root@srv-lvm-01 ~]# parted -s /dev/vdb set 1 lvm on

Configure /dev/vdc

[root@srv-lvm-01 ~]# parted -s /dev/vdc mklabel msdos
[root@srv-lvm-01 ~]# parted -s /dev/vdc mkpart primary 1MiB 100%
[root@srv-lvm-01 ~]# parted -s /dev/vdc set 1 lvm on

Verify Partition Layout

[root@srv-lvm-01 ~]# lsblk
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda    253:0    0  40G  0 disk 
└─vda1 253:1    0  40G  0 part /
vdb    253:16   0  60G  0 disk 
└─vdb1 253:17   0  60G  0 part 
vdc    253:32   0  60G  0 disk 
└─vdc1 253:33   0  60G  0 part

Physical Volume Initialization

Install LVM utilities if not present:

[root@srv-lvm-01 ~]# yum install -y lvm2

Create PVs on the new partitions:

[root@srv-lvm-01 ~]# pvcreate /dev/vdb1 /dev/vdc1
  Physical volume "/dev/vdb1" successfully created
  Physical volume "/dev/vdc1" successfully created

Inspect PV status:

[root@srv-lvm-01 ~]# pvscan
  PV /dev/vdb1                      lvm2 [60.00 GiB]
  PV /dev/vdc1                      lvm2 [60.00 GiB]
  Total: 2 [120.00 GiB] / in use: 0 [0   ] / in no VG: 2 [120.00 GiB]

Volume Group Assembly

Establish a volume group named vgdatastore:

[root@srv-lvm-01 ~]# vgcreate vgdatastore /dev/vdb1 /dev/vdc1
  Volume group "vgdatastore" successfully created

Review VG configuration:

[root@srv-lvm-01 ~]# vgdisplay vgdatastore
  --- Volume group ---
  VG Name               vgdatastore
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               119.99 GiB
  PE Size               4.00 MiB
  Total PE              30718
  Alloc PE / Size       0 / 0   
  Free  PE / Size       30718 / 119.99 GiB

Logical Volume Provisioning

Create three LVs with different purposes:

# Application storage (40GB)
[root@srv-lvm-01 ~]# lvcreate -n lv_apps -L 40G vgdatastore
  Logical volume "lv_apps" created

# Log archive (30GB)
[root@srv-lvm-01 ~]# lvcreate -n lv_logs -L 30G vgdatastore
  Logical volume "lv_logs" created

# Backup storage (remaining space)
[root@srv-lvm-01 ~]# lvcreate -n lv_backup -l 100%FREE vgdatastore
  Logical volume "lv_backup" created

Verify LV allocation:

[root@srv-lvm-01 ~]# lvs
  LV        VG           Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_apps   vgdatastore  -wi-a-----  40.00g                                                    
  lv_backup vgdatastore  -wi-a-----  49.99g                                                    
  lv_logs   vgdatastore  -wi-a-----  30.00g

Filesystem Creation

Format LVs with XFS filesystem:

[root@srv-lvm-01 ~]# mkfs.xfs /dev/vgdatastore/lv_apps
[root@srv-lvm-01 ~]# mkfs.xfs /dev/vgdatastore/lv_logs
[root@srv-lvm-01 ~]# mkfs.xfs /dev/vgdatastore/lv_backup

Mountpoint Configuration

Establish mount directories and activate filesystems:

[root@srv-lvm-01 ~]# mkdir -p /opt/apps /var/logs/archive /backup
[root@srv-lvm-01 ~]# mount /dev/vgdatastore/lv_apps /opt/apps
[root@srv-lvm-01 ~]# mount /dev/vgdatastore/lv_logs /var/logs/archive
[root@srv-lvm-01 ~]# mount /dev/vgdatastore/lv_backup /backup

Validate mounted filesystems:

[root@srv-lvm-01 ~]# df -hT
Filesystem                         Type      Size  Used Avail Use% Mounted on
/dev/vda1                          ext4       40G  1.5G   36G   4% /
devtmpfs                           devtmpfs  7.8G     0  7.8G   0% /dev
tmpfs                              tmpfs     7.8G     0  7.8G   0% /dev/shm
/dev/mapper/vgdatastore-lv_apps    xfs        40G   33M   40G   1% /opt/apps
/dev/mapper/vgdatastore-lv_logs    xfs        30G   33M   30G   1% /var/logs/archive
/dev/mapper/vgdatastore-lv_backup  xfs        50G   33M   50G   1% /backup

Persistent Mount Configuration

Add entries to /etc/fstab for automatic mounting:

[root@srv-lvm-01 ~]# echo "/dev/mapper/vgdatastore-lv_apps   /opt/apps          xfs   defaults   0 0" >> /etc/fstab
[root@srv-lvm-01 ~]# echo "/dev/mapper/vgdatastore-lv_logs   /var/logs/archive  xfs   defaults   0 0" >> /etc/fstab
[root@srv-lvm-01 ~]# echo "/dev/mapper/vgdatastore-lv_backup /backup            xfs   defaults   0 0" >> /etc/fstab

Test fstab configuration:

[root@srv-lvm-01 ~]# mount -a
[root@srv-lvm-01 ~]# echo $?
0

Storage Expansion Procedures

Scenario 1: Extending With in Available VG Space

# Expand lv_apps by 10GB
[root@srv-lvm-01 ~]# lvextend -L +10G /dev/vgdatastore/lv_apps
[root@srv-lvm-01 ~]# xfs_growfs /opt/apps

Scenario 2: Adding New Physical Storage

When VG capacity is exhausted, integrate a new disk:

# Partition new disk /dev/vdd
[root@srv-lvm-01 ~]# parted -s /dev/vdd mklabel msdos
[root@srv-lvm-01 ~]# parted -s /dev/vdd mkpart primary 1MiB 100%
[root@srv-lvm-01 ~]# parted -s /dev/vdd set 1 lvm on

# Create PV and extend VG
[root@srv-lvm-01 ~]# pvcreate /dev/vdd1
[root@srv-lvm-01 ~]# vgextend vgdatastore /dev/vdd1

# Expand logical volume
[root@srv-lvm-01 ~]# lvextend -l +100%FREE /dev/vgdatastore/lv_backup
[root@srv-lvm-01 ~]# xfs_growfs /backup

For ext4 filesystems, substitute xfs_growfs with resize2fs:

[root@srv-lvm-01 ~]# resize2fs /dev/vgdatastore/lv_apps

Tags: LVM CentOS 7 fdisk pvcreate vgcreate

Posted on Tue, 18 Aug 2026 16:48:06 +0000 by eatadi