From 6e440bf9bb4c6d3206ed1dc20f067cd5e6723d25 Mon Sep 17 00:00:00 2001 From: dalto Date: Sat, 13 Nov 2021 11:13:39 -0600 Subject: [PATCH] [umount] Export zpools after unmounting --- src/modules/umount/main.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/modules/umount/main.py b/src/modules/umount/main.py index 0035a6b0f..795eb8d2b 100644 --- a/src/modules/umount/main.py +++ b/src/modules/umount/main.py @@ -49,6 +49,26 @@ def list_mounts(root_mount_point): return lst +def export_zpools(root_mount_point): + """ Exports the zpools if defined in global storage + + :param root_mount_point: The absolute path to the root of the install + :return: + """ + try: + zfs_pool_list = libcalamares.globalstorage.value("zfsPoolInfo") + zfs_pool_list.sort(reverse=True, key=lambda x: x["poolName"]) + if zfs_pool_list: + for zfs_pool in zfs_pool_list: + import_result = subprocess.run(['zpool', 'export', root_mount_point, zfs_pool["poolName"]]) + if import_result.returncode != 0: + libcalamares.utils.warning("Failed to export zpool") + except Exception as e: + # If this fails it shouldn't cause the installation to fail + libcalamares.utils.warning("Received exception while exporting zpools: " + format(e)) + pass + + def run(): """ Unmounts given mountpoints in decreasing order. @@ -94,6 +114,8 @@ def run(): # in the exception object. subprocess.check_output(["umount", "-lv", mount_point], stderr=subprocess.STDOUT) + export_zpools(root_mount_point) + os.rmdir(root_mount_point) return None