Merge ~jibel/ubiquity:lp1856863_2TB_drives_use_gpt into ubiquity:master

Proposed by Jean-Baptiste Lallement
Status: Merged
Approved by: Jean-Baptiste Lallement
Approved revision: 41a3b48a4cc4778da99c94c3bdd59671cabe1dab
Merged at revision: 41a3b48a4cc4778da99c94c3bdd59671cabe1dab
Proposed branch: ~jibel/ubiquity:lp1856863_2TB_drives_use_gpt
Merge into: ubiquity:master
Diff against target: 87 lines (+28/-8)
2 files modified
debian/changelog (+9/-0)
scripts/zsys-setup (+19/-8)
Reviewer Review Type Date Requested Status
Didier Roche-Tolomelli (community) Approve
Ubuntu Installer Team Pending
Review via email: mp+377179@code.launchpad.net

Commit message

Drives bigger than 2TB use GPT but if the machine has been booted in legacy mode the ESP is not created. Rely on the label type instead of the firmware to know how to partition the disk (LP: #1856863)

To post a comment you must log in.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

2 small comments but the overall logic LGTM.

review: Needs Information
Revision history for this message
Jean-Baptiste Lallement (jibel) :
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

MP updated following your comments

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

ack on the comment and the changes. LGTM. I didn't test myself but I think you did try it. It would be good to land that to have it in a daily. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 9fdb914..89c009a 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,12 @@
6+ubiquity (20.04.5) UNRELEASED; urgency=medium
7+
8+ * zsys-setup: Drives bigger than 2TB use GPT but if the machine has been
9+ booted in legacy mode the ESP is not created. Rely on the label type
10+ instead of the firmware to know how to partition the disk (LP: #1856863).
11+ Thanks to Pablo Mendez Hernandez for the investigation.
12+
13+ -- Jean-Baptiste Lallement <jean-baptiste.lallement@ubuntu.com> Mon, 06 Jan 2020 14:34:31 +0100
14+
15 ubiquity (20.04.4) focal; urgency=medium
16
17 * When removing packages, also remove automatically installed packages that
18diff --git a/scripts/zsys-setup b/scripts/zsys-setup
19index fcd0a49..30e2898 100755
20--- a/scripts/zsys-setup
21+++ b/scripts/zsys-setup
22@@ -184,7 +184,7 @@ get_layout() {
23 fi
24
25 partesp=1
26- if in_efi_mode; then
27+ if is_gpt "${disk}"; then
28 # No extended partition on EFI + GPT
29 # The layout is
30 # 1: ESP
31@@ -240,22 +240,29 @@ format_disk() {
32 [ ${size_percent} -gt ${bpool_size} ] && bpool_size=${size_percent}
33 [ ${bpool_size} -gt 2048 ] && bpool_size=2048
34
35- if in_efi_mode; then
36+ if is_gpt "${disk}"; then
37 # Improvement: Delete all the partitions but the ESP
38 # There should be only 1 or 2 partitions but it can be made generic
39- sfdisk --delete "${disk}" ${partswap}
40+ if ! esp_exists "${disk}"; then
41+ start=$(sfdisk -l "${disk}"|grep "^${partprefix}${partesp}"|awk '{print $2}')
42+ cat > "${sfdisktmp}" <<EOF
43+${partprefix}${partesp} : start= ${start}, size= 512M, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, bootable
44+EOF
45+ else
46+ sfdisk --delete "${disk}" ${partswap}
47+ fi
48
49- cat > "${sfdisktmp}" <<EOF
50+ cat >> "${sfdisktmp}" <<EOF
51 ${partprefix}${partswap} : size= ${ss}M, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
52 ${partprefix}${partbpool} : size= ${bpool_size}M, type=6A82CB45-1DD2-11B2-99A6-080020736631
53 ${partprefix}${partrpool} : type=6A85CF4D-1DD2-11B2-99A6-080020736631
54 EOF
55 sfdiskopts="--append"
56 else
57- if ! esp_exists; then
58+ if ! esp_exists "${disk}"; then
59 start=$(sfdisk -l "${disk}"|grep "^${partprefix}${partesp}"|awk '{print $2}')
60 cat > "${sfdisktmp}" <<EOF
61-${partprefix}${partesp} : start= $start, size= 512M, type=ef, bootable
62+${partprefix}${partesp} : start= ${start}, size= 512M, type=ef, bootable
63 EOF
64 else
65 sfdisk --delete "${disk}" ${partswap}
66@@ -406,7 +413,11 @@ in_efi_mode() {
67 }
68
69 esp_exists() {
70- grep -q "\s${ESP}\s" /proc/mounts
71+ sfdisk -d "${1}" | grep -q 'type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B'
72+}
73+
74+is_gpt() {
75+ sfdisk -d "${1}" | awk '/^label:/ {print $2}'|grep -q gpt
76 }
77
78 check_prerequisites ${REQUIREDPKGS}
79@@ -431,7 +442,7 @@ EOF
80 cat > "${PARTITION_LAYOUT}" <<EOF
81 disk:${DISK}
82 EOF
83- if ! in_efi_mode || ! esp_exists; then
84+ if ! in_efi_mode || ! esp_exists "${DISK}"; then
85 cat >> "${PARTITION_LAYOUT}" <<EOF
86 part:vfat:ESP:${DISK}${PARTBASE}${PARTESP}
87 EOF

Subscribers

People subscribed via source and target branches