[fstab] fix btrfs with LUKS and systemd

- see also #730
- credit goes to @abucodonosor
This commit is contained in:
Philip 2017-09-12 07:10:59 -04:00
parent fcc23b98d2
commit 39d73e1882

View File

@ -226,6 +226,7 @@ class FstabGenerator(object):
def generate_fstab_line_info(self, partition): def generate_fstab_line_info(self, partition):
""" Generates information for each fstab entry. """ """ Generates information for each fstab entry. """
filesystem = partition["fs"].lower() filesystem = partition["fs"].lower()
has_luks = "luksMapperName" in partition
mount_point = partition["mountPoint"] mount_point = partition["mountPoint"]
disk_name = disk_name_for_partition(partition) disk_name = disk_name_for_partition(partition)
is_ssd = disk_name in self.ssd_disks is_ssd = disk_name in self.ssd_disks
@ -253,17 +254,28 @@ class FstabGenerator(object):
self.root_is_ssd = is_ssd self.root_is_ssd = is_ssd
if filesystem == "btrfs" and "subvol" in partition: if filesystem == "btrfs" and "subvol" in partition:
return dict( if has_luks:
device="UUID=" + partition["uuid"], return dict(
mount_point=mount_point, device="/dev/mapper/" + partition["luksMapperName"],
fs=filesystem, mount_point=mount_point,
options=",".join( fs=filesystem,
["subvol={}".format(partition["subvol"]), options] options=",".join(
), ["subvol={}".format(partition["subvol"]), options]
check=check, ),
) check=check,
)
else:
return dict(
device="UUID=" + partition["uuid"],
mount_point=mount_point,
fs=filesystem,
options=",".join(
["subvol={}".format(partition["subvol"]), options]
),
check=check,
)
if "luksMapperName" in partition: if has_luks:
return dict(device="/dev/mapper/" + partition["luksMapperName"], return dict(device="/dev/mapper/" + partition["luksMapperName"],
mount_point=mount_point or "swap", mount_point=mount_point or "swap",
fs=filesystem, fs=filesystem,