Hi there, In this article, I’ll explain about LVM(Logical Volume Management) and way to configure them on centOS 8.
The following topics will explain in this article.
- What is LVM?
- Why we need It?
- LVM Structure
- Configure LVM on CentOS 8
4.1. Create Physical Volume
4.2. Create Volume Group
4.3. Create Logical Volume
- Write the File System
- Mount the logical volume
1. What is LVM?
The term LVM stands for Logical Volume Management. Its a system for managing hard drive on Linux systems. This is more efficient than the traditional way of managing hard drives. In the LVM system, we use logical volumes to save data.
2. Why we need It?
LVM is the most efficient way to manage the hard disk. Suppose we have 40GB of HDD and 50GB HDD. We have to save a 70GB single file on our HDD drive. In this case, we can’t use a single drive to save 70GB files. Because we have max 50GB in a single HDD drive. This operation can be achieved only by the LVM system. We can merge that two HDD drives into one logical drive with LVM.
3. LVM Structure
LVM system has a structure. You need to clearly understand this before using LMVs. The following image describes the LVM structure.
The bottom of the image has physical drives. We convert them to physical volumes(PV) and merge into one volume group(VG). After that we divide the volume group(VG) into multiple Logical Volumes(LV). This is the entire process of LVM system.
4. Configure LVM on CentOS 8
Before configuring the LVM system, notice I have added two HDD drives into my CentOS system. One is 5Gb and the other one is 4Gb.
Now I’ll perfome the following steps to create a 9Gb Logical Volume(LV).
4.1. Create Physical Volume(PV).
4.2. Create Volume Group(VG).
4.3. Create a Logical Volume(LV).
4.1. Create Physical Volume(PV)
Physical Volume(PV) is the term in LVM used to describe the physical HDD drives. I have two HDD drives called sdb and sdc. Now I’ll convert them to PVs.
To check the PVs are correctly created by following command.
4.2. Create Volume Group(VG).
After that, we need to create Volume Group(VG). VG is created from merging PVs. Use the following command to create VG called “new_vg”.
vgcreate new_vg /dev/sdb /dev/sdc
To check the VG is correctly created by following command.
4.3. Create a Logical Volume(LV)
After creating VG, now Its possible to create Logical Volumes(LVs) using VG. Use the following command to create 9Gb LV called “My_lv1”.
lvcreate -L 8.99G -n My_lv1 new_vg
To check the LV is correctly created by following command.
5. Write the File System
Now We need to write a file system into our LV before mount it. I use ext4 file system for this LV. Use the following command to write a file system into “My_lv1”.
6. Mount the logical volume
The final step of LVM system is mounting the LV to specific mount point. In this case I’ll make new directory called “LVM” in root directory.
Now, Use the following command to mount the LV called “My_lv1”.
mount /dev/new_vg/My_lv1 /LVM
We can also use following command to check the size the mounted volume.
df -h /LVM
That’s all about LVM system in centOS. Your comments are also welcome! Its very important to improve my blog.