• R/O
  • HTTP
  • SSH
  • HTTPS

alterlinux-calamares: 提交

GitHubのミラーです
https://github.com/FascodeNet/alterlinux-calamares


Commit MetaInfo

修订版61703ad0701bb955d327c099565c0b56c0d3ca38 (tree)
时间2016-11-26 02:38:44
作者Teo Mrnjavac <teo@kde....>
CommiterTeo Mrnjavac

Log Message

Write Btrfs subvolume lines to fstab.

更改概述

差异

--- a/src/modules/fstab/main.py
+++ b/src/modules/fstab/main.py
@@ -21,6 +21,7 @@
2121
2222 import os
2323 import re
24+import subprocess
2425
2526 import libcalamares
2627
@@ -180,10 +181,33 @@ class FstabGenerator(object):
180181 print(FSTAB_HEADER, file=fstab_file)
181182
182183 for partition in self.partitions:
183- dct = self.generate_fstab_line_info(partition)
184-
185- if dct:
186- self.print_fstab_line(dct, file=fstab_file)
184+ # Special treatment for a btrfs root with @ and @home subvolumes
185+ if partition["fs"] == "btrfs" and partition["mountPoint"] == "/":
186+ output = subprocess.check_output(['btrfs',
187+ 'subvolume',
188+ 'list',
189+ self.root_mount_point])
190+ output_lines = output.splitlines()
191+ for line in output_lines:
192+ if line.endswith(b'path @'):
193+ root_entry = partition
194+ root_entry["subvol"] = "@"
195+ dct = self.generate_fstab_line_info(root_entry)
196+ if dct:
197+ self.print_fstab_line(dct, file=fstab_file)
198+ elif line.endswith(b'path @home'):
199+ home_entry = partition
200+ home_entry["mountPoint"] = "/home"
201+ home_entry["subvol"] = "@home"
202+ dct = self.generate_fstab_line_info(home_entry)
203+ if dct:
204+ self.print_fstab_line(dct, file=fstab_file)
205+
206+ else:
207+ dct = self.generate_fstab_line_info(partition)
208+
209+ if dct:
210+ self.print_fstab_line(dct, file=fstab_file)
187211
188212 if self.root_is_ssd:
189213 # Mount /tmp on a tmpfs
@@ -224,12 +248,21 @@ class FstabGenerator(object):
224248 if mount_point == "/":
225249 self.root_is_ssd = is_ssd
226250
251+ if filesystem == "btrfs" and "subvol" in partition:
252+ return dict(device="UUID=" + partition["uuid"],
253+ mount_point=mount_point,
254+ fs=filesystem,
255+ options=",".join(["subvol={}".format(partition["subvol"]),
256+ options]),
257+ check=check,
258+ )
259+
227260 return dict(device="UUID=" + partition["uuid"],
228261 mount_point=mount_point or "swap",
229262 fs=filesystem,
230263 options=options,
231264 check=check,
232- )
265+ )
233266
234267 def print_fstab_line(self, dct, file=None):
235268 """ Prints line to '/etc/fstab' file. """
Show on old repository browser