summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeo Mrnjavac <teo@kde.org>2016-11-10 15:58:48 +0100
committerTeo Mrnjavac <teo@kde.org>2016-11-25 18:38:44 +0100
commit61703ad0701bb955d327c099565c0b56c0d3ca38 (patch)
tree53f28008c53c1d26320f5fc9ad81a2d83ca35f2a
parente95b5552899e583bf0dcc92229bbc3f3e27dbf12 (diff)
Write Btrfs subvolume lines to fstab.v2.4.5
-rw-r--r--src/modules/fstab/main.py43
1 files changed, 38 insertions, 5 deletions
diff --git a/src/modules/fstab/main.py b/src/modules/fstab/main.py
index 05b094fdc..622f55c44 100644
--- a/src/modules/fstab/main.py
+++ b/src/modules/fstab/main.py
@@ -21,6 +21,7 @@
import os
import re
+import subprocess
import libcalamares
@@ -180,10 +181,33 @@ class FstabGenerator(object):
print(FSTAB_HEADER, file=fstab_file)
for partition in self.partitions:
- dct = self.generate_fstab_line_info(partition)
-
- if dct:
- self.print_fstab_line(dct, file=fstab_file)
+ # 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)
+
+ if dct:
+ self.print_fstab_line(dct, file=fstab_file)
if self.root_is_ssd:
# Mount /tmp on a tmpfs
@@ -224,12 +248,21 @@ class FstabGenerator(object):
if mount_point == "/":
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"],
mount_point=mount_point or "swap",
fs=filesystem,
options=options,
check=check,
- )
+ )
def print_fstab_line(self, dct, file=None):
""" Prints line to '/etc/fstab' file. """