How to Create LVM in Linux Step by Step

1. Add the new disk As Per requirement in your VM. ( I have add 5GB Disk Space for create the LVM. )


2. create a new Partition using fdisk tool and select partition type LVM : 

[root@rajeev ~]#  lsblk 

[root@rajeev ~]#  fdisk /dev/vdb 

[root@rajeev ~]#  partprobe /dev/vdb

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








3. Initializes the partition /dev/vdb1 as an LVM physical volume :

[root@rajeev ~]# pvcreate /dev/vdb1

  Physical volume "/dev/vdb1" successfully created.


4. Displaying Physical Volumes :  ( You Can Use Any One Command. )

[root@rajeev ~]#  pvs /dev/vdb1

[root@rajeev ~]# pvdisplay /dev/vdb1



5. Create volume group name myvg and add /dev/vdb1 partition into the group.

[root@rajeev ~]# vgcreate myvg /dev/vdb1

  Volume group "myvg" successfully created




6. Creates a logical volume called lv_myvg that uses all of the unallocated space in the volume group vg_newlvm :

[root@rajeev ~]# lvcreate -l 100%FREE -n lv_myvg myvg

  Logical volume "lv_myvg" created.



7. Use the mkfs command to format a newly created LVM :

[root@rajeev ~]# mkfs.ext4 /dev/myvg/lv_myvg



8. Create the mount point and mount the new LVM :

[root@rajeev ~]# mkdir /mylvm
[root@rajeev ~]# mount /dev/myvg/lv_myvg  /mylvm/
[root@rajeev ~]# df -h



9. For Permanent mounting 

[root@rajeev ~]# vim /etc/fstab  ( And Add Below Line. )

/dev/myvg/lv_myvg       /mylvm/         ext4    defaults        0 0

 10.  For Test fstab entry.  

[root@rajeev ~]# df -h
[root@rajeev ~]# umount /mylvm
[root@rajeev ~]# df -h
[root@rajeev ~]# mount -a
[root@rajeev ~]# df -h



Comments

Popular posts from this blog

PCS Corosync Pacemaker Cluster Mariadb using NFS

How to install and configure node js and PM2 in rhel7

How to Create or Configure iSCSI Server and Clinet