Write Btrfs subvolume lines to fstab.
This commit is contained in:
parent
e3d7180932
commit
8f68f9bdef
@ -21,6 +21,7 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
import libcalamares
|
||||
|
||||
@ -180,6 +181,29 @@ class FstabGenerator(object):
|
||||
print(FSTAB_HEADER, file=fstab_file)
|
||||
|
||||
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)
|
||||
|
||||
if dct:
|
||||
@ -224,6 +248,15 @@ 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,
|
||||
|
Loading…
Reference in New Issue
Block a user