1
1
import subprocess
2
-
2
+ import os
3
3
def checkAvailableDisks ():
4
4
print (subprocess .run ("lsblk" ))
5
5
@@ -15,17 +15,17 @@ def VolList():
15
15
16
16
def createPhysicalVolume (VolumeList ):
17
17
for i in VolumeList :
18
- subprocess . run (f"pvcreate { i } " )
18
+ os . system (f"pvcreate { i } " )
19
19
print (f"{ i } Drive is converted to Physical Volume" )
20
20
print ("All the drives are converted to Physical Volume" )
21
21
22
22
def extendVolumeGroup (Volume ):
23
- subprocess . run (f"vgextend { Volume } " )
23
+ os . system (f"vgextend { Volume } " )
24
24
print (f"{ Volume } is added to Volume Group" )
25
25
26
26
def createVolumeGroup (VolumeList ):
27
27
volGrpName = input ("Enter the name you want to give to your Volume Group: " )
28
- subprocess . run (f"vgcreate { volGrpName } { VolumeList [0 ]} " )
28
+ os . system (f"vgcreate { volGrpName } { VolumeList [0 ]} " )
29
29
for i in range (1 ,len (VolumeList )):
30
30
extendVolumeGroup (VolumeList [i ])
31
31
print ("Volume Group created with the name {}!" .format (volGrpName ))
@@ -34,53 +34,54 @@ def createVolumeGroup(VolumeList):
34
34
def createLogicalVolume (volGrpName ):
35
35
logVolName = input ("Enter the name you want to give to your Logical Volume: " )
36
36
logVolsize = input ("Enter the size of Logical Volume you want to create(in G): " )
37
- subprocess . run (f"lvcreate --size { logVolsize } G --name { logVolName } " )
37
+ os . system (f"lvcreate --size { logVolsize } G --name { logVolName } " )
38
38
print (f"Logical Volume of size { logVolsize } GB is created with the name { logVolName } " )
39
39
return logVolName
40
40
41
41
def extendLogicalVolume (volGrpName ,logVolName ):
42
42
volGrpName = input ("Enter the name of your Volume Group: " )
43
43
logVolName = input ("Enter the name of your Logical volume: " )
44
44
addvol = input (f"How much you want to add extra in { logVolName } (in GB): " )
45
- subprocess . run (f"lvextend --size +{ addvol } G /dev/{ volGrpName } /{ logVolName } " )
45
+ os . system (f"lvextend --size +{ addvol } G /dev/{ volGrpName } /{ logVolName } " )
46
46
print (f"Logical Volume size increased by { addvol } " )
47
47
48
48
def decreaseLogicalVolume (volGrpName ,logVolName ):
49
49
print ("WARNING THIS CAN DESTROY YOUR DATA AND NOT SUPPORTED IN GFS2 AND XFS FORMATS\n " * 3 )
50
50
decvol = input (f"Enter the size by which you want to decrease in { logVolName } (in GB): " )
51
- subprocess . run (f"lvreduce --resizefs -L -{ decvol } /dev/{ volGrpName } /{ logVolName } " )
51
+ os . system (f"lvreduce --resizefs -L -{ decvol } /dev/{ volGrpName } /{ logVolName } " )
52
52
print (f"Logical Volume size reduced by { decvol } " )
53
53
54
54
def firstFormat (logVolName ,volGrpName ):
55
55
print ("Performing EXT4 formating for first time" )
56
- subprocess . run (f"mkfs.ext4 /dev/{ volGrpName } /{ logVolName } " )
56
+ os . system (f"mkfs.ext4 /dev/{ volGrpName } /{ logVolName } " )
57
57
print ("Format complete, disk is ready for mounting!" )
58
58
59
59
def extendedFormat (logVolName ,volGrpName ):
60
- subprocess . run (f"resize2fs /dev/{ volGrpName } /{ logVolName } " )
60
+ os . system (f"resize2fs /dev/{ volGrpName } /{ logVolName } " )
61
61
print ("Formated extended Volume!" )
62
62
63
63
def mount (logVolName ,volGrpName ):
64
64
des = input ("Do you have existing dir on which you have to mount?:(Y/N) " )
65
+ dirname = ''
65
66
if (des == 'Y' ):
66
67
dirName = input ("Add dir path you want to mount: " )
67
68
else :
68
69
dirname = input ("Give name to dir where you want to mount: " )
69
- subprocess . run (f"mkdir /{ dirName } " )
70
- subprocess . run (f"mount /dev/{ volGrpName } /{ logVolName } " )
70
+ os . system (f"mkdir /{ dirName } " )
71
+ os . system (f"mount /dev/{ volGrpName } /{ logVolName } " )
71
72
72
73
def detailsPhysicalVolume ():
73
74
pv = input ("Enter the Physical Volume which you want to see details: " )
74
- print (subprocess . run (f"pvdisplay { pv } " ))
75
+ print (os . system (f"pvdisplay { pv } " ))
75
76
76
77
def detailsVolumeGroup (volGrpName ):
77
78
vg = input ("Enter the Volume Group which you want to see details: " )
78
- print (subprocess . run (f"vgdisplay { vg } " ))
79
+ print (os . system (f"vgdisplay { vg } " ))
79
80
80
81
def detailsLogicalVolume ():
81
82
vg = input ("Enter the Volume Group where the Logical Volume is located: " )
82
83
lv = input ("Enter the logical Volume which you want to see details: " )
83
- print (subprocess . run (f"lvdisplay { vg } /{ lv } " ))
84
+ print (os . system (f"lvdisplay { vg } /{ lv } " ))
84
85
85
86
def introHeader ():
86
87
print ("""
0 commit comments