✨Elasticity Task Integrating LVM with Hadoop and providing Elasticity to Datanode Storage.
✨Increase or Decrease the Size of Static Partition in Linux.
Logical Volume Manager (LVM)
Traditional storage capacity is based on individual disk capacity. LVM uses a different concept. Storage space is managed by combining or pooling the capacity of the available drives. With traditional storage, three 1 TB disks are handled individually. With LVM, those same three disks are considered to be 3 TB of aggregated storage capacity. This is accomplished by designating the storage disks as Physical Volumes (PV), or storage capacity useable by LVM. The PVs are then added to one or more Volume Groups (VGs). The VGs are carved into one or more Logical Volumes (LVs), which then are treated as traditional partitions.

An administrator thinks of LVM as total combined storage space.

1. Install a new hard disk drive
There needs to be a storage disk available. Just physically install a drive in the server.

2. Designate Physical Volumes
Physical Volumes (PV) are disks or partitions that are available to LVM as potential storage capacity. We can mix and match drive types to create PVs. To implement LVM, first designate a drive as a Physical Volume.
For this first install LVM


Command to create a PV:

Display PV capacity and additional information:

Similarly creating another similar volume:
3. Manage Volume Groups
Once one or more of the disks are available to LVM as Physical Volumes, the storage capacity is combined into Volume Groups (VGs). There may be more than one VG on a server, and disks may be members of more than one VG (but PVs themselves may only be members of one VG).
Use the vgcreate
command to create a new Volume Group. The VG must have at least one member.Use the following command to create a Volume Group named iiecvg with /dev/xvdf
and /dev/xvdg
as members:


Display information for a VG named iiecvg:

4. Manage Logical Volumes
he lvcreate
command carves storage capacity from a VG. The syntax for the lvcreate
command is as follows:
lvcreate -L size -n lvname vgnameHere is the command to create a 1 GB Logical Volume named mylv1 carved from the iiecvg Volume Group:

You can use the lvdisplay
command to see the Logical Volume's configuration.

5. Apply a filesystem and set a mount point
Once the LV is created, it is managed as any other partition. It needs a filesystem and a mount point, just like we configured in the standard partition management section above.
- Run the
mkfs.ex4
command on the LV. - Create a mount point by using
mkdir.
- Manually mount the volume using the
mount
command. - Use the
df -h
command to verify the storage capacity is available.



Increase capacity
You can add storage capacity to the Logical Volume. This is useful if the users consume more space than you anticipated. The process is pretty logical:
- Add a disk and configure it as a PV.
- Add it to a VG.
- Add the capacity to the LV and then extend the filesystem.

Reduce capacity
Reducing storage space is a less common task, but it’s worth noting. The process occurs in the opposite order from expanding storage.
Note: XFS filesystems are not actually shrunk. Instead, back up the content and then restore it to a newly-resized LV. You can use the xfsdump
utility to accomplish this. The ext4 filesystem can be reduced.
First unmount it
umount /dev/iiecvg/mylv1
1. Shrink the filesystem
resize2fs /dev/iiecvg/mylv1 3k
2. Reduce the LV
Use the lvreduce
command to shrink the storage space allocated to the LV. This returns the potential storage capacity to the VG.
lvreduce -L 2T iiecvg/mylv1