We will see process on how to create a LVM in Linux.
In My example, I have taken a Cent OS 7 machine.
1) I have added 2 disks on my server of 1 GB each as shown below:-
2) Find the current status of volumes on the server.
3) Now the first steps is to scan the server for the disks which are added:-
Now to scan the system, please run the below command:-
echo "- - -" > /sys/class/scsi_host/host0/scan (Disk is visible sometimes when we run the host0 command)
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
In my case I had to scan host 1 and host 2 as well, in order to get the sdb,sdc as shown above.
4) Now we will create a physical volume from the hard drive. Run the below command as shown below:-
pvcreate /dev/sdb /dev/sdc
5) Now we will create a new volume group. In My example, I have created a new volume group rather than extending one. So run the below command:-
vgcreate volume1 /dev/sdb /dev/sdc
6) Now we will create a new logical volume, hence please run the below command:-
lvcreate -n logicalvolume1 -L 1.9G volume1
7) Now we will create the requird file system.
mkfs -t ext4 /dev/mapper/volume1-logicalvolume1
8) Now we will mount the required filesystem, which can be done by running the below command:-
mount /dev/mapper/volume1-logicalvolume1 /drives/data1
For this to work, I have created a folder drives in the root folder and in the drives folder, data1 folder is created as shown below:-
9) The same now can be seen by running the command:- df -h as shown below:-