Creating Logical Volume Manager (LVM) in Linux

Creating Logical Volume Manager (LVM) in Linux

by -
0 1638

Creating Logical Volume Manager (LVM) in Linux

Volume management creates a layer of abstraction over physical storage, allowing you to create logical storage volumes. This provides much greater flexibility in a number of ways than using physical storage directly. With a logical volume, you are not restricted to physical disk sizes. In addition, the hardware storage configuration is hidden from the software so it can be resized and moved without stopping applications or unmounting file systems. This can reduce operational costs.

Logical Volume Management (LVM) makes it easier to manage disk space. If a file system needs more space, it can be added to its logical volumes from the free spaces in its volume group and the file system can be re-sized as we wish. If a disk starts to fail, replacement disk can be registered as a physical volume with the volume group and the logical volumes extents can be migrated to the new disk without data loss.

Have a look at flow doagram of lvm and we can say components of lvm.







I think some of above pictures  will create some understanding for lvm. As visualization makes better picture of anything.

In a modern world every Server needs more space day by day for that we need to expand depending on our needs. Logical volumes can be use in RAID, SAN. A Physical Disk will be grouped to create a volume Group. Inside volume group we need to slice the space to create Logical volumes. While using logical volumes we can extend across multiple disks, logical volumes or reduce logical volumes in size with some commands without reformatting and re-partitioning the current disk. Volumes can stripes data across multiple disks this can increase the I/O stats.

My Server Setup – Requirements

My Server Setup – Requirements
  1. Operating System – CentOS 6.5 with LVM Installation
  2. Server IP –

Creating LVM Disk Storage in Linux

1. We’ve used CentOS 6.5 Operating system using LVM in a Virtual Disk (VDA). Here we can see the Physical Volume (PV), Volume Group (VG), Logical Volume (LV) by using following command.

# pvs
# vgs
# lvs


Here, is the description of each parameters shown in above screenshot.

  1. Physical Disk Size (PV Size)
  2. Disk which used was Virtual Disk sdb.
  3. Volume Group Size (VG Size)
  4. Volume Group name (vg1)
  5. Logical Volume name (kvitlvm, lalitlvm)

Friends for any real time environment on servers , it is used in a condition when we need to make up or add more space or reduce some space, which is only effective with this method lvm.So,for practical purpose , we are creating here lvm to make you feel like a real environment.

As i have done this practical on virtula machine on Oracale Virtual Box.You can also practice on virtual machine.

Add virtual harddisk in virtual box

First of look at the snapshots , how to add a virtual harddisk in virtual box.

1. Create a Centos/Rhel based machine on virtual box.


2. Select a machine settings and go to storage section.


3.  Add virtual harddisk of any size as you want, here in this practical i have added 30GB virtual harddisk.


4. Follow the options .


5. Give the name to added hardisk.


These are all the above method to add virtual hard disk on virtual machine .Now we have to move on for further practical.


1. Create 3 partitions of size each 100MB.
2.. Convert them into physical  volumes.
3 Combine physical volumes into volume group.
4. Finally create a logical volume from the volume group.

Step 1

Step1: Now i have taken ssh access to machine ( in my virtual machine, on which i m going to make lvm.

Note:Green color is color which is showing my machine, dont be confused for this.As in all my practicals, you will be shown like this.This is linux mint mahine which i used in my daily use for desktop purpose.



Step 2:Check Added hard disk

Step 2: First of all check the added harddisk by putting command fdisk -l on your terminal.


Here you can see additional harddisk has been added as /dev/sdb and of which i have created three partitions of /dev/sdb1 , /dev/sdb2, /dev/sdb3 of equal 10GB each from /dev/sdb (30GB).

Disk /dev/sdb: 32.6 GB, 32635994112 bytes


Device Boot Start End Blocks Id System

/dev/sdb1 1 1306 10490413+ 83 Linux

/dev/sdb2 1307 2612 10490445 83 Linux

/dev/sdb3 2613 3918 10490445 83 Linux

Step 3: Create 3 partitions .

Step 3: Create 3 partitions , you need to know how to create partitions.

[[email protected] ~]# fdisk /dev/sdb



Keep notice that same process of above are divided into two snapshots.

[[email protected] ~]# partprobe /dev/sdb1 (to make kernel effectice )

Like same as to create for sdb1, sdb2, sdb3.


Step 4: Create Physical Volume

Step 4: Note: If you had installed the server in the minimal mode, the commands pvcreate,   lvcreate, vgcreate etc., couldn’t be found. To use that commands install the lvm2 package first.

[email protected] ~]# yum install lvm2

Step-2. Create Physical Volumes

# pvcreate /dev/sdb1 /dev/sdb2 /dev/sdb3


Physical volume “/dev/sdb1” successfully created

Physical volume “/dev/sdb2” successfully created

Physical volume “/dev/sdb3” successfully created


You can see that Phycal volumes has been created.

pvs is a command which will display you all physical volumes.

[email protected] ~]# pvs

PV VG Fmt Attr PSize PFree

/dev/sdb1 lvm2 — 10.00g 10.00g

/dev/sdb2 lvm2 — 10.00g 10.00g

/dev/sdb3 lvm2 — 10.00g 10.00g




You can use these commands to check physical volumes.

Create Volume Group and Logical Volume

Step-5. Create Volume Groups

[email protected] ~]# vgcreate vg1 /dev/sdb1 /dev/sdb2 /dev/sdb3

Volume group “vg1” successfully created


[[email protected] ~]# vgs

VG #PV #LV #SN Attr VSize VFree

vg1 3 0 0 wz–n- 30.00g 30.00g


[[email protected] ~]# vgscan

Reading all physical volumes. This may take a while.

Found volume group “vg1” using metadata type lvm2 .


Step-6. Create Logical Volume


[[email protected] ~]# lvcreate -L 200M vg1 -n lv1

Logical volume “lv1” created


-L, –size-

Gives the size to allocate for the new logical volume. A size suffix of B for bytes, S for sectors as 512 bytes, K for kilobytes, M for megabytes, G for gigabytes, T for terabytes, P for petabytes or E for exabytes is optional Default unit is megabytes.

-n, –name LogicalVolume

Sets the name for the new logical volume. Without this option a default name of “lvol#” will be generated where # is the LVM internal number of the logical volume.


[[email protected] ~]# lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert

lv1 vg1 -wi-a—– 200.00m


Step-7. Format the logical volume

Step-7. Format the logical volume

# mkfs.ext4 /dev/vg1/lv1

You can check by df -T that which file system your machine is using.




Step 8: Mount the logical volume

# mount /dev/vg1/lv1 /mnt/ ( /mnt- Mount Point )

Then you can check by df -h command to check the mounted lvm on /mnt.


Step 9: Check the mounted directory

Step 9: You can create any file or directory on mounted /mnt directory .


Step 10: For temporary and permanent mounting

ermanent Mounting

It’s now temporarily mounted, for permanent mount we need to add the entry in fstab, for that let us get the mount entry from mtab using

# cat /etc/mtab

We need to make slight changes in fstab entry while entering the mount entry contents copies from mtab, we need to change the rw to defaults

# vim /etc/fstab

Our fstab Entry want to be similar to below sample. Save and exit from fstab using wq!.


Before permanent mounting, umount /mnt.


Keep the entries and save the file.



Then you can check by:

# mount -a ( Whether mounting is correct or not )

# df -h ( will show you mount point )


In my upcoming future articles, I will see how to extend the volume group, logical volumes, reducing logical volume, taking snapshot and restore from snapshot. Till then stay updated to  for more such awesome articles in linux for linux lovers.

For any queries and information , mail us at [email protected] or [email protected]


Download PDF

CEO, KV IT-Solutions Pvt. Ltd. | [email protected] | 9810028374|
Linux Professional and an Industrial Trainer | 20 + years Experience in IT Industry

” We are born free, No Gate and Windows can snatch our freedom “


0 1672

0 1328

0 1188


Leave a Reply