aboutsummarylogtreecommitdiffstats
path: root/croco-btrfs.patch
blob: c5637f3862cf57e5c18c42c8ac2516e97fa54323 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
From a62f0179e61fc5ca3b9c47f7482ce38a85572bdb Mon Sep 17 00:00:00 2001
From: TotallyNotElite <totallynotelite@gmail.com>
Date: Mon, 18 Jan 2021 22:56:27 +0100
Subject: [PATCH] Croco BTRFS patches

---
 src/modules/fstab/main.py       |  38 +++++++
 src/modules/grubcfg/main.py     |   2 +-
 src/modules/initcpiocfg/main.py |   2 +-
 src/modules/mount/main.py       | 178 ++++++++++++++++++++++++++++++--
 4 files changed, 210 insertions(+), 10 deletions(-)

diff --git a/src/modules/fstab/main.py b/src/modules/fstab/main.py
index 6977ccad1..63352128a 100644
--- a/src/modules/fstab/main.py
+++ b/src/modules/fstab/main.py
@@ -206,6 +206,41 @@ class FstabGenerator(object):
                             dct = self.generate_fstab_line_info(home_entry)
                             if dct:
                                 self.print_fstab_line(dct, file=fstab_file)
+                        elif line.endswith(b'path @root'):
+                            rootuser_entry = partition
+                            rootuser_entry["mountPoint"] = "/root"
+                            rootuser_entry["subvol"] = "@root"
+                            dct = self.generate_fstab_line_info(rootuser_entry)
+                            if dct:
+                                self.print_fstab_line(dct, file=fstab_file)
+                        elif line.endswith(b'path @srv'):
+                            srv_entry = partition
+                            srv_entry["mountPoint"] = "/srv"
+                            srv_entry["subvol"] = "@srv"
+                            dct = self.generate_fstab_line_info(srv_entry)
+                            if dct:
+                                self.print_fstab_line(dct, file=fstab_file)
+                        elif line.endswith(b'path @cache'):
+                            cache_entry = partition
+                            cache_entry["mountPoint"] = "/var/cache"
+                            cache_entry["subvol"] = "@cache"
+                            dct = self.generate_fstab_line_info(cache_entry)
+                            if dct:
+                                self.print_fstab_line(dct, file=fstab_file)
+                        elif line.endswith(b'path @log'):
+                            log_entry = partition
+                            log_entry["mountPoint"] = "/var/log"
+                            log_entry["subvol"] = "@log"
+                            dct = self.generate_fstab_line_info(log_entry)
+                            if dct:
+                                self.print_fstab_line(dct, file=fstab_file) 
+                        elif line.endswith(b'path @tmp'):
+                            tmp_entry = partition
+                            tmp_entry["mountPoint"] = "/var/tmp"
+                            tmp_entry["subvol"] = "@tmp"
+                            dct = self.generate_fstab_line_info(tmp_entry)
+                            if dct:
+                                self.print_fstab_line(dct, file=fstab_file)
                         elif line.endswith(b'path @swap'):
                             swap_part_entry = partition
                             swap_part_entry["mountPoint"] = "/swap"
@@ -326,6 +361,9 @@ def create_swapfile(root_mount_point, root_btrfs):
     The swapfile-creation covers progress from 0.2 to 0.5
     """
     libcalamares.job.setprogress(0.2)
+    swapfile_path = os.path.join(root_mount_point, "var", "cache", "swapfile")
+    with open(swapfile_path, "wb") as f:
+        pass
     if root_btrfs:
         # btrfs swapfiles must reside on a subvolume that is not snapshotted to prevent file system corruption
         swapfile_path = os.path.join(root_mount_point, "swap/swapfile")
diff --git a/src/modules/grubcfg/main.py b/src/modules/grubcfg/main.py
index 9e9615a0c..cc017d5a0 100644
--- a/src/modules/grubcfg/main.py
+++ b/src/modules/grubcfg/main.py
@@ -98,7 +98,7 @@ def modify_grub_default(partitions, root_mount_point, distributor):
             break
 
     if have_plymouth:
-        use_splash = "splash"
+        use_splash = "splash rd.udev.log_priority=3 vt.global_cursor_default=0 systemd.unified_cgroup_hierarchy=1"
 
     cryptdevice_params = []
 
diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py
index cdfeadd0f..ca7f96914 100644
--- a/src/modules/initcpiocfg/main.py
+++ b/src/modules/initcpiocfg/main.py
@@ -116,7 +116,7 @@ def modify_mkinitcpio_conf(partitions, root_mount_point):
     btrfs = ""
     lvm2 = ""
     hooks = ["base", "udev", "autodetect", "modconf", "block", "keyboard",
-             "keymap"]
+             "keymap", "consolefont"]
     modules = []
     files = []
     encrypt_hook = False
diff --git a/src/modules/mount/main.py b/src/modules/mount/main.py
index 3982176df..27b9f79df 100644
--- a/src/modules/mount/main.py
+++ b/src/modules/mount/main.py
@@ -82,12 +82,52 @@ def mount_partition(root_mount_point, partition, partitions):
     # Finally we remount all of the above on the correct paths.
     if fstype == "btrfs" and partition["mountPoint"] == '/':
         has_home_mount_point = False
+        has_rootuser_mount_point = False
+        has_srv_mount_point = False
+        has_cache_mount_point = False
+        has_log_mount_point = False
+        has_tmp_mount_point = False
         for p in partitions:
             if "mountPoint" not in p or not p["mountPoint"]:
                 continue
             if p["mountPoint"] == "/home":
                 has_home_mount_point = True
                 break
+            
+        for p in partitions:
+            if "mountPoint" not in p or not p["mountPoint"]:
+                continue
+            if p["mountPoint"] == "/root":
+                has_rootuser_mount_point = True
+                break
+        
+        for p in partitions:
+            if "mountPoint" not in p or not p["mountPoint"]:
+                continue
+            if p["mountPoint"] == "/srv":
+                has_srv_mount_point = True
+                break
+            
+        for p in partitions:
+            if "mountPoint" not in p or not p["mountPoint"]:
+                continue
+            if p["mountPoint"] == "/var/cache":
+                has_cache_mount_point = True
+                break
+            
+        for p in partitions:
+            if "mountPoint" not in p or not p["mountPoint"]:
+                continue
+            if p["mountPoint"] == "/var/log":
+                has_log_mount_point = True
+                break
+            
+        for p in partitions:
+            if "mountPoint" not in p or not p["mountPoint"]:
+                continue
+            if p["mountPoint"] == "/var/tmp":
+                has_tmp_mount_point = True
+                break
         needs_swap_subvolume = False
         swap_choice = global_storage.value( "partitionChoices" )
         if swap_choice:
@@ -105,18 +145,140 @@ def mount_partition(root_mount_point, partition, partitions):
             subprocess.check_call(['btrfs', 'subvolume', 'create',
                                        root_mount_point + '/@swap'])
 
-        subprocess.check_call(["umount", "-v", root_mount_point])
+        if not has_rootuser_mount_point:
+            subprocess.check_call(['btrfs', 'subvolume', 'create',
+                                   root_mount_point + '/@root'])
+            
+        if not has_srv_mount_point:
+            subprocess.check_call(['btrfs', 'subvolume', 'create',
+                                   root_mount_point + '/@srv'])
+            
+        if not has_cache_mount_point:
+            subprocess.check_call(['btrfs', 'subvolume', 'create',
+                                   root_mount_point + '/@cache'])
+            
+        if not has_log_mount_point:
+            subprocess.check_call(['btrfs', 'subvolume', 'create',
+                                   root_mount_point + '/@log'])
+            
+        if not has_tmp_mount_point:
+            subprocess.check_call(['btrfs', 'subvolume', 'create',
+                                   root_mount_point + '/@tmp'])
 
-        device = partition["device"]
+        subprocess.check_call(["umount", "-v", root_mount_point])
 
         if "luksMapperName" in partition:
-            device = os.path.join("/dev/mapper", partition["luksMapperName"])
+            libcalamares.utils.mount(
+                "/dev/mapper/{!s}".format(partition["luksMapperName"]),
+                mount_point,
+                fstype,
+                ",".join(
+                    ["subvol=@", partition.get("options", "")]),
+                )
+            if not has_home_mount_point:
+                libcalamares.utils.mount(
+                    "/dev/mapper/{!s}".format(partition["luksMapperName"]),
+                    root_mount_point + "/home",
+                    fstype,
+                    ",".join(
+                        ["subvol=@home", partition.get("options", "")]),
+                    )
+            if not has_rootuser_mount_point:
+                libcalamares.utils.mount(
+                    "/dev/mapper/{!s}".format(partition["luksMapperName"]),
+                    root_mount_point + "/root",
+                    fstype,
+                    ",".join(
+                        ["subvol=@root", partition.get("options", "")]),
+                    )
+            if not has_srv_mount_point:
+                libcalamares.utils.mount(
+                    "/dev/mapper/{!s}".format(partition["luksMapperName"]),
+                    root_mount_point + "/srv",
+                    fstype,
+                    ",".join(
+                        ["subvol=@srv", partition.get("options", "")]),
+                    )
+            if not has_cache_mount_point:
+                libcalamares.utils.mount(
+                    "/dev/mapper/{!s}".format(partition["luksMapperName"]),
+                    root_mount_point + "/var/cache",
+                    fstype,
+                    ",".join(
+                        ["subvol=@cache", partition.get("options", "")]),
+                    )
+            if not has_log_mount_point:
+                libcalamares.utils.mount(
+                    "/dev/mapper/{!s}".format(partition["luksMapperName"]),
+                    root_mount_point + "/var/log",
+                    fstype,
+                    ",".join(
+                        ["subvol=@log", partition.get("options", "")]),
+                    )
+            if not has_tmp_mount_point:
+                libcalamares.utils.mount(
+                    "/dev/mapper/{!s}".format(partition["luksMapperName"]),
+                    root_mount_point + "/var/tmp",
+                    fstype,
+                    ",".join(
+                        ["subvol=@tmp", partition.get("options", "")]),
+                    )
+        else:
+            libcalamares.utils.mount(
+                partition["device"],
+                mount_point,
+                fstype,
+                ",".join(["subvol=@", partition.get("options", "")]),
+                )
+            if not has_home_mount_point:
+                libcalamares.utils.mount(
+                    partition["device"],
+                    root_mount_point + "/home",
+                    fstype,
+                    ",".join(
+                        ["subvol=@home", partition.get("options", "")]),
+                    )
+            if not has_rootuser_mount_point:
+                libcalamares.utils.mount(
+                    partition["device"],
+                    root_mount_point + "/root",
+                    fstype,
+                    ",".join(
+                        ["subvol=@root", partition.get("options", "")]),
+                    )
+            if not has_srv_mount_point:
+                libcalamares.utils.mount(
+                    partition["device"],
+                    root_mount_point + "/srv",
+                    fstype,
+                    ",".join(
+                        ["subvol=@srv", partition.get("options", "")]),
+                    )
+            if not has_cache_mount_point:
+                libcalamares.utils.mount(
+                    partition["device"],
+                    root_mount_point + "/var/cache",
+                    fstype,
+                    ",".join(
+                        ["subvol=@cache", partition.get("options", "")]),
+                    )
+            if not has_log_mount_point:
+                libcalamares.utils.mount(
+                    partition["device"],
+                    root_mount_point + "/var/log",
+                    fstype,
+                    ",".join(
+                        ["subvol=@log", partition.get("options", "")]),
+                    )
+            if not has_tmp_mount_point:
+                libcalamares.utils.mount(
+                    partition["device"],
+                    root_mount_point + "/var/tmp",
+                    fstype,
+                    ",".join(
+                        ["subvol=@tmp", partition.get("options", "")]),
+                    )
 
-        if libcalamares.utils.mount(device,
-                                    mount_point,
-                                    fstype,
-                                    ",".join(["subvol=@", partition.get("options", "")])) != 0:
-            libcalamares.utils.warning("Cannot mount {}".format(device))
 
         if not has_home_mount_point:
             if libcalamares.utils.mount(device,
-- 
2.30.0