How to configure lvm in Linux in just few simple steps

Posted: 21 Jan 2019 in RAID and LVM
Tags: , ,

Learn to create lvm inside RedHat Enterprise Linux. This tutorial is all about lvm creation in Linux and with creation we also learn how to delete lvm,how to delete volume group and how to delete physical volume in Linux. We learn the complete lvm creation and deletion process in just few simple steps.

For this LVM Lab we have total 5 Hard Drive /dev/sda ,dev/sdb,/dev/sdc ,/dev/sdd and /dev/sde


Out of these 5 only 4 Drives are taking part in this LVM Creation Lab

and those Drives are: /dev/sdb,/dev/sdc,/dev/sdd and /dev/sde

Related Articles for You:

How to extend size of LVM Disk

How to Reduce or shrink the size of LVM Disk

How to create and configure STRIPPED LOGICAL VOLUME in Linux

How to create and configure MIRRORED LOGICAL VOLUME in Linux

How to create and configure SNAPSHOT LOGICAL VOLUME in Linux

 

Before doing any thing first we will Check Partition Table:


[root@localhost ~]# cat /proc/partitions

8 0 27962016 sda
8 1 20482843 sda1
8 2 4096575 sda2
8 16 2097152 sdb
8 32 2097152 sdc
8 48 2097152 sdd
8 64 2097152 sde
[root@localhost ~]#

 

 

Now create a partition in each Hard Drive using fdisk command Line tool.


I hope you all know how to create partition in Linux,if not then Please Read below article:

How to create and Delete Partition in Linux


 

Now convert the newly created partition  to LVM Type using fdisk tool.


 

Create Physical Volume using pvcreate


 

pvcreate

 

Now display physical volume information in short using pvs


Display physical volume information in detail using pvdisplay


 

Create a Volume group vg00 from physical Volumes /dev/sdb1,/dev/sdc1/dev/sdd1 and /dev/sde1

see volume group information in short using vgs command

see the volume group related info in detail  using vgdisplay

 

 

Create LVM and name it lv1


Create a Directory,Format the lvm


i have create a directory /lvdata and format the lvm partition with ext3 file system using mkfs.ext3 command.

 

Mount lvm Partition to use it.


After formatting the lvm partition i have mounted the lvm partition /dev/vg00/lv1 on /lvdata folder.

See lvm partition and physical partition info along with related volume group


[root@localhost ~]# pvscan
PV /dev/sdb1 VG vg00 lvm2 [484.00 MB / 364.00 MB free]
PV /dev/sdc1 VG vg00 lvm2 [964.00 MB / 0 free]
PV /dev/sdd1 VG vg00 lvm2 [484.00 MB / 484.00 MB free]
PV /dev/sde1 VG vg00 lvm2 [964.00 MB / 0 free]
Total: 4 [2.83 GB] / in use: 4 [2.83 GB] / in no VG: 0 [0 ]
[root@localhost ~]#

 

Have a Brief look of what we have done before learning how to Delete.


Now learn the process of deleting lvm in Linux.


Like creation of LVM deletion of LVM is equally important. So in this tutorial i have also mentioned the steps to create a lvm partition. There is a proper method to delete lvm partition in your linux machine and if you have not deleted your lvm partition properly you will be in difficulty.

 

Step 1: unmount lvm partition and delete it.


unmount the lvm partition using umount command.

then cross check it using df -h command

then delete the lvm partition using lvremove command.

and then crosscheck it using lvs or lvdisplay command.

Step 2: delete volume group and check it.


You can delete volume group only after deletion of lvm partition.

Step 3: delete Physical Volume and Check it


You can delete physical volume only after deletion of volume group.so whenever you need to delete a physical volume must delete volume group first otherwise you will be in problem.

Partition yet not deleted

Always remember ………….. deleting physical volume doestn’t mean deleting partition. You have to delete partition after deletion of physical volume.

you can still see the partition available

now if you want to Delete your Partitions you can do this using fdisk tool ,and if you are new to Linux see below links it will guide you.

How to Create and How to delete Linux Partition.
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.