System ProgrammingLearn how to Use Logical Volume Manager in Red Hat Linux

Learn how to Use Logical Volume Manager in Red Hat Linux

In the previous two articles, we have discussed the Basic Partitions. In this article, we will introduce another important concept: LVM. So, bring your coffee, and bear with me with your full attention.

Logical Volume Manager
The Logical Volume Manager LVM acts as a layer between physical and logical storage. LVM is meant to address the disadvantages of basic partitions. Although configuring basic partitions is an easy process, it has many limitations:

    • A small file system couldn’t be extended.
    • An over-sized file system couldn’t be shrunk.
    • The largest partition (and hence file system) that could be created in your system can not exceed the size of the largest disk installed. This is simply because a basic partition couldn’t span across different disks.

On the other hand, LVM offers the following benefits:

  • Flexibility: a file system could be easily extended or shrunk on need.
  • Larger file systems: LVM allows much more file system sizes than basic partitions.
  • Snapshot backups: LVM gives you the capability to take a snapshot backup for a file system at a specific point in time.
  • Data mirroring: LVM allows mirroring of data for higher availability.

LVM Structure
The LVM consists of the following components:

  1. Physical Volumes: these are the “real” disk devices. They could be internal, like IDE, SATA, and SCSI, or external like iSCSI and SAN storage disks.
  2. Volume Group: a physical volume group (or just volume group for short) is a group of physical disks that are combined together into a larger entity that has a name. You can think of it like a logical disk whose size is the total of multiple underlying physical disk devices.
  3. Logical Volume: the logical volume is the top of the LVM pyramid. A volume group could be divided into one or more logical volumes, on top of which file systems are built.

Physical Partitions versus Logical Partitions
Two common terms that you will hear frequently when working with LVM are Physical Partition PP, and Logical Partition LP. You should know the meaning and use of each.

To use a physical disk in an LVM structure, it should be configured as an LVM physical volume. This operation includes dividing the physical disk into small, equal-size units called physical partitions or physical extents PE.

A logical partition (extent) is the smallest unit that could be allocated to a logical volume. So, a logical volume is allocated a number of logical extents. Each logical extent is mapped to a corresponding underlying physical extent of the same size.

Implementing LVM
As in basic partitions, LVM can be implemented both using CLI and using the GUI tool. We will learn how to do it in both ways.

LVM Using the Command Line
There is a rich set of commands that handle the LVM administration tasks. In this section, we are going to discuss a full scenario starting with a raw new empty disk, till the creation and mounting of file system.

Given that you have two new disks of sizes 4 GB and 6 GB, we need to create a new file system /sales_data with  8 GB size.
To achieve these requirements, we will go through the following procedure:

    1. Configure the two disks as physical volumes. This is done using the pvcreate command.


    1. Display the existing physical volumes to check the result of the last step. Two commands could be used: pvs and pvdisplay.

pvdisplay gives more detailed info:

    1. Now, the newly-created physical volumes could be used to create a volume group. To create a new volume group, use the vgcreate command.



Where:   VOLUMEGROUPNAME is the name of the volume group we want to create. Of course, it must be unique on a Linux box.
PHYSICALVOLPATH is the full path of the device file representing a physical volume. When creating a volume group, at least one physical volume needs to be specified.

  1. To display the new volume group, two commands also exist: vgs and vgdisplay.

pvs lists the existing volume groups, with short summary for each, including info like:

    • Volume group name.
    • Number of physical volumes in the group.
    • Number of logical volumes created in this group.
    • The total space size of this volume group.
    • The free (not yet allocated) space available in the volume group.

pvdisplay gives more detailed output:
We could see information like: the physical extent PE size, the total number of PEs, number of allocated (used) PEs, and the number of free PEs.

  • Now, we have a pool of disk space that is available for allocation to new logical volumes. This step and the remaining steps in the procedure will be continued in the next article.

In this article, we had an introduction to LVM.

  • Logical Volume Manager LVM solves the problems we faced when working with basic partitions, like file system resizing, support for larger file systems, and etc.
  • LVM consists of three main components: Physical Volume PV, Volume Group VG, and Logical Volume
  • LVM administration could be done either using CLI or GUI tool.
  • The pvcreate command is used to initialize a disk or partition for use by LVM.
  • The vgcreate command is used to create a new volume group using one or more physical volume.

See you in the next article to continue our discussion on LVM.


Please enter your comment!
Please enter your name here

Exclusive content

- Advertisement -Newspaper WordPress Theme

Latest article


More article

- Advertisement -Newspaper WordPress Theme