Day 7: Logical Volume Group:

Vandana PanditVandana Pandit
2 min read

Today we will what is LVM -Logical Volume Manager and

LVM allows grouping of multiple physical volume which are disk/partition into volume group. From this volume group you can carve out logical volumes.

LVM allows logical volume to be resized dynamically as long as there is sufficient space in volume group.

Steps to create and resize LVM

In order to make use of LVM you need to first install lvm2 like this:

Lets do lsblk and check the disk and partition this system has

We are going to make use of /dev/xvdb2 partition for creating physical group

We are going to make use of /dev/xvdb2 partition for creating physical group

Make use pvcreate command to create Physical Volume like this

Now that the physical volume is create we need to create a volume group, but before that let's see how to display the created physical volume.

To create volume group we will make use of vg command followed by the name of volume group in this case it is "vandana_vg" followed by the created physical volume which is /dev/xvdb2.

To display volume group make use of vgdisplay or vgs command

To create Logical volume we will make us of lvcreate command followed by the Linear type '-L' then specify the size and then mention the name for your logical volume 'vol1' followed by the volume group name 'vandana_vg'.

To display created volume group make use of lvdisplay command or lvs command like the way shown in the screenshot.

Once the logical volume is created now let's create filesystem ext4 on the logical volume vol1

To check if the filesystem is created on logical volume vol1 fire blkid command

Create a directory /mnt/vol1 to mount the filesystem on it.

Lets see if the logical volume is mounted on /mnt/vol1

From the previous screenshot we can see that there is 568M free space available in volume group . Let's expand the logical volume with 200M extra to the existing size of the logical volume using lvresize command:

Now that logical volume is resized we need to also resize the filesystem created on it.

Running the df command now shows that the logical volume has been in created from 200M to 400M

Note:

/dev/mapper/vandana-vg-vol1 is same as /dev/vandana-vg/vol1

0
Subscribe to my newsletter

Read articles from Vandana Pandit directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vandana Pandit
Vandana Pandit

๐Ÿ‘ฉโ€๐Ÿ’ป I am currently working as Infrastructure Engineer. ๐Ÿ”ญ Iโ€™m currently preparing for CKA certification. ๐Ÿ“ Do check my linked post I keep posting articles related to DevOps