Hey guys🙋

In this article let’s talk about how to automate LVM (logical volume management) using python script. We can use any programming language for our task but if we talk about simplicity and readability python will be the most suitable one for us. So let’s look into code.

This is a simple menu-driven program in which I defined 12 different options. Here I used two python modules subprocess and os.

What is the use of os and subprocess modules?

  • The subprocess module is used to run new programs through Python code by creating a new process that helps to gain input or output or error pipes and also helps to gain exit codes of various commands.
  • The OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system-dependent functionality.

The main difference between these two modules is when we run os. system(), It will give output as 0/1 (whether process executed or not) but in the subprocess module we have a way to get a system generated from the subprocess.getoutput() it will execute the code and gives output back to user which we can use for future reference.

#automation #script #python #lvm

Automating LVM setup using Python script.
1.85 GEEK