How to increase or decrease Hadoop Datanode Static Partition [Part 2]
Task 7.1
- Integrating LVM with Hadoop and providing Elasticity to DataNode Storage.
- Increase or Decrease the Size of Static Partition in Linux.
- Automating LVM Partition using Python-Script.
We are contributing LV1 volume back to the VG and give it to the LV2. So we can provide extra volume to the LV2.
lvdisplay /dev/hadoop/lv1
Note
If you have more than 40GiB of data in the LV1 then it will be destroy data while reducing volume.
Whenever we reduce the LVM it always tries to keep your data in the partition and try to acquire space from where ever we have the space is free.
vgdisplay hadoop
To reduce the LV partition we must follow 4 steps i.e.
Step 1
Unmount the partition.
umount part1/
Ensure that you come out from the partition otherwise, it will notify you busy.
If multiple users are reading or writing or running a program from the partition that is using in real-time then it will hang up or fail.
Step 2
Scan and Clean the partition.
e2fsck -f /dev/mapper/hadoop-lv1
Whenever we create a partition it creates an inode table. Whenever you create or delete files it keeps on updating the inode tables. Sometimes in inode tables, we have some kind of proper unmapping or unlinking of the files of their locations. While creating and removing the files that time some types of garbage come up.
Step 3
Format the partition with online formating
resize2fs /dev/mapper/hadoop-lv1 40G
lvdisplay /dev/mapper/hadoop-lv1
Physically volume sectors are being already be associated. But although it is showing the volume size of 50GiB.
Why?
Because we resize the partition format although the physical volume will be the same 50GiB.
Step 4
Reduce LV
All the 10GB that is not formatted and it is not useful so we have to reduce it.
lvreduce — size -10G /dev/mapper/hadoop-lv1
It will physically remove the volume from the LV and then it will go back to VG.
Now, we can see that LV volume is reduced from 50GiB to 40GiB.
VG size gets increased from 5.99GiB to 15.99GiB.
At last mount it as before to use.
Mount
mount /dev/hadoop/lv1 part1/df -h
Extending the LV
lvextend — size +10 /dev/mapper/hadoop-lv2
It physically gets the volume but without format, it is not useful.
Although it doesn't update here also.
resize2fs /dev/mapper/hadoop-lv2
It will go to physical volume and automatically find the increased volume and update it.
df -h
LV2 size gets increased from 39GiB to 49GiB.