How to create LVM with four disks on CentOS 7 linux

In this article we will show you how to create LVM with four disks on CentOS 7 linux.
As you may know, LVM is like “dynamic partitions”, meaning that you can create/resize/delete LVM “partitions” (they’re called “Logical Volumes” in LVM-speak) from the command line while your Linux system is running: no need to reboot the system to make the kernel aware of the newly-created or resized partitions.

Our environment

OS: CentOS 7
No. of Disks: 4 disks with 500 GB each one

lvm concept

1- Partition drives

here we partition each hard drive into 1:

# parted /dev/sdb mklabel msdos
# parted /dev/sdb mkpart primary 1 100%
# parted /dev/sdc mklabel msdos 
# parted /dev/sdc mkpart primary 1 100%
# parted /dev/sdd mklabel msdos 
# parted /dev/sdd mkpart primary 1 100%
# parted /dev/sde mklabel msdos 
# parted /dev/sde mkpart primary 1 100%

LVM has three primary parts. Each part plays an important role in creating and maintaining logical volumes:

Physical Volume (PV): A physical volume (PV) is created using the LVM’s /sbin/pvcreate command. This utility designates an unused disk partition (or whole drive) to be used by LVM. The LVM structures, a volume label, and metadata are added to the partition during this process.

Volume Group (VG): A volume group (VG) is created using the LVM’s /sbin/vgcreate command, which adds PVs to a storage pool. This storage pool is used in turn to build various logical volumes.

Logical Volume (LV): A logical volume (LV) is created using the LVM’s /sbin/lvcreate command. This is the final object in logical volume creation. A LV consists of storage space chunks (logical extents) from a VG pool. It can be formatted with a filesystem, mounted, and used just like a typical disk partition.

2- Create PV

create pv for lvm:

# pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1

3- Create VG

create vg from created PVs:

# vgcreate vg00 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1

4- Create LV

create lv from created vg. in our case, vg size is 1.82TiB:

# lvcreate -l 100%FREE vg00

5- Make filesystem and mount

make filesystem on create lvm:

# mkfs -t xfs /dev/vg00/lvol0

edit fstab file and add entry to mount /var directory on created lvm:

# /dev/vg00/lvol0 /var    xfs defaults 0 0

One practical usage of lvm is that you have a hosting server and have decided to separate /var or /home from your main root tree to prevent OS get stuck with fulling space. we have an article on How to move var to new partition on CentOS 7 linux.