LVM(Logical Volume Manager) aka Elastic Storage Volume
What is LVM?
According to RedHat, LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes.
In LVM, we have a few important which are:
- Physical Volume: It is the regular storage device.
- Volume Group: Volume group pools the storage from the physical volume.
- Logical Volume: Volume group can be sliced into any number of logical volumes and are functionally equivalent to the partitions in the physical disk, but with much more flexibility.
Steps to create LVM:
- Attach the physical drives
2. Check for the attached drives
/dev/sdb and /dev/sdc are the drives which I have connected.
3. Create physical drives using the command:
pvcreate drive_name
4. Create the volume group using the command:
vgcreate volume_group_name drive_names
5. Create the logical volume using the following command:
lvcreate — size 4G — name partition_name volume_group_name
6. Format the partition using the following command:
mkfs.format_name partition_name
7. Mount the partition on some directory using the command:
mount partition_name mount_directory
mount /dev/volume_group/data_node_elastic /dn1
You can extend/reduce the logical volume using the following commands:
lvextend — size +2G logical_volume_name
lvereduce — size -2G logical_volume_name
Using the above concept, we can make our data nodes/ storage elastic in volume.
We can automate the whole process using the simple python script: