[mount] Add support for zfs datasets

This commit is contained in:
dalto 2021-11-06 14:33:43 -05:00
parent e3af4f3e26
commit 858e271c8a

View File

@ -131,6 +131,24 @@ def mount_partition(root_mount_point, partition, partitions):
",".join([mount_option, partition.get("options", "")])) != 0:
libcalamares.utils.warning("Cannot mount {}".format(device))
if fstype == "zfs" and partition["mountPoint"] == '/':
# Get the zfs dataset list from global storage
zfs = libcalamares.globalstorage.value("zfs")
if not zfs:
libcalamares.utils.warning("Failed to locate zfs dataset list")
# Set the canmount property for each dataset. This will effectively mount the dataset
for dataset in zfs:
if dataset['canmount'] == 'noauto' or dataset['canmount'] == 'on':
subprocess.check_call(['zfs', 'set', 'canmount=' + dataset['canmount'],
dataset['zpool'] + '/' + dataset['dsName']])
# It is common for the / mountpoint to be set to noauto since it is mounted by the initrd
# If this is the case we need to manually mount it here
if dataset['mountpoint'] == '/' and dataset['canmount'] == 'noauto':
subprocess.check_call(['zfs', 'mount', dataset['zpool'] + '/' + dataset['dsName']])
def run():
"""