Skip to main content

What is Logical Volume manager in Linux?






Topics to be covered in this blogpost:


What is LVM and its examples .

Advantage of LVM

Posssibilities of LVM

Realtime LVM Examples

Adding new Space /Disk using LVM 

What is LVM ?

LVM is used to manage volume and disk on the linux Server.

LVM allows disks to be combined together.


Example of LVM:

Like partition of disk in windows C,D drive similarly we can do the same in Linux.

Single disk can be divided into different partitions.


Multiple disks can be combined and grouped into one.

LVM can be understood using the image below:




Advantage of LVM:

In case of disk is running out of space ,you can add new disk without breaking partitions of your 

file system.


Possibilities of LVM:

1.New space can be created on server for new project

2.In case of the low disk space we can increase the space.

3.In case of the extra space allocated to the partition, capacity can be reallocated (reduce capacity in one volume group and add it to another.)

4. Possibilities and different combinations of LVM can be explained using the image below:



Working on LVM : 

Requirement:

We need to deploy 2 applications(app1 and app2) on the single Linux Server. We need separate partitions and space for both the applications. How can we do that ?

We can do it using LVM .I have Explained below how we doing it using LVM.

 
Steps of LVM for adding new Space :

1.Install a new Hard disk drive.

2. Make Partition to use it.

3.Create physical volume.

4.Create Volume group.

5.Create Logical Volume.

6.Apply the filesystem.

7.Set mountpoint.


1. Install the new Hard disk drive :

 We can add this hard disk drive from vCenter /Oracle virtual manager /Oracle Cloud wherever this server is deployed .


2.Make partition: 

a. Login to server using putty .to check if the disk you have added is reflecting in the server or not ,use the command fdisk -l. As you can see that disk /dev/sdb is added to the server .



b. use fdisk command to create partition.

command: fdisk diskname.




c. Type n for creating new partition and type p for primary partition. if you are creating 1 partition then type 1.Select first sector and last sector as default .



d. Above steps will create the new partition of type 'Linux'. but we need partition of type Linux LVM.

Type t and type 8e hexcode to change the partition type.




e. Type w to write the table to disk and exit.


f. if you want to check if the partition has been  created or not , type the command fdisk -l.

you can see in the below snip that /dev/sdb1 partition has been created from /dev/sdb disk.

3. Create the Physical Volume:

Command to create phyical volume: pvcreate partition (example: pvcreate /dev/sdb1)

command to display physical volumes: pvdisplay.


a. create the physical volume from partition /dev/sdb1

pvcreate /dev/sdb1


b. pvdisplay will show you your physical volume details . size of physical volume we have created is 2 gb.

4. Create the Volume Group:

We can create volume group from single physical volume or multiple physical volumes.

command to create VG: vgcreate VGname PV1 PV2 PV3 ....

command to display VG  : vgdisplay 

a. Create VG named vgapps from physical volume /dev/sdb1 as shown below :

vgcreate vgapps /dev/sdb1



5.Create the logical volume : 

Here is the tricky part . we have to create 2 logical volumes of size 1 gb  for 2 applications. because that is our requirement.

command to create logical volume : 

lvcreate -L size(1G or 1T) -n lvname vgname


command to display logical volumes: 

lvdisplay


a. create 2 logical volumes app1-lv and app2-lv for 2 applications from volume group vgapps.

commands :

lvcreate -L 1000M -n app1-lv vgapps

lvcreate -L 1000M -n app2-lv vgapps



b. lvdisplay will show the following info.




6. Apply the FileSystem.

Run the mkfs.ext4 command on LV.

command : mkfs.ext4 LVpath

a. Create file system : mkfs.ext4 /dev/vgapps/app1-lv





7. create the mount point:

a. Create two directories for app1 and app2 .


b. mount LV path on the 2 directories we have created.


c. Use command df -hT to check if the file systems are reflecting or not.

Comments

Popular posts from this blog

Post build configurations on Redhat VM

  ************************************* Post build configuration on Linux VM: ************************************* Set the hostname. hostnamectl set-hostname <Servername> ***************************************** Network configuration : Make sure VM gets the ipv4 ip address either from DHCP or assign the static ip address to it.   Question : How to assign the static ip address to the linux machine using the nmcli ?  Answer: fire the below commands: nmcli device nmcli connection modify enpos3 ipv4.addresses 10.253.1.34/24 nmcli connection modify enpos3 ipv4.gateway 10.253.1.1 nmcli connection modify enpos3 ipv4.method manual nmcli connection modify enpos3 ipv4.dns 8.8.8.8 nmli connection down enpos3 nmcli connection up enpos3 ip address show enpos3 nmcli connection show ************************†****************** Register to RHΝ. Register to redhat network if the linux vm is redhat vm. subscription-manager register --org <org>  --activationkey <activat...

AWS cloud practitioner notes

 AWS Certified cloud practitioner: What is cloud computing? cloud computing is the on demand delivery of the compute power, database storage, applications and other IT resources through a cloud services platform with pay-as-you-go pricing. you can provision exactly the right type and size of the computing resources you need. you can access many resources as you need almost instantly like servers, storage,databases and application services as well. Amazon web services owns and maintains the network connected hardware required for these application services, while you provision and use what you need via a web application. ***************************************** Deployment models of Cloud: Private Cloud: Cloud service used by a single organisation, not exposed to the public. complete control. security of the sensitive applications meeting specific business needs. ********************** Public Cloud: Cloud resources owned and operated by the third party. cloud service provider delive...