# using LVM with commands

LVM --> is a tool which is used to add  hard disk of different sizes and make it one big logical disk 
scenario - we have 3 hard disk of 10gb 5gb and 1gb , an application need 16gb of memory so using LVM we will add the 3 disk and make 1 logical disk of 16gb


![lvg.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1670214211335/f91WBncLV.png align="left")

installing lvm -- sudo yum install lvm2

* Creating logicaldisk  
   1 . add hard disk    
   2 . partition the disk to lvm linux using fdisk
       $ fdisk /dev/sdd   --> n (new partition) --> t(type lvm linux 8e) --> w (write)
       
![Screenshot from 2022-12-05 10-32-52.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1670216901138/UJMFvvBnq.png align="left")

![Screenshot from 2022-12-05 10-35-36.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1670217222009/wOwoRbz_4.png align="left")

  3 . create a physical volume  
            $ pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1   
            $ pvdisplay 

![Screenshot from 2022-12-05 10-46-46.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1670217486291/vG7aBeLMq.png align="left")
 
4 .   creating volume groups   
             $ vgcreate vgname  /dev/sdb1   /dev/sdc1 /dev/sdd1 

5 .   creating logicalvolume
        $ lvcreate -n logicalvolname  -L 300M VGNAME
        300M is 300mb ,vgname is volgroup that is created
      $  lvcreate -n lgvol2 -l 50%FREE vgname   (using percetange of space)
      $ lvdisplay (shows lv )

6 . creating file system     
            $ mkfs.ext4 /dev/vgname/lgvol2
  

7 .    mount /dev/vgname/lgvol2 /mount

 




