Write Btrfs subvolume lines to fstab.

This commit is contained in:
Teo Mrnjavac 2016-11-10 15:58:48 +01:00 committed by Philip
parent e3d7180932
commit 8f68f9bdef

View File

@ -21,6 +21,7 @@
import os import os
import re import re
import subprocess
import libcalamares import libcalamares
@ -180,6 +181,29 @@ class FstabGenerator(object):
print(FSTAB_HEADER, file=fstab_file) print(FSTAB_HEADER, file=fstab_file)
for partition in self.partitions: for partition in self.partitions:
# Special treatment for a btrfs root with @ and @home subvolumes
if partition["fs"] == "btrfs" and partition["mountPoint"] == "/":
output = subprocess.check_output(['btrfs',
'subvolume',
'list',
self.root_mount_point])
output_lines = output.splitlines()
for line in output_lines:
if line.endswith(b'path @'):
root_entry = partition
root_entry["subvol"] = "@"
dct = self.generate_fstab_line_info(root_entry)
if dct:
self.print_fstab_line(dct, file=fstab_file)
elif line.endswith(b'path @home'):
home_entry = partition
home_entry["mountPoint"] = "/home"
home_entry["subvol"] = "@home"
dct = self.generate_fstab_line_info(home_entry)
if dct:
self.print_fstab_line(dct, file=fstab_file)
else:
dct = self.generate_fstab_line_info(partition) dct = self.generate_fstab_line_info(partition)
if dct: if dct:
@ -224,6 +248,15 @@ class FstabGenerator(object):
if mount_point == "/": if mount_point == "/":
self.root_is_ssd = is_ssd self.root_is_ssd = is_ssd
if filesystem == "btrfs" and "subvol" in partition:
return dict(device="UUID=" + partition["uuid"],
mount_point=mount_point,
fs=filesystem,
options=",".join(["subvol={}".format(partition["subvol"]),
options]),
check=check,
)
return dict(device="UUID=" + partition["uuid"], return dict(device="UUID=" + partition["uuid"],
mount_point=mount_point or "swap", mount_point=mount_point or "swap",
fs=filesystem, fs=filesystem,