Skip to content
Snippets Groups Projects
Commit 5601b740 authored by Administrator's avatar Administrator
Browse files

Small fixes to mounting and unmounting

parent e1c51c31
No related branches found
No related tags found
No related merge requests found
...@@ -131,10 +131,10 @@ class Snapshot: ...@@ -131,10 +131,10 @@ class Snapshot:
self.get_name().replace("-", "--")) self.get_name().replace("-", "--"))
def get_mount_options(self): def get_mount_options(self):
return "-nfstype=xfs,ro,noatime,nouuid,norecovery" return "ro,noatime,nouuid,norecovery"
def get_tab_entry(self): def get_tab_entry(self):
return "{} {} :{}".format( return "{} -fstype=xfs,{} :{}".format(
self.get_name(), self.get_name(),
self.get_mount_options(), self.get_mount_options(),
self.get_mapper_device()) self.get_mapper_device())
...@@ -166,10 +166,21 @@ class Snapshot: ...@@ -166,10 +166,21 @@ class Snapshot:
"/bin/mount", "/bin/mount",
self.get_mapper_device(), self.get_mapper_device(),
self.get_mountpoint(), self.get_mountpoint(),
self.get_mount_options() # nouuid is necessary for xfs snapshots "-o", self.get_mount_options()
] ]
sp.run(mount_command, check=True) sp.run(mount_command, check=True)
def check_mount(self):
check_command = [
"/bin/findmnt",
"--source", self.get_mapper_device()
]
try:
sp.check_call(check_command)
return True
except sp.CalledProcessError:
return False
def remove(self): def remove(self):
self.unmount() self.unmount()
remove_command = [ remove_command = [
...@@ -179,6 +190,7 @@ class Snapshot: ...@@ -179,6 +190,7 @@ class Snapshot:
sp.run(remove_command, check=True) sp.run(remove_command, check=True)
def unmount(self): def unmount(self):
if self.check_mount():
unmount_command = [ unmount_command = [
"/bin/umount", "/bin/umount",
self.get_mountpoint() self.get_mountpoint()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment