livemedia-creator: Simplify cleanup for no-virt
If an anaconda no-virt run crashes it can leave things mounted under
/mnt/sysimage. Previously anaconda-cleanup was used to handle this, but
it will also try to cleanup host mountpoints which isn't desired.
(cherry picked from commit bae111d5a3
)
This commit is contained in:
parent
631daa0178
commit
372ba1ed16
@ -766,6 +766,23 @@ def novirt_log_check(log_check, proc):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def anaconda_cleanup(dirinstall_path):
|
||||||
|
"""
|
||||||
|
Cleanup any leftover mounts from anaconda
|
||||||
|
|
||||||
|
:param str dirinstall_path: Path where anaconda mounts things
|
||||||
|
|
||||||
|
If anaconda crashes it may leave things mounted under this path. It will
|
||||||
|
typically be set to /mnt/sysimage/
|
||||||
|
"""
|
||||||
|
dirinstall_path = os.path.abspath(dirinstall_path)
|
||||||
|
# unmount filesystems
|
||||||
|
for mounted in reversed(open("/proc/mounts").readlines()):
|
||||||
|
(_device, mountpoint, _rest) = mounted.split(" ", 2)
|
||||||
|
if mountpoint.startswith(dirinstall_path):
|
||||||
|
umount(mountpoint)
|
||||||
|
|
||||||
|
|
||||||
def novirt_install(opts, disk_img, disk_size, repo_url):
|
def novirt_install(opts, disk_img, disk_size, repo_url):
|
||||||
"""
|
"""
|
||||||
Use Anaconda to install to a disk image
|
Use Anaconda to install to a disk image
|
||||||
@ -850,6 +867,9 @@ def novirt_install(opts, disk_img, disk_size, repo_url):
|
|||||||
finally:
|
finally:
|
||||||
log_monitor.shutdown()
|
log_monitor.shutdown()
|
||||||
|
|
||||||
|
# Make sure any leftover anaconda mounts have been cleaned up
|
||||||
|
anaconda_cleanup(ROOT_PATH)
|
||||||
|
|
||||||
# Move the anaconda logs over to a log directory
|
# Move the anaconda logs over to a log directory
|
||||||
log_dir = os.path.abspath(os.path.dirname(opts.logfile))
|
log_dir = os.path.abspath(os.path.dirname(opts.logfile))
|
||||||
log_anaconda = joinpaths(log_dir, "anaconda")
|
log_anaconda = joinpaths(log_dir, "anaconda")
|
||||||
|
Loading…
Reference in New Issue
Block a user