GitHubのミラーです
https://github.com/FascodeNet/alterlinux-calamares
修订版 | 61703ad0701bb955d327c099565c0b56c0d3ca38 (tree) |
---|---|
时间 | 2016-11-26 02:38:44 |
作者 | Teo Mrnjavac <teo@kde....> |
Commiter | Teo Mrnjavac |
Write Btrfs subvolume lines to fstab.
@@ -21,6 +21,7 @@ | ||
21 | 21 | |
22 | 22 | import os |
23 | 23 | import re |
24 | +import subprocess | |
24 | 25 | |
25 | 26 | import libcalamares |
26 | 27 |
@@ -180,10 +181,33 @@ class FstabGenerator(object): | ||
180 | 181 | print(FSTAB_HEADER, file=fstab_file) |
181 | 182 | |
182 | 183 | 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) | |
187 | 211 | |
188 | 212 | if self.root_is_ssd: |
189 | 213 | # Mount /tmp on a tmpfs |
@@ -224,12 +248,21 @@ class FstabGenerator(object): | ||
224 | 248 | if mount_point == "/": |
225 | 249 | self.root_is_ssd = is_ssd |
226 | 250 | |
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 | + | |
227 | 260 | return dict(device="UUID=" + partition["uuid"], |
228 | 261 | mount_point=mount_point or "swap", |
229 | 262 | fs=filesystem, |
230 | 263 | options=options, |
231 | 264 | check=check, |
232 | - ) | |
265 | + ) | |
233 | 266 | |
234 | 267 | def print_fstab_line(self, dct, file=None): |
235 | 268 | """ Prints line to '/etc/fstab' file. """ |