If swap gets deleted entry from /etc/fstab gets also deleted
This commit is contained in:
parent
b9bf1454ad
commit
faac5d22be
@ -126,6 +126,15 @@ class SwapModule(AbstractModule):
|
||||
return
|
||||
disable_swapfile = "sudo swapoff {} && ".format(swap_location) + \
|
||||
"sudo rm {}".format(swap_location)
|
||||
if self._check_fstab_entry() is True:
|
||||
with open("/etc/fstab", "r") as fstab_out:
|
||||
content = fstab_out.readlines()
|
||||
with open("/etc/fstab", "w") as fstab_in:
|
||||
content = content[:-1]
|
||||
for line in content:
|
||||
fstab_in.write(line)
|
||||
else:
|
||||
print("No entry in /etc/fstab!")
|
||||
subprocess.call(disable_swapfile, shell=True)
|
||||
output_swapon = subprocess.check_output(['swapon', '--show']).decode("UTF-8")
|
||||
output_free = subprocess.check_output(['free', '-h']).decode("UTF-8")
|
||||
|
Loading…
Reference in New Issue
Block a user