LVM (Logical volume manager) configuration in Linux

What Is LVM ?

LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes. With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes. LVM physical volumes can be placed on other block devices which might span two or more disks. The physical volumes are combined into logical volumes, with the exception of the /boot/ partition. The /boot/ partition cannot be on a logical volume group because the boot loader cannot read it. If the root (/) partition is on a logical volume, create a separate /boot/ partition which is not a part of a volume group.

LVM Terms

Physical Volume: A physical volume (PV) is another name for a regular physical disk partition that is used or will be used by LVM. 

Volume Group: Any number of physical volumes (PVs) on different disk drives can be added  together into a volume group (VG).

Logical Volumes: Volume groups must then be subdivided into logical volumes. Each logical volume can be individually formatted as if it were a regular Linux partition. A logical volume is, therefore, like a virtual partition on your virtual disk drive

To Create A LVM-

The first thing you have to do is  Create Partitions using FDISK and set  partition type as LINUX LVM (ID 8e),make sure you have free disk space on your disk to create new partition.

First create a new partition and assign partition ID to 8e for LVM

Create Physical Volumes

Physical  Volumes are the free row disk without any partition. or a existing disk with free space. to create Physical volumes run below command , before creating PV find the device name using fdisk -l or p to print while creating partition. in my case it is /dev/sdb1, you can add multiple disk into PV.

#pvcreate   /dev/sda** /dev/sdb**

Run below command to display 


Create Volume Group

Volume group is group of multiple Physical volume.

 #vgcreate   VG name   /dev/sda**    /dev/adb**

Run Below command to display volume group 


Create Logical Volume

Run Below command to create Logical Volume

#lvcreate     -L   +5G    -n    LV name    VG name

Run Below command to Display Logical Volume, using this command you can find all details like LV name VG name Size and permission


Format the Logical Volume

To use the LV you have to Assign to file system, use below command to format logical volume.

#mkfs.ext4     /dev/VG name/LV name

Mount Logical Volume.

To use Logical Volume you have to mount into directory , you can use mount command to mount and using df-h command you can verify, mount command will mount to temporary, to mount permanently make any entry on fstab file.

Activate the new volume,

To activate and update new changes you can use #mount -a command.


If you want to add new disk and add into existing LV , create PV first using

#pvcreate /dev/device name

Resize the Volume Group 

Once you added new physical volume extend VG into existing VG

#vgextend vgname /dev/PV name 

Resize the LVM

You can increase the size of LV here i have shown 1G added in existing LV

#lvextend    -L    +1G -n /dev/VG name/LV name 

If you want to use remaining all space into LV use below command

#lvresize -l +100%FREE /dev/VGname/LVname

Configuring the HDD for new extended space

#resize2fs  /dev/VG name/LV name

run #xfs_growfs /dev/VG name/LV name if above command give you error 

You can mount the LV and  verify using #df -h

LVM (Logical volume manager) configuration in Linux LVM (Logical volume manager) configuration in Linux Reviewed by Unknown on July 08, 2016 Rating: 5

1 comment:

  1. lvcreate with max size available you can use below command

    lvcreate -n LVNAME -l 100%FREE vgName


Get Your Business Online Now

Powered by Blogger.