Technology

WHAT DO WE UNDERSTAND BY LOGICAL VOLUME MANAGEMENT?

Basically, Logical Volume Management (LVM) introduces an extra layer between the physical disk and the file system, it can create “virtual” disk partitions out of one or more physical hard drives. It also allows you to create larger partitions, then you could achieve with a single drive allowing the file system to be –

  • Resized and moved easily and online without requiring a system-wide outage.
  • Using discontinuous space on disk.
  • Meaningful name to volumes.
  • Span multiple physical disks.

Concept
LVM is few conceptual layers such as Physical volume, Logical volume, and file system. The picture below shows the structure of LVM. LVM consists of Physical Volumes, Volumes Groups, Logical Volumes, and finally file systems. The physical partitions are known as Physical Extents (PE), and the logical partitions are known as logical Extents (LE).

The conceptual layers are in turn made up of smaller units like Physical extents (in case of Physical volume) and logical extents (in case of logical volumes).

Components of LVM in Linux

– Physical Volumes (PV)
– Physical Extents (PE)
– Volume Group (VG)
– Logical Extents (LE)

Physical Volume

It is the standard partitions that you add to the LVM. Normally, a physical volume is a standard primary or logical partition with the hex code 8e.

Physical Extents

It is a chunk of disk space. Every PV is divided into several equal-sized PEs.

Volume Group (VG)

It is composed of a group of PVs and LVs. It is the organizations’ group for LVM.

Logical Volume (LV)

It is composed of a group of Les. You can format and mount any file system on an LV. The size of these LV’s can easily be increased or decreased as per the requirement.

Logical Extents

It is also a chunk of disk space. Every LE is mapped to a specific PE.

Some Commands Related to LVM

Lab Work

Verify your all disks with the Commandlsblk

In our case, we have five disks, but we work on only four– sdb, sdc, sdd.

The second thing we check disks that are not mounted anywhere. Using Command df  -h, you check this.

If all disks are free, then good to go configure Logical volume

Step 1

“Create PV (Physical Volume)”

Select disk whenever you use logical partitions.

Here, we have used three disks (sdb, sdc, and, sdd). all these disks are not mounted and not used anywhere. So, I create Physical Volume using Commandpvcreate /dev/sdb /dev/sdc /dev/sdd

verify pv(physical volume) create or not using command – pvs


Step 2

VG(Volume Group) create

VG ‘volume group’ means like a pool out of which we create LV. Using some simple commands, we create vg (volume group). Commandvgcreate vg_name /dev/sdb /dev/sdc /dev/sdd

Here, we create a volume group like a vg pool.

Now we required a 5GB disk. Here, we make a 5GB disk using vg group

verify vg(volume group) create or not using Commandvgs


Step 3

LV (logical volume) create

In the third step, we create a 5GB disk using Commandlvcreate -L +5G -n first_lv first_vg


Step 4

File system write on lv_disk

After creating logical volume (LV) we write a file system on LV partitions. Type on file system – mkfs, mkfs.ext4, mkfs.ext2, mkfs.minix, mkfs.fst, etc. Commandmkfs.ext4  /dev/first_vg/first_lv


Step 5

Disk (5GB) mount on an empty directory
After write filesystem on disk then mount disk on a directory
Create a directory using mkdir disk5GB (Directory name)

Disk mount on directory (disk5GB)

After all successful tasks, we mount our 5GB disk on disk5GB directory using Command – mount  /dev/mapper/first_vg-first_lv  /disk5GB


Verify

Commandlsblk

We have successfully created LVM partitions.

Verify for Mount Point

Now, our disk is mounted on directory disk5GB.

Here we have seen how to setup flexible storage with logical volumes by using physical disk to physical volume, physical volume to volume group. Volume group to logical volumes. These features are very useful to our day-to-day working so if our concepts are clear then we easily create a logical volume and modify it and if in any change requirement we solved it.

Zindagi Technologies have been a helping hand and fulfilling technology business requirements for those who need planning, designing, and deployment of the resources that we provide. We are an IT company that is dynamically growing and providing professional services that will transform the business of our clients. We only strive for the best and to get in touch with us, you can give us a call at +919773973971.

Author
Deepak Kumar
Linux and Server Administrator


Author

Team ZT