How to configure LVM in REDHAT 7 & CENTOS 7..

What is LVM..?

Logical volumes and logical volumes management make it easy to manage disk space. If a LVM hosted file system needs more space, it can be allocated to its logical volume from the free space in its volume group and the file system can be resized. If a disk starts to fail, a replacement disk can be registered as physical volume with volume group and the logical volume’s migrated to the new disk.

Different Terms Used in LVM

Physical Devices

Physical devices are the storage devices used to persist data stored on a logical volume. These are block devices and could be disk partitions, whole disk RAID arrays, or SAN disks. A devices must be initialized as a LVM physical volume in order to be used with LVM. The entire “device” will be used as physical volume.

Physical Volume

Physical volumes (PV) are used to register underlying physical devices in volume groups in volume groups. LVM automatically segments PVs in physical extent (PE) these are small chunks of data that act as smallest storage block on a PV.

Volume group

Volume groups are storage pools made up of one or more physical volumes. A PV can only be allocated to a single VG. A VG can consist of unused soace and any number of logical volumes.

Logical Volume

Logical volume (LV ) are created from free physical extent in a volume group and provide the “storage” device used by applications, users, and the operating system. LV are collection of Logical extents(LE), which map to physical extents, the smallest storage chunks of a PV. By default each Logical extent will map to on Physica extent. Setting specific LV option will change this maping, for example mirroring causes each LE map to two PEs.

Read Also: How to install piwik analytics tool on centos?

 Configure lvm in redhat 7 & centos 7

 

Adding Logical volume

Step 1: Create Physical Volume

    1. Now use fdisk to create partition of 1GiB and set there type as Linux LVM.
 # fdisk /dev/sda
    1. Add a new primary partition of 1 GiB.
    1. Change the partition type to Linux LVM -0x8e
    2. Now repeat the previous step to add another partition
    3. Write the changes to the partition table and quit
    4. Use partprobe to register the new partition with the kernel.
 # partprobe

2.0 Create Physical Volumes
Use pvcreate to add the new partitions as physical volumes.

# pvcreate /dev/sda1 /dev/sda2
# pvdisplay

3.0. Create the Volume group
Use vgcreate to create the new VG name Chetan /dev/sda1 /dev/sda2

 # vgdisplay

4.0. Create the Logical Volume

Use lvcreate to create the a 1.5 GiB LV named Kapoor from the Chetan VG

 # lvcreate –n Kapoor –L 1500M Chetan
 # lvdisplay

The above above commands will create device called /dev/Chetan/Kapoor without the file system on it.

5.0. Add a persistent file system

5.1. Use mkfs to place an xfs file system on the Kapoor LV

 # mkfs –t xfs /dev/Chetan/Kapoor

5.2. Use mkdir to make a mount point /volume

# mkdir /volume

5.3 Now make an entry in the fstab file using file editor

 # vim /etc/fstab

/dev/Chetan/Kapoor /volume xfs defaults 1 2

5.4. Use mount command to verify entry in fstab

 # mount -a

5.5 Check our logical volume

 # df -h

Testing Time

Now copy some file to our logical volume

 # cp /home/chetan/* /volume

# ls /volume

If you got some issues using this tutorial please feel free to comment below.

Leave a Reply

Your email address will not be published.


*