Creating LVM volumes in RHEL 8.

Abhishek Sahu
4 min readJan 1, 2021

Hello Readers, In today’s blog I am going to show you how you can create LVM volumes.

Src: Bing search

Software require:-

  1. Virtualization software eg. Oracle Virtual box, VMware, HyperV etc.
  2. RedHat 8 VMs.
  3. Root or Sudo privilege.

So let’s start with the practical part of our blog:

What is LVM?

LVM or Logical Management Volume is a disk management tool or concept used in Linux which helps us in increasing or decreasing the size of Linux partition without unmounting the partition.

Now Let us start creating our LVM volume first.

To create a LVM first launched a VM and attach a physical hard drive to it or use a virtual hard disk with the help of virtualization software.

Here I am using Virtual Machine of RedHat 8. Now I am adding a newa hard disk of 16 GB named as ansible_1.

Now after login run “df -h” command to see mounted storage on the system.

Here you can see that no ansible_1 drive is mounted. Now run “fdisk -l” command to see connected devices.

Here you can see that we have two devices of 16 GB each in which one is mounted and partitioned which is our previous drive /dev/sda and we have one new device /dev/sdb which is a new device connected to our instance.

Now Let’s create our LVM partition from this drive….

To create a LVM we first need to create PV (Physical Volume) then VG (Volume Group) and then LV (Logical Volume). But before all this we have to partitioned our newly attached hard drive.

So, I am assuming that you guys already know partitioning. If you don’t know partitioning you can directly use hard drives as a PV.

Now I’ve created three partition from that drive named as sdb1, sdb2, and sdb3.

Now its time to create Physical Volume. Use command “pvcreate drivename” to create a physical volume. You can also use “pvs” command to display all the PV present in the system.

Now After Creating PV its time to create VG from that previously created PV. To create VG used the following command:

vgcreate vgname ‘LVs you want to attach’

Now our vg has been create successfully, you can check VG with the help of ‘vgs’ command. Or use “vgdisplay vgname” to display all the information about a VG.

Now we have been successfully created our VG, its time to create a LV and use it.

To create a LV we will use lvcreate command.

Use command “lvcreate -n name_for_lv -L size vgname” to create a new LV and command “lvs” to display all the LV in system and “lvdisplay lvname” to display all information about a LV.

After Creating a LV its time to use it. And as we know for using any volume we first have to format and mount it.

Now our new LV has been created and mounted successfully. we can check the same by using “df -h” command.

Here u can see that our new folder is mounted with our new LV.

Now lets try extending the size of this newly mounted folder.

We can extend the LV with command “ lvextend -L +size LV_path

But still when you guys are running df -h command you are seeing the previous volume. This shows that the our new LV size is increased but it is not in affect. To let it in affect we first have to resize our LV. we can use “resize2fs drvename” command to resize our LV without unmounting it.

Now you can see that size of our linux partition is increased without unmounting it.

This is how we can create LVM partitions in Linux.

I would like to thank Vimal Sir and entire ARTH team for asking me to perform this task.

--

--

Abhishek Sahu

Hey Readers, I am tech enthusiast and an Computer Science Student. Here I am sharing various industry use cases and its solution.