What is LVM?
LVM is a method of allocating hard drive space into logical volumes that can be easily resized as per our requirement.
OR
LVM is a file management utility which allows us to create and manage the storage of a server like adding, removing and resizing partition on demand.
Below are the basic core term which are used in Logical Volume Manager :
1. Physical volume
2. Logical group
3. Logical volume
4. Physical extent
Scenario 1 :
We are taking simplest scenario to make good understanding about LVM. Many of us didn’t understand how the fundamentals exist behind LVM.
Basically We have provided raw disk to our machine. Using provided raw disk, we have to make partition using fdisk command utility. After making partition, we are able to make PV(Physical Volume), VG(Volume Group), and finally LV(Logical Volume).
Lets see the demonstration : “Welcome to Eassy Linux”
We are having 10 GB of Raw disk /dev/sdb :
![](https://static.wixstatic.com/media/986ac3_196c7da5f9f1410eb4e59a87fbcb5299~mv2.png/v1/fill/w_544,h_124,al_c,q_85,enc_auto/986ac3_196c7da5f9f1410eb4e59a87fbcb5299~mv2.png)
NOTE : sda disk is used for system partition configuration.
#fdisk –l (list the disk available with system)
![](https://static.wixstatic.com/media/986ac3_b1bdbc73baa24fa28f7f9b635f9fb214~mv2.png/v1/fill/w_664,h_433,al_c,q_85,enc_auto/986ac3_b1bdbc73baa24fa28f7f9b635f9fb214~mv2.png)
Now , Using this raw disk /dev/sdb, we are going to first make partition using fdisk utility :
#fdisk /dev/sdb
Now press n to create a new partition.
Press p to make primary partition.
It will ask for starting cylinder as it is raw disk we will use whole disk, so just simply press enter.
enter the last cylinder. Just simply press enter as we need to use the whole disk. The drive has been initialized and read to be formatted.
To check partition information by pressing p.
Below are the step snapshots:
![](https://static.wixstatic.com/media/986ac3_52dcb693147242738af69123cc3a9857~mv2.png/v1/fill/w_613,h_372,al_c,q_85,enc_auto/986ac3_52dcb693147242738af69123cc3a9857~mv2.png)
Now after performing the above steps we can see here above partition type is LINUX (ID 83) so we need to change.
Now press t (toggle).
It will suggest to see the Hex codes list for different partition type. We have to choose 8e from the list.
![](https://static.wixstatic.com/media/986ac3_b6f38fd39fe64c9e9da5083c58f35cd8~mv2.png/v1/fill/w_724,h_422,al_c,q_85,enc_auto/986ac3_b6f38fd39fe64c9e9da5083c58f35cd8~mv2.png)
After putting 8e Hex code for partition 1, its partition type has been changed.
![](https://static.wixstatic.com/media/986ac3_84588fc35b044f71b8907d1b07fb0c9d~mv2.png/v1/fill/w_610,h_221,al_c,q_85,enc_auto/986ac3_84588fc35b044f71b8907d1b07fb0c9d~mv2.png)
Now press w to save the changes made to fdisk utility.
/dev/sdb partition is done now.
Now execute the below command to inform operating system kernel of partition table changes.
#partprobe /dev/sdb
![](https://static.wixstatic.com/media/986ac3_b8afe66cd0674953afa1a4735c74e63e~mv2.png/v1/fill/w_307,h_40,al_c,q_85,enc_auto/986ac3_b8afe66cd0674953afa1a4735c74e63e~mv2.png)
Create the physical volume :
#pvcreate /dev/sdb1
![](https://static.wixstatic.com/media/986ac3_079717316da04ab98e6ed407cce5072b~mv2.png/v1/fill/w_416,h_63,al_c,q_85,enc_auto/986ac3_079717316da04ab98e6ed407cce5072b~mv2.png)
Create the Volume group with the name eassylinux :
#vgcreate eassylinux /dev/sdb1
![](https://static.wixstatic.com/media/986ac3_b60fb60558244dc398ec6754efddf591~mv2.png/v1/fill/w_422,h_57,al_c,q_85,enc_auto/986ac3_b60fb60558244dc398ec6754efddf591~mv2.png)
TO verify volume group is created or not we used vgs command.
![](https://static.wixstatic.com/media/986ac3_796bf12ccd35434c81bcece191c852a2~mv2.png/v1/fill/w_404,h_88,al_c,q_85,enc_auto/986ac3_796bf12ccd35434c81bcece191c852a2~mv2.png)
Now as you can see, our logical group size is 10GB.
Create Logical volume with name data of size 4GB :
#lvcreate –L 4GB –n data eassylinux
![](https://static.wixstatic.com/media/986ac3_b528b7d954ee4456b819c38fe02ee30e~mv2.png/v1/fill/w_480,h_58,al_c,q_85,enc_auto/986ac3_b528b7d954ee4456b819c38fe02ee30e~mv2.png)
Here
–L = size of lv.
-n = name of lv.
To verify use lvdisply , lvscan or lvs command.
![](https://static.wixstatic.com/media/986ac3_978ef6f9d1fd4bf79fbc41bd20677673~mv2.png/v1/fill/w_668,h_102,al_c,q_85,enc_auto/986ac3_978ef6f9d1fd4bf79fbc41bd20677673~mv2.png)
Now format the LVM partition :
![](https://static.wixstatic.com/media/986ac3_44f8b839947346c59e7acbd89ac6e5f6~mv2.png/v1/fill/w_549,h_368,al_c,q_85,enc_auto/986ac3_44f8b839947346c59e7acbd89ac6e5f6~mv2.png)
Make a directory for mounting the LVM parttiton :
# mkdir /data
Now mount the partition:
Here We are mounting temporary
![](https://static.wixstatic.com/media/986ac3_043a9428597f42e499d1f31a4ae61c1f~mv2.png/v1/fill/w_524,h_40,al_c,q_85,enc_auto/986ac3_043a9428597f42e499d1f31a4ae61c1f~mv2.png)
Verify the mount by df -h command :
![](https://static.wixstatic.com/media/986ac3_4582914d8b6e41c5b3ec6442800e66ad~mv2.png/v1/fill/w_596,h_163,al_c,q_85,enc_auto/986ac3_4582914d8b6e41c5b3ec6442800e66ad~mv2.png)
Also verify with lost+found directory available inside the mount point. If exist , that means you have successfully configured the LVM.
![](https://static.wixstatic.com/media/986ac3_b8b55f43cff6478bafe546cc350b7ead~mv2.png/v1/fill/w_615,h_228,al_c,q_85,enc_auto/986ac3_b8b55f43cff6478bafe546cc350b7ead~mv2.png)
Congratulations!!!!
We have configured the LVM partition.
In next scenarios, We will see how to make 3 logical volume with 1 PV and 1 VG.
コメント