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.)
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.
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 :
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
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
Post a Comment