Merge ~jibel/ubiquity:zfs_fixes into ubiquity:master
- Git
- lp:~jibel/ubiquity
- zfs_fixes
- Merge into master
Status: | Merged |
---|---|
Merged at revision: | 3d62cb23e755f1afbb5f8027edf441b23799eb8c |
Proposed branch: | ~jibel/ubiquity:zfs_fixes |
Merge into: | ubiquity:master |
Diff against target: |
461 lines (+240/-90) 4 files modified
debian/changelog (+13/-3) debian/ubiquity.templates (+5/-0) scripts/zsys-setup (+181/-86) ubiquity/plugins/ubi-partman.py (+41/-1) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Didier Roche-Tolomelli (community) | Approve | ||
Review via email:
|
Commit message
Various fixes from experiment:
- Use version 5000 for bpool with some features disabled to stay compatible with grub and prevent users from upgrading and breaking their systems.
- The partman confirmation dialog now displays the final layout of the partition that will be created instead of the true but confusing message from partman telling that an ext4 partition will be created (LP: #1847719)
- Calculate the size of bpool to be 500M < 5% partition size < 2G
- Always create an ESP and moved grub to the ESP.
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Didier Roche-Tolomelli (didrocks) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jean-Baptiste Lallement (jibel) wrote : | # |
Thanks fir the review. Comments addressed.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Didier Roche-Tolomelli (didrocks) wrote : | # |
- one more comment on the new changes
- still 2 pending on previous diff
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jean-Baptiste Lallement (jibel) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Didier Roche-Tolomelli (didrocks) wrote : | # |
LGTM! I didn't give it a try yet, but I didn't spot anything more. Just 2 notes:
- Is having predictable names in /tmp is a security issue? I remember we removed from flag filenames in the past due to this.
- Did you have a look at our latest exchanges with Richard (the ones before the 19.10 release) to ensure we address all of his remarks?
Ack (pending testing)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Didier Roche-Tolomelli (didrocks) wrote : | # |
Did a test-run without UEFI enabled, and working well for me.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jean-Baptiste Lallement (jibel) wrote : | # |
I reviewed the comments from Richard in the spec and latest email exchanges and apparently they've all been addressed.
About the temporary directory in /tmp we could pass an additional argument to the script, but it's called from completely different scopes: from ubiquity itself (ubi-partman and gtk_ui) and from a subprocess, it would add lot of complexity for share the name of the temporary directory between these scopes. Passing it in the environment wouldn't improve the security either. At best we could umask the directory so it can only be accessed by root.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Didier Roche-Tolomelli (didrocks) wrote : | # |
+1 for me then :)
Preview Diff
1 | diff --git a/debian/changelog b/debian/changelog | |||
2 | index 8a152ab..9ba61ce 100644 | |||
3 | --- a/debian/changelog | |||
4 | +++ b/debian/changelog | |||
5 | @@ -1,8 +1,18 @@ | |||
6 | 1 | ubiquity (20.04.1) UNRELEASED; urgency=medium | 1 | ubiquity (20.04.1) UNRELEASED; urgency=medium |
7 | 2 | 2 | ||
11 | 3 | * script/zsys-setup: fix tag name from org.zsys to com.ubuntu.zsys. | 3 | * zfs: |
12 | 4 | * Added an advanced features dialog to the partitioning page. LVM, LVM with | 4 | - Added an advanced features dialog to the partitioning page. LVM, LVM |
13 | 5 | encryption and experimental ZFS support have been moved to this dialog. | 5 | with encryption and experimental ZFS support have been moved to this |
14 | 6 | dialog. | ||
15 | 7 | - Fix tag name from org.zsys to com.ubuntu.zsys. | ||
16 | 8 | - Use version 5000 for bpool with some features disabled to stay | ||
17 | 9 | compatible with grub and prevent users from upgrading and breaking their | ||
18 | 10 | systems. | ||
19 | 11 | - The partman confirmation dialog now displays the final layout of the | ||
20 | 12 | partition that will be created instead of the true but confusing message | ||
21 | 13 | from partman telling that an ext4 partition will be created (LP: #1847719) | ||
22 | 14 | - Calculate the size of bpool to be 500M < 5% partition size < 2G | ||
23 | 15 | - Always create an ESP and moved grub to the ESP. | ||
24 | 6 | 16 | ||
25 | 7 | -- Jean-Baptiste Lallement <jean-baptiste.lallement@ubuntu.com> Mon, 28 Oct 2019 09:07:57 +0100 | 17 | -- Jean-Baptiste Lallement <jean-baptiste.lallement@ubuntu.com> Mon, 28 Oct 2019 09:07:57 +0100 |
26 | 8 | 18 | ||
27 | diff --git a/debian/ubiquity.templates b/debian/ubiquity.templates | |||
28 | index f56ac69..4342a2a 100644 | |||
29 | --- a/debian/ubiquity.templates | |||
30 | +++ b/debian/ubiquity.templates | |||
31 | @@ -1597,3 +1597,8 @@ _Description: | |||
32 | 1597 | Template: ubiquity/secureboot_key | 1597 | Template: ubiquity/secureboot_key |
33 | 1598 | Type: password | 1598 | Type: password |
34 | 1599 | _Description: SecureBoot key for MokPW | 1599 | _Description: SecureBoot key for MokPW |
35 | 1600 | |||
36 | 1601 | Template: ubiquity/text/partman_confirm_zfs | ||
37 | 1602 | Type: text | ||
38 | 1603 | _Description: | ||
39 | 1604 | partition #%(partid)s as %(parttype)s used for %(partusage)s | ||
40 | 1600 | \ No newline at end of file | 1605 | \ No newline at end of file |
41 | diff --git a/scripts/zsys-setup b/scripts/zsys-setup | |||
42 | index 439a9d7..554adb2 100755 | |||
43 | --- a/scripts/zsys-setup | |||
44 | +++ b/scripts/zsys-setup | |||
45 | @@ -43,7 +43,12 @@ set -eu | |||
46 | 43 | REQUIREDPKGS="zfsutils-linux" | 43 | REQUIREDPKGS="zfsutils-linux" |
47 | 44 | TARGET="/target" | 44 | TARGET="/target" |
48 | 45 | ESP="${TARGET}/boot/efi" | 45 | ESP="${TARGET}/boot/efi" |
50 | 46 | INIT_FLAG="/tmp/.zsys-init.done" | 46 | ZSYSTMP="/tmp/$(basename $0)" |
51 | 47 | INIT_FLAG="${ZSYSTMP}/init.done" | ||
52 | 48 | FSTAB_PARTMAN="${ZSYSTMP}/fstab.partman" | ||
53 | 49 | PARTITION_LAYOUT="${ZSYSTMP}/layout" | ||
54 | 50 | |||
55 | 51 | mkdir -p "${ZSYSTMP}" | ||
56 | 47 | 52 | ||
57 | 48 | usage() { | 53 | usage() { |
58 | 49 | # Display script usage | 54 | # Display script usage |
59 | @@ -122,7 +127,7 @@ prepare_target() { | |||
60 | 122 | # Save fstab generated by partman | 127 | # Save fstab generated by partman |
61 | 123 | if [ -f "${target}/etc/fstab" ]; then | 128 | if [ -f "${target}/etc/fstab" ]; then |
62 | 124 | echo "I: Saving existing fstab" | 129 | echo "I: Saving existing fstab" |
64 | 125 | cp "${target}/etc/fstab" /tmp/fstab.partman | 130 | cp "${target}/etc/fstab" "${FSTAB_PARTMAN}" |
65 | 126 | else | 131 | else |
66 | 127 | echo "W: ${target}/etc/fstab doesn't exist" | 132 | echo "W: ${target}/etc/fstab doesn't exist" |
67 | 128 | fi | 133 | fi |
68 | @@ -156,46 +161,116 @@ prepare_target() { | |||
69 | 156 | done | 161 | done |
70 | 157 | } | 162 | } |
71 | 158 | 163 | ||
72 | 164 | get_layout() { | ||
73 | 165 | # Returns disk, base name of the partition and partition numbers to create | ||
74 | 166 | target="$1" | ||
75 | 167 | |||
76 | 168 | # The entire disk has been formatted with use_device | ||
77 | 169 | # There is either one ext4 partition or one ext4 and one ESP | ||
78 | 170 | part="$(grep -E "\s${target}\s" /proc/mounts | awk '{print $1}')" | ||
79 | 171 | disk="" | ||
80 | 172 | partbase="" | ||
81 | 173 | |||
82 | 174 | if [ -n "${part}" ]; then | ||
83 | 175 | disk="$(lsblk -lns -o TYPE,PATH ${part}| grep disk| awk '{print $2}')" | ||
84 | 176 | if [ -z "${disk}" ]; then | ||
85 | 177 | echo "E: Couldn't identify disk for partition ${part}. Exiting!" | ||
86 | 178 | exit 1 | ||
87 | 179 | fi | ||
88 | 180 | # Some disks have letters in the partition number like /dev/nvme0n1p1 | ||
89 | 181 | # In this case we want to retrieve 'p' so we deal only with partition number | ||
90 | 182 | # in the rest of the script and prepend the base. | ||
91 | 183 | partbase="$(echo ${part} | sed -e 's/[0-9]*$//' | sed -e "s#${disk}##")" | ||
92 | 184 | fi | ||
93 | 185 | |||
94 | 186 | partesp=1 | ||
95 | 187 | if in_efi_mode; then | ||
96 | 188 | # No extended partition on EFI + GPT | ||
97 | 189 | # The layout is | ||
98 | 190 | # 1: ESP | ||
99 | 191 | # 2: swap | ||
100 | 192 | # 3: bpool | ||
101 | 193 | # 4: rpool | ||
102 | 194 | partswap=2 | ||
103 | 195 | partbpool=3 | ||
104 | 196 | partrpool=4 | ||
105 | 197 | else | ||
106 | 198 | # MBR pools are on extended partition | ||
107 | 199 | # The layout is: | ||
108 | 200 | # 1: ESP | ||
109 | 201 | # 2: Extended | ||
110 | 202 | # 5: swap | ||
111 | 203 | # 6: bpool | ||
112 | 204 | # 7: rpool | ||
113 | 205 | partswap=5 | ||
114 | 206 | partbpool=6 | ||
115 | 207 | partrpool=7 | ||
116 | 208 | fi | ||
117 | 209 | |||
118 | 210 | echo "OK|${disk}|${partbase}|${partesp}|${partswap}|${partbpool}|${partrpool}" | ||
119 | 211 | } | ||
120 | 212 | |||
121 | 159 | format_disk() { | 213 | format_disk() { |
122 | 160 | disk="$1" | 214 | disk="$1" |
127 | 161 | partgrub="$2" | 215 | partbase="$2" |
128 | 162 | partbpool="$3" | 216 | partesp="$3" |
129 | 163 | partrpool="$4" | 217 | partbpool="$4" |
130 | 164 | ss="$5" | 218 | partrpool="$5" |
131 | 219 | ss="$6" | ||
132 | 165 | partswap=$(( partbpool - 1 )) | 220 | partswap=$(( partbpool - 1 )) |
134 | 166 | partext=$(( partgrub + 1 )) | 221 | partext=$(( partesp + 1 )) |
135 | 167 | sfdiskopts="" | 222 | sfdiskopts="" |
137 | 168 | partprefix="${disk}${PARTBASE}" | 223 | partprefix="${disk}${partbase}" |
138 | 169 | 224 | ||
140 | 170 | echo "I: Formatting disk $disk with partitions grub:${partgrub} ext:${partext} bpool:${partbpool} rpool:${partrpool}" | 225 | sfdisktmp="${ZSYSTMP}/sfdisk.cfg" |
141 | 226 | rm -f "${sfdisktmp}" | ||
142 | 171 | 227 | ||
144 | 172 | if [ "${IS_EFI}" = "true" ]; then | 228 | echo "I: Formatting disk $disk with partitions ESP:${partesp} ext:${partext} swap:${partswap} bpool:${partbpool} rpool:${partrpool}" |
145 | 173 | 229 | ||
146 | 230 | # bpool size: 500M < 5% of ZFS allocated space < 2G | ||
147 | 231 | # partext4 is the ext4 partition created by partman. | ||
148 | 232 | # Its id is 2 or 1 depending on being on and EFI system of not. | ||
149 | 233 | partext4=1 | ||
150 | 234 | if in_efi_mode; then | ||
151 | 235 | partext4=$(( partesp + 1 )) | ||
152 | 236 | fi | ||
153 | 237 | |||
154 | 238 | size_percent=$(expr \( $(blockdev --getsize64 ${disk}${partext4}) / 1024 / 1024 \) \* 5 / 100) | ||
155 | 239 | bpool_size=500 | ||
156 | 240 | [ ${size_percent} -gt ${bpool_size} ] && bpool_size=${size_percent} | ||
157 | 241 | [ ${bpool_size} -gt 2048 ] && bpool_size=2048 | ||
158 | 242 | |||
159 | 243 | if in_efi_mode; then | ||
160 | 174 | # Improvement: Delete all the partitions but the ESP | 244 | # Improvement: Delete all the partitions but the ESP |
169 | 175 | # We should be only 1 or 2 partittion but well it can be made generic | 245 | # There should be only 1 or 2 partitions but it can be made generic |
170 | 176 | sfdisk --delete "${disk}" ${partgrub} | 246 | sfdisk --delete "${disk}" ${partswap} |
171 | 177 | 247 | ||
172 | 178 | cat > /tmp/sfdisk.cfg <<EOF | 248 | cat > "${sfdisktmp}" <<EOF |
173 | 179 | ${partprefix}${partgrub} : size= 50M, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4 | 249 | ${partprefix}${partswap} : size= ${ss}M, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F |
174 | 180 | ${partprefix}${partswap} : size= ${ss}M, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F | 250 | ${partprefix}${partbpool} : size= ${bpool_size}M, type=6A82CB45-1DD2-11B2-99A6-080020736631 |
175 | 181 | ${partprefix}${partbpool} : size= 2G, type=6A82CB45-1DD2-11B2-99A6-080020736631 | 251 | ${partprefix}${partrpool} : type=6A85CF4D-1DD2-11B2-99A6-080020736631 |
168 | 182 | ${partprefix}${partrpool} : type=6A85CF4D-1DD2-11B2-99A6-080020736631 | ||
176 | 183 | EOF | 252 | EOF |
177 | 184 | sfdiskopts="--append" | 253 | sfdiskopts="--append" |
178 | 185 | else | 254 | else |
187 | 186 | start=$(sfdisk -l "${disk}"|grep "^${partprefix}${partgrub}"|awk '{print $2}') | 255 | if ! esp_exists; then |
188 | 187 | 256 | start=$(sfdisk -l "${disk}"|grep "^${partprefix}${partesp}"|awk '{print $2}') | |
189 | 188 | cat > /tmp/sfdisk.cfg <<EOF | 257 | cat > "${sfdisktmp}" <<EOF |
190 | 189 | ${partprefix}${partgrub} : start= $start, size= 50M, type=83, bootable | 258 | ${partprefix}${partesp} : start= $start, size= 512M, type=ef, bootable |
191 | 190 | ${partprefix}${partext} : type=5 | 259 | EOF |
192 | 191 | ${partprefix}${partswap} : size= ${ss}M, type=82 | 260 | else |
193 | 192 | ${partprefix}${partbpool} : size= 2G, type=a5 | 261 | sfdisk --delete "${disk}" ${partswap} |
194 | 193 | ${partprefix}${partrpool} : type=a5 | 262 | fi |
195 | 263 | |||
196 | 264 | cat >> "${sfdisktmp}" <<EOF | ||
197 | 265 | ${partprefix}${partext} : type=5 | ||
198 | 266 | ${partprefix}${partswap} : size= ${ss}M, type=82 | ||
199 | 267 | ${partprefix}${partbpool} : size= ${bpool_size}M, type=a5 | ||
200 | 268 | ${partprefix}${partrpool} : type=a5 | ||
201 | 194 | EOF | 269 | EOF |
202 | 195 | 270 | ||
203 | 196 | fi | 271 | fi |
204 | 197 | 272 | ||
206 | 198 | cat /tmp/sfdisk.cfg | sfdisk ${sfdiskopts} "${disk}" | 273 | cat "${sfdisktmp}" | sfdisk ${sfdiskopts} "${disk}" |
207 | 199 | 274 | ||
208 | 200 | # Force a re-read of the partition table | 275 | # Force a re-read of the partition table |
209 | 201 | echo "I: Re-reading partition table" | 276 | echo "I: Re-reading partition table" |
210 | @@ -228,12 +303,26 @@ init_zfs() { | |||
211 | 228 | -O mountpoint=/ -R "${target}" rpool "${partrpool}" | 303 | -O mountpoint=/ -R "${target}" rpool "${partrpool}" |
212 | 229 | 304 | ||
213 | 230 | # bpool | 305 | # bpool |
214 | 306 | # The version of bpool is set to the default version to prevent users from upgrading | ||
215 | 307 | # Then only features supported by grub are enabled. | ||
216 | 231 | zpool create -f \ | 308 | zpool create -f \ |
217 | 232 | -o version=28 \ | ||
218 | 233 | -o ashift=12 \ | 309 | -o ashift=12 \ |
219 | 234 | -d \ | 310 | -d \ |
221 | 235 | -O xattr=sa \ | 311 | -o feature@async_destroy=enabled \ |
222 | 312 | -o feature@bookmarks=enabled \ | ||
223 | 313 | -o feature@embedded_data=enabled \ | ||
224 | 314 | -o feature@empty_bpobj=enabled \ | ||
225 | 315 | -o feature@enabled_txg=enabled \ | ||
226 | 316 | -o feature@extensible_dataset=enabled \ | ||
227 | 317 | -o feature@filesystem_limits=enabled \ | ||
228 | 318 | -o feature@hole_birth=enabled \ | ||
229 | 319 | -o feature@large_blocks=enabled \ | ||
230 | 320 | -o feature@lz4_compress=enabled \ | ||
231 | 321 | -o feature@spacemap_histogram=enabled \ | ||
232 | 322 | -o feature@userobj_accounting=enabled \ | ||
233 | 323 | -O compression=lz4 \ | ||
234 | 236 | -O acltype=posixacl \ | 324 | -O acltype=posixacl \ |
235 | 325 | -O xattr=sa \ | ||
236 | 237 | -O relatime=on \ | 326 | -O relatime=on \ |
237 | 238 | -O normalization=formD \ | 327 | -O normalization=formD \ |
238 | 239 | -O canmount=off \ | 328 | -O canmount=off \ |
239 | @@ -297,18 +386,27 @@ init_system_partitions() { | |||
240 | 297 | partefi="$2" | 386 | partefi="$2" |
241 | 298 | partgrub="$3" | 387 | partgrub="$3" |
242 | 299 | 388 | ||
244 | 300 | echo "I: Creating grub partition $partgrub" | 389 | # ESP |
245 | 390 | mkdir -p "${target}/boot/efi" | ||
246 | 391 | if ! in_efi_mode; then | ||
247 | 392 | echo "I: Creating ESP" | ||
248 | 393 | mkfs.vfat "${partefi}" | ||
249 | 394 | fi | ||
250 | 395 | mount -t vfat "${partefi}" "${target}/boot/efi" | ||
251 | 396 | mkdir -p "${target}/boot/efi/grub" | ||
252 | 397 | |||
253 | 398 | echo "I: Mount grub directory" | ||
254 | 301 | # Finalize grub directory | 399 | # Finalize grub directory |
255 | 302 | mkdir -p "${target}/boot/grub" | 400 | mkdir -p "${target}/boot/grub" |
265 | 303 | mke2fs -F -t ext4 "${partgrub}" | 401 | mount -o bind "${target}/boot/efi/grub" "${target}/boot/grub" |
266 | 304 | mount -t ext4 "${partgrub}" "${target}/boot/grub" | 402 | } |
267 | 305 | 403 | ||
268 | 306 | if [ "${IS_EFI}" = "true" ]; then | 404 | in_efi_mode() { |
269 | 307 | # ESP | 405 | [ -d /proc/efi ] || [ -d /sys/firmware/efi ] |
270 | 308 | mkdir -p "${target}/boot/efi" | 406 | } |
271 | 309 | # No need to reformat the partition has been prepared by partman-efi | 407 | |
272 | 310 | mount -t vfat "${partefi}" "${target}/boot/efi" | 408 | esp_exists() { |
273 | 311 | fi | 409 | grep -q "\s${ESP}\s" /proc/mounts |
274 | 312 | } | 410 | } |
275 | 313 | 411 | ||
276 | 314 | check_prerequisites ${REQUIREDPKGS} | 412 | check_prerequisites ${REQUIREDPKGS} |
277 | @@ -318,57 +416,48 @@ echo "I: Running $(basename "$0") ${COMMAND}" | |||
278 | 318 | if [ -z "${COMMAND}" ]; then | 416 | if [ -z "${COMMAND}" ]; then |
279 | 319 | echo "E: ${COMMAND} is mandatory. Exiting!" | 417 | echo "E: ${COMMAND} is mandatory. Exiting!" |
280 | 320 | exit 1 | 418 | exit 1 |
285 | 321 | elif [ "${COMMAND}" = "init" ]; then | 419 | elif [ "${COMMAND}" = "layout" ]; then |
286 | 322 | # The entire disk has been formatted with use_device | 420 | # Just displays de layout that will be created without any change to the disk. |
287 | 323 | # There is either one ext4 partition or one ext4 and one ESP | 421 | # At this stage we don't now yet the size of the partition that will be created. |
288 | 324 | PART=$(grep -E "\s${TARGET}\s" /proc/mounts | awk '{print $1}') | 422 | IFS="|" read ERR DISK PARTBASE PARTESP PARTSWAP PARTBPOOL PARTRPOOL<<EOF |
289 | 423 | $(get_layout ${TARGET}) | ||
290 | 424 | EOF | ||
291 | 325 | 425 | ||
294 | 326 | if [ -z "${PART}" ]; then | 426 | if [ "${ERR}" != "OK" ]; then |
295 | 327 | echo "E: Couldn't identify partition matching ${TARGET}. Exiting!" | 427 | echo "${ERR}" |
296 | 328 | exit 1 | 428 | exit 1 |
297 | 329 | fi | 429 | fi |
298 | 330 | 430 | ||
300 | 331 | DISK="$(lsblk -lns -o TYPE,PATH ${PART}| grep disk| awk '{print $2}')" | 431 | cat > "${PARTITION_LAYOUT}" <<EOF |
301 | 432 | disk:${DISK} | ||
302 | 433 | EOF | ||
303 | 434 | if ! in_efi_mode || ! esp_exists; then | ||
304 | 435 | cat >> "${PARTITION_LAYOUT}" <<EOF | ||
305 | 436 | part:vfat:ESP:${DISK}${PARTBASE}${PARTESP} | ||
306 | 437 | EOF | ||
307 | 438 | fi | ||
308 | 332 | 439 | ||
311 | 333 | echo "I: Partition table before init of ZFS" | 440 | cat >> "${PARTITION_LAYOUT}" <<EOF |
312 | 334 | partx --show "${DISK}" | 441 | part:swap:swap:${DISK}${PARTBASE}${PARTSWAP} |
313 | 442 | part:zfs:bpool:${DISK}${PARTBASE}${PARTBPOOL} | ||
314 | 443 | part:zfs:rpool:${DISK}${PARTBASE}${PARTRPOOL} | ||
315 | 444 | EOF | ||
316 | 335 | 445 | ||
321 | 336 | # Some disks have letters in the partion number like /dev/nvme0n1p1 | 446 | elif [ "${COMMAND}" = "init" ]; then |
322 | 337 | # In this case we want to retrieve 'p' so we deal only with partition number | 447 | rm -f "${INIT_FLAG}" |
319 | 338 | # in the rest of the script and prepend the base. | ||
320 | 339 | PARTBASE="$(echo ${PART} | sed -e 's/[0-9]*$//' | sed -e "s#${DISK}##")" | ||
323 | 340 | 448 | ||
329 | 341 | # Better check if the ESP has been created than if it's a EFI system | 449 | IFS="|" read ERR DISK PARTBASE PARTESP PARTSWAP PARTBPOOL PARTRPOOL<<EOF |
330 | 342 | IS_EFI="false" | 450 | $(get_layout ${TARGET}) |
331 | 343 | if grep -q "\s${ESP}\s" /proc/mounts; then | 451 | EOF |
327 | 344 | IS_EFI="true" | ||
328 | 345 | fi | ||
332 | 346 | 452 | ||
356 | 347 | PARTGRUB=$(lsblk -n -o TYPE ${DISK}|grep ^part| wc -l) | 453 | if [ "${ERR}" != "OK" ]; then |
357 | 348 | if [ "$IS_EFI" = "true" ]; then | 454 | echo "${ERR}" |
358 | 349 | # No extended partition on EFI + GPT | 455 | exit 1 |
336 | 350 | # The layout is | ||
337 | 351 | # 1: ESP | ||
338 | 352 | # 2: grub | ||
339 | 353 | # 3: swap | ||
340 | 354 | # 4: bpool | ||
341 | 355 | # 5: rpool | ||
342 | 356 | PARTSWAP=3 | ||
343 | 357 | PARTBPOOL=4 | ||
344 | 358 | PARTRPOOL=5 | ||
345 | 359 | else | ||
346 | 360 | # MBR pools are on extended partition | ||
347 | 361 | # The layout is: | ||
348 | 362 | # 1: grub | ||
349 | 363 | # 2: Extended | ||
350 | 364 | # 5: swap | ||
351 | 365 | # 6: bpool | ||
352 | 366 | # 7: rpool | ||
353 | 367 | PARTSWAP=5 | ||
354 | 368 | PARTBPOOL=6 | ||
355 | 369 | PARTRPOOL=7 | ||
359 | 370 | fi | 456 | fi |
360 | 371 | 457 | ||
361 | 458 | echo "I: Partition table before init of ZFS" | ||
362 | 459 | partx --show "${DISK}" | ||
363 | 460 | |||
364 | 372 | # Swap files are not supported on ZFS, we use a swap partition instead: | 461 | # Swap files are not supported on ZFS, we use a swap partition instead: |
365 | 373 | SWAPFILE="$(grep "^${TARGET}" /proc/swaps |awk '{print $1}')" | 462 | SWAPFILE="$(grep "^${TARGET}" /proc/swaps |awk '{print $1}')" |
366 | 374 | # Give us a minimum swap partition size of 4MB in case we decide on | 463 | # Give us a minimum swap partition size of 4MB in case we decide on |
367 | @@ -385,20 +474,26 @@ elif [ "${COMMAND}" = "init" ]; then | |||
368 | 385 | SWAPVOLSIZE=$(( SWAPSIZE / 1024 / 1024 )) | 474 | SWAPVOLSIZE=$(( SWAPSIZE / 1024 / 1024 )) |
369 | 386 | 475 | ||
370 | 387 | prepare_target "${TARGET}" | 476 | prepare_target "${TARGET}" |
372 | 388 | format_disk "${DISK}" "${PARTGRUB}" "${PARTBPOOL}" "${PARTRPOOL}" "${SWAPVOLSIZE}" | 477 | format_disk "${DISK}" "${PARTBASE}" "${PARTESP}" "${PARTBPOOL}" "${PARTRPOOL}" "${SWAPVOLSIZE}" |
373 | 389 | init_zfs "${TARGET}" "${DISK}${PARTBASE}${PARTBPOOL}" "${DISK}${PARTBASE}${PARTRPOOL}" | 478 | init_zfs "${TARGET}" "${DISK}${PARTBASE}${PARTBPOOL}" "${DISK}${PARTBASE}${PARTRPOOL}" |
375 | 390 | init_system_partitions "${TARGET}" "${DISK}${PARTBASE}1" "${DISK}${PARTBASE}${PARTGRUB}" | 479 | init_system_partitions "${TARGET}" "${DISK}${PARTBASE}1" "${DISK}${PARTBASE}${PARTESP}" |
376 | 391 | 480 | ||
377 | 392 | # Generate fstab | 481 | # Generate fstab |
378 | 393 | # $TARGET/etc has been destroyed by the creation of the zfs partitition | 482 | # $TARGET/etc has been destroyed by the creation of the zfs partitition |
379 | 394 | # Recreate it | 483 | # Recreate it |
380 | 395 | mkdir -p "${TARGET}/etc" | 484 | mkdir -p "${TARGET}/etc" |
382 | 396 | if [ -f /tmp/fstab.partman ]; then | 485 | if [ -f "${FSTAB_PARTMAN}" ]; then |
383 | 397 | echo "I: Creating fstab" | 486 | echo "I: Creating fstab" |
385 | 398 | grep -Ev '\s/\s|/swapfile' /tmp/fstab.partman > "${TARGET}/etc/fstab" | 487 | grep -Ev '\s/\s|/swapfile' "${FSTAB_PARTMAN}" > "${TARGET}/etc/fstab" |
386 | 488 | fi | ||
387 | 489 | |||
388 | 490 | if ! grep -q "boot/efi" "${TARGET}/etc/fstab"; then | ||
389 | 491 | espuuid=$(blkid -s UUID -o value "${DISK}${PARTBASE}${PARTESP}") | ||
390 | 492 | echo "UUID=${espuuid}\t/boot/efi\tvfat\tumask=0077\t0\t1" >> "${TARGET}/etc/fstab" | ||
391 | 399 | fi | 493 | fi |
394 | 400 | grubuuid=$(blkid -s UUID -o value "${DISK}${PARTBASE}${PARTGRUB}") | 494 | |
395 | 401 | echo "UUID=${grubuuid}\t/boot/grub\text4\terrors=remount-ro\t0\t1" >> "${TARGET}/etc/fstab" | 495 | # Bind mount grub from ESP to the expected location |
396 | 496 | echo "/boot/efi/grub\t/boot/grub\tnone\tdefaults,bind\t0\t0" >> "${TARGET}/etc/fstab" | ||
397 | 402 | 497 | ||
398 | 403 | if [ -n "${SWAPFILE}" ]; then | 498 | if [ -n "${SWAPFILE}" ]; then |
399 | 404 | SWAPDEVICE="${DISK}${PARTBASE}${PARTSWAP}" | 499 | SWAPDEVICE="${DISK}${PARTBASE}${PARTSWAP}" |
400 | diff --git a/ubiquity/plugins/ubi-partman.py b/ubiquity/plugins/ubi-partman.py | |||
401 | index 5601d7d..086ac2b 100644 | |||
402 | --- a/ubiquity/plugins/ubi-partman.py | |||
403 | +++ b/ubiquity/plugins/ubi-partman.py | |||
404 | @@ -3215,9 +3215,15 @@ class Page(plugin.Plugin): | |||
405 | 3215 | raise AssertionError("Arrived at %s unexpectedly" % question) | 3215 | raise AssertionError("Arrived at %s unexpectedly" % question) |
406 | 3216 | 3216 | ||
407 | 3217 | elif question.startswith('partman/confirm'): | 3217 | elif question.startswith('partman/confirm'): |
408 | 3218 | description = self.extended_description(question) | ||
409 | 3219 | |||
410 | 3220 | if hasattr(self.ui, "use_zfs"): | ||
411 | 3221 | if (self.ui.use_zfs.get_active() and self.ui.use_device.get_active()): | ||
412 | 3222 | description = self.update_zfs_description(self.extended_description(question)) | ||
413 | 3223 | |||
414 | 3218 | response = self.frontend.question_dialog( | 3224 | response = self.frontend.question_dialog( |
415 | 3219 | self.description(question), | 3225 | self.description(question), |
417 | 3220 | self.extended_description(question), | 3226 | description, |
418 | 3221 | ('ubiquity/text/go_back', 'ubiquity/text/continue')) | 3227 | ('ubiquity/text/go_back', 'ubiquity/text/continue')) |
419 | 3222 | if response == 'ubiquity/text/continue': | 3228 | if response == 'ubiquity/text/continue': |
420 | 3223 | self.db.set('ubiquity/partman-confirm', question[8:]) | 3229 | self.db.set('ubiquity/partman-confirm', question[8:]) |
421 | @@ -3293,6 +3299,40 @@ class Page(plugin.Plugin): | |||
422 | 3293 | 3299 | ||
423 | 3294 | return plugin.Plugin.run(self, priority, question) | 3300 | return plugin.Plugin.run(self, priority, question) |
424 | 3295 | 3301 | ||
425 | 3302 | def update_zfs_description(self, description): | ||
426 | 3303 | """Update the description in the partman dialog to display custom | ||
427 | 3304 | messages""" | ||
428 | 3305 | |||
429 | 3306 | misc.execute_root('/usr/share/ubiquity/zsys-setup', 'layout') | ||
430 | 3307 | |||
431 | 3308 | zsys_layout = '/tmp/zsys-setup/layout' | ||
432 | 3309 | lines = description.splitlines() | ||
433 | 3310 | # Remove the last line of the output from partman which corresponds to | ||
434 | 3311 | # the ext4 partition | ||
435 | 3312 | del(lines[-1]) | ||
436 | 3313 | |||
437 | 3314 | if not os.path.exists(zsys_layout): | ||
438 | 3315 | return description | ||
439 | 3316 | |||
440 | 3317 | with open(zsys_layout, 'r') as f: | ||
441 | 3318 | layout = f.readlines() | ||
442 | 3319 | |||
443 | 3320 | partlabel = misc.utf8(self.db.metaget('ubiquity/text/partman_confirm_zfs', 'extended_description'), | ||
444 | 3321 | errors='replace') | ||
445 | 3322 | for line in layout: | ||
446 | 3323 | if not line.startswith("part:"): | ||
447 | 3324 | continue | ||
448 | 3325 | |||
449 | 3326 | line = line.strip() | ||
450 | 3327 | (t, f, u, p) = line.split(':') | ||
451 | 3328 | |||
452 | 3329 | lines.append(" " + partlabel % { | ||
453 | 3330 | 'partid': os.path.basename(p), | ||
454 | 3331 | 'parttype': f, | ||
455 | 3332 | 'partusage': u}) | ||
456 | 3333 | |||
457 | 3334 | return "\n".join(lines) | ||
458 | 3335 | |||
459 | 3296 | def ok_handler(self): | 3336 | def ok_handler(self): |
460 | 3297 | if self.install_bootloader and not self.is_bootdev_preseeded(): | 3337 | if self.install_bootloader and not self.is_bootdev_preseeded(): |
461 | 3298 | self.preseed('grub-installer/bootdev', self.ui.get_grub_choice()) | 3338 | self.preseed('grub-installer/bootdev', self.ui.get_grub_choice()) |
I didn't test yet as we are going to have some iterations. Here are mostly nitpick, good work :)