Automating LVM using Python

Shreeraj Redgaonkar
3 min readNov 15, 2020

--

In Linux, we sometimes need to modify the size of partitions online, i.e. without unmounting them. However, we cannot achieve this with the help of static partitions created using the fdisk command.

In order to meet this requirement, we use the concept of LVM. LVM stands for Logical Volume Management. With the help of LVM technology, we can modify the partitions by increasing or decreasing their size online. This technology proves very helpful in commercial applications such as servers, which cannot be offline for even a second!

Before getting started, let’s take a look at definition of LVM. LVM is a system of managing logical volumes, or filesystems, that is much more advanced and flexible than the traditional method of partitioning a disk into one or more segments and formatting that partition with a filesystem.

In order to help you use the LVM technology, our team having team members Surayya Shaikh, Kartik Arora, Girish Yadav and me (Shreeraj Redgaonkar) has created an Automation script for LVM in Python. With the help of this script, you can use and execute the LVM technology without even knowing and typing a single line of code!

So without wasting more time, let’s jump to the LVM Automation. Following is the menu of the Automation program:

As you can see from the menu, we can perform various operations using the Automation script. The first operation is to check and display the information about the available hard disks. The second operation helps you to create a physical volume, the third operation creates a volume group and the fourth operation helps you to create, format and mount the Logical Volume. Finally, the fifth operation helps you extend the size of an existing LV and the sixth operation closes the Automation program.

You can download and use the program from GitHub. Thanks for reading till the end.

--

--