Automating LVM with python script
Kapil Kumar
Software Development Engineer Level 1 @Cogoport | Backend Developer | Ruby on Rails | Kotlin | Micronaut | Python | FastAPi | Docker | RHEL8 | AWS
Code has been uploaded to github: https://github.com/kapil111kumar/lvmautomation
Name of the python script is "lvmautomation.py", command to run python file --> python3 lvmautomation.py
Options are provide in the menu for different procedures...
- We will choose the option 1 to list all the disks/drives...
Disks: /dev/sdc, /dev/sdd, /dev/sde are the on which we will perform automation..
2. Now, will choose the option 2, to create physical volumes(PV's) on the disks stated above...
And we will continue for next options..
3. Now, will go for option 3 to display all the new PV's created..
As we can observe that these disks space aren't still allocatable.. it is bcz.. we haven't created any vg and formatted, so in next step we eill do that.
4. Now, we add the above three PV's(/dev/sdc, /dev/sdd. /dev/sde) created in option 2, and then create a volume group(VG) named "vg1"
VG "vg1" has been created successfully..
5. We can list the VG's using the the option 5..
we can see from the output that vg1 of size appx. 43GiB(8+20+15)
6. Now, we will create a logical volume "lv1" from the VG "vg1" of size 11GiB and format it with fs "ext4"..
7. We can display the LV using option 7..
8. Now, we will do some extra part that is resizing the size of LV, we can increase or decrease but here we will do the practical for increase..
resizing has been done, we can also observe that resize2fs formatting type has been use..
we also confirm it from option 7... size has been resized to 19GiB
we can see it also using option 1..
!!! Task Completed !!!