summaryrefslogtreecommitdiffstats
path: root/patches/opnfv-fuel/0051-EFI-Add-basic-support-for-U-EFI.patch
blob: d45d4f29cade0d906d4560aedce5df948cac77f2 (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
From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Date: Sun, 28 Aug 2016 00:28:53 +0200
Subject: [PATCH] EFI: Add basic support for (U)EFI

This change introduces basic EFI support in <fuel-astute> and
<fuel-agent>, by patching them at build time with:
- ESP partition flag;
- VFAT filesytem on ESP;
- clearing "ubuntu" boot entry created by Trusty's grub-install;

This change DOES NOT provide an x86 (U)EFI netloader for integration
with cobbler.

Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
---
 .../0010-EFI-Erase-boot-entry-on-EFI-systems.patch | 43 ++++++++++++++
 .../0010-EFI-Add-esp-partition-flag.patch          | 48 ++++++++++++++++
 .../0020-EFI-Add-fs-for-efi-partition.patch        | 66 ++++++++++++++++++++++
 3 files changed, 157 insertions(+)
 create mode 100644 build/patch-repos/build/repos/astute/0010-EFI-Erase-boot-entry-on-EFI-systems.patch
 create mode 100644 build/patch-repos/build/repos/fuel-agent/0010-EFI-Add-esp-partition-flag.patch
 create mode 100644 build/patch-repos/build/repos/fuel-agent/0020-EFI-Add-fs-for-efi-partition.patch

diff --git a/build/patch-repos/build/repos/astute/0010-EFI-Erase-boot-entry-on-EFI-systems.patch b/build/patch-repos/build/repos/astute/0010-EFI-Erase-boot-entry-on-EFI-systems.patch
new file mode 100644
index 0000000..fa925b0
--- /dev/null
+++ b/build/patch-repos/build/repos/astute/0010-EFI-Erase-boot-entry-on-EFI-systems.patch
@@ -0,0 +1,43 @@
+From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+Date: Mon, 18 Jul 2016 16:02:20 +0200
+Subject: [PATCH] EFI: Erase boot entry on EFI systems.
+
+On EFI-enabled systemd, grub-install from grub-efi-* package
+installs a boot entry named "ubuntu".
+
+Since this boot entry is saved in board flash memory, erasing
+the MBR bootloader code and/or partition signature will not
+clear the ubuntu boot entry, leaving it pointing to a loader
+on the ESP (EFI System Partition) that will try to load the
+kernel/initrd from an erased partition.
+
+In Fuel 8.0, the whole disk was erased, so the ubuntu EFI boot
+entry was skipped due to missing ESP, while for Fuel 9.0 and
+above we have to explicitly remove it to keep the system in a
+sane state.
+
+Note: efibootmgr is installed automatically on EFI systems
+as a dependency of grub-efi-*.
+
+Closes: ARMBAND-47
+
+Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+---
+ mcagents/erase_node.rb | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/mcagents/erase_node.rb b/mcagents/erase_node.rb
+index 3eb98e8..3bac36f 100644
+--- a/mcagents/erase_node.rb
++++ b/mcagents/erase_node.rb
+@@ -112,6 +112,10 @@ module MCollective
+         File.open('/proc/sys/kernel/panic','w') {|file| file.write("10\n")}
+ 
+         begin
++          # clear out EFI boot entry on EFI-enabled systems
++          system("(which efibootmgr > /dev/null 2>&1 && efibootmgr | "\
++                 "grep -oP '(?<=Boot)[0-9]+(?=.*ubuntu)' | "\
++                 "xargs -I{} efibootmgr --delete-bootnum --bootnum {}) || true")
+           get_devices(type='all').each do |dev|
+             debug_msg("erasing bootstrap code area in MBR of #{dev[:name]}")
+             # clear out the boot code in MBR
diff --git a/build/patch-repos/build/repos/fuel-agent/0010-EFI-Add-esp-partition-flag.patch b/build/patch-repos/build/repos/fuel-agent/0010-EFI-Add-esp-partition-flag.patch
new file mode 100644
index 0000000..ac94a4f
--- /dev/null
+++ b/build/patch-repos/build/repos/fuel-agent/0010-EFI-Add-esp-partition-flag.patch
@@ -0,0 +1,48 @@
+From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+Date: Tue, 8 Mar 2016 16:29:39 +0100
+Subject: [PATCH] EFI: Add <esp> partition flag.
+
+Parted flag <esp> (see [1]) will mark EFI system partition, allowing us
+to properly format and mount it during do_partitioning deployment phase.
+
+[1] https://www.gnu.org/software/parted/manual/html_node/set.html
+---
+ fuel_agent/drivers/nailgun.py | 2 +-
+ fuel_agent/utils/partition.py | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/fuel_agent/drivers/nailgun.py b/fuel_agent/drivers/nailgun.py
+index c2fef69..0ae81f9 100644
+--- a/fuel_agent/drivers/nailgun.py
++++ b/fuel_agent/drivers/nailgun.py
+@@ -324,7 +324,7 @@ class Nailgun(BaseDataDriver):
+             # uefi partition (for future use)
+             LOG.debug('Adding UEFI partition on disk %s: size=200' %
+                       disk['name'])
+-            parted.add_partition(size=200)
++            parted.add_partition(size=200, flags=['esp'])
+ 
+             LOG.debug('Looping over all volumes on disk %s' % disk['name'])
+             for volume in disk['volumes']:
+diff --git a/fuel_agent/utils/partition.py b/fuel_agent/utils/partition.py
+index acdd0b3..86349d2 100644
+--- a/fuel_agent/utils/partition.py
++++ b/fuel_agent/utils/partition.py
+@@ -93,7 +93,7 @@ def set_partition_flag(dev, num, flag, state='on'):
+     :param dev: A device file, e.g. /dev/sda.
+     :param num: Partition number
+     :param flag: Flag name. Must be one of 'bios_grub', 'legacy_boot',
+-    'boot', 'raid', 'lvm'
++    'boot', 'raid', 'lvm', 'esp'
+     :param state: Desiable flag state. 'on' or 'off'. Default is 'on'.
+ 
+     :returns: None
+@@ -103,7 +103,7 @@ def set_partition_flag(dev, num, flag, state='on'):
+     # parted supports more flags but we are interested in
+     # setting only this subset of them.
+     # not all of these flags are compatible with one another.
+-    if flag not in ('bios_grub', 'legacy_boot', 'boot', 'raid', 'lvm'):
++    if flag not in ('bios_grub', 'legacy_boot', 'boot', 'raid', 'lvm', 'esp'):
+         raise errors.WrongPartitionSchemeError(
+             'Unsupported partition flag: %s' % flag)
+     if state not in ('on', 'off'):
diff --git a/build/patch-repos/build/repos/fuel-agent/0020-EFI-Add-fs-for-efi-partition.patch b/build/patch-repos/build/repos/fuel-agent/0020-EFI-Add-fs-for-efi-partition.patch
new file mode 100644
index 0000000..a3767a1
--- /dev/null
+++ b/build/patch-repos/build/repos/fuel-agent/0020-EFI-Add-fs-for-efi-partition.patch
@@ -0,0 +1,66 @@
+From: Stanislaw Kardach <stanislaw.kardach@cavium.com>
+Date: Tue, 8 Mar 2016 21:08:55 +0100
+Subject: [PATCH] EFI: Add fs for efi partition
+
+---
+ debian/control                |  1 +
+ fuel_agent/drivers/nailgun.py | 13 ++++++++++---
+ specs/fuel-agent.spec         |  1 +
+ 3 files changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/debian/control b/debian/control
+index 189dc00..acfda35 100644
+--- a/debian/control
++++ b/debian/control
+@@ -39,6 +39,7 @@ Depends: bzip2,
+ 	 qemu-user-static,
+ 	 binfmt-support,
+ 	 dmidecode,
++	 dosfstools,
+ 	 ethtool,
+ 	 gdisk,
+ 	 genisoimage,
+diff --git a/fuel_agent/drivers/nailgun.py b/fuel_agent/drivers/nailgun.py
+index bc532b4..f092865 100644
+--- a/fuel_agent/drivers/nailgun.py
++++ b/fuel_agent/drivers/nailgun.py
+@@ -81,6 +81,9 @@ class Nailgun(BaseDataDriver):
+         # was already allocated on first matching volume
+         # or not
+         self._boot_partition_done = False
++        # this var states whether ESP partition was already
++        # allocated on the first matching volume or not
++        self._esp_partition_done = False
+         # this var is used as a flag that /boot fs
+         # has already been added. we need this to
+         # get rid of md over all disks for /boot partition.
+@@ -321,10 +324,14 @@ class Nailgun(BaseDataDriver):
+             LOG.debug('Adding bios_grub partition on disk %s: size=24' %
+                       disk['name'])
+             parted.add_partition(size=24, flags=['bios_grub'])
+-            # uefi partition (for future use)
+-            LOG.debug('Adding UEFI partition on disk %s: size=200' %
++            # uefi partition - added only once.
++            if self._is_boot_disk(disk) and not self._esp_partition_done:
++                LOG.debug('Adding UEFI partition on disk %s: size=200' %
+                       disk['name'])
+-            parted.add_partition(size=200, flags=['esp'])
++                prt = parted.add_partition(size=200, flags=['esp'])
++                partition_scheme.add_fs(device=prt.name, mount='/boot/efi',
++                                        fs_type='vfat')
++                self._esp_partition_done = True
+ 
+             LOG.debug('Looping over all volumes on disk %s' % disk['name'])
+             for volume in disk['volumes']:
+diff --git a/specs/fuel-agent.spec b/specs/fuel-agent.spec
+index a43f693..c2b9b51 100644
+--- a/specs/fuel-agent.spec
++++ b/specs/fuel-agent.spec
+@@ -50,6 +50,7 @@ Requires:    xfsprogs
+ Requires:    pciutils
+ Requires:    ethtool
+ Requires:    debootstrap
++Requires:    dosfstools
+ Requires:    dpkg
+ Requires:    qemu-user-static
+ Requires:    xz