Skip to content

Commit cc5556d

Browse files
derekhigginsjuliakreger
authored andcommitted
Install grub in the EFI "Fallback path"
In systems where the nvram may have been reset, add \EFI\BOOT\BOOTx64.EFI to the EFI system partition so that the image continues to boot. This will be particularly useful if the NVRAM wasn't written correctly or if the baremetal server is be simulated on virt and the NVRAM was been reset on start (as is the case in libvirt). Change-Id: I5005ae02c283cdc01540ea46c341a7b0bf9d4c42 Closes-Bug: #1632637
1 parent 6490425 commit cc5556d

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

ironic_python_agent/extensions/image.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,19 @@ def _install_grub2(device, root_uuid, efi_system_part_uuid=None):
118118
'"/usr/sbin/%(bin)s-install %(dev)s"' %
119119
{'path': path, 'bin': binary_name, 'dev': device},
120120
shell=True, env_variables={'PATH': path_variable})
121+
# Also run grub-install with --removable, this installs grub to the
122+
# EFI fallback path. Useful if the NVRAM wasn't written correctly,
123+
# was reset or if testing with virt as libvirt resets the NVRAM
124+
# on instance start.
125+
# This operation is essentially a copy operation. Use of the
126+
# --removable flag, per the grub-install source code changes
127+
# the default file to be copied, destination file name, and
128+
# prevents NVRAM from being updated.
129+
if efi_partition:
130+
utils.execute('chroot %(path)s /bin/bash -c '
131+
'"/usr/sbin/%(bin)s-install %(dev)s --removable"' %
132+
{'path': path, 'bin': binary_name, 'dev': device},
133+
shell=True, env_variables={'PATH': path_variable})
121134

122135
# Generate the grub configuration file
123136
utils.execute('chroot %(path)s /bin/bash -c '

ironic_python_agent/tests/unit/extensions/test_image.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ def test__install_grub2_uefi(self, mock_get_part_uuid, mkdir_mock,
137137
'"/usr/sbin/grub-install %s"' %
138138
(self.fake_dir, self.fake_dev)), shell=True,
139139
env_variables={'PATH': '/sbin:/bin'}),
140+
mock.call(('chroot %s /bin/bash -c '
141+
'"/usr/sbin/grub-install %s --removable"' %
142+
(self.fake_dir, self.fake_dev)), shell=True,
143+
env_variables={'PATH': '/sbin:/bin'}),
140144
mock.call(('chroot %s /bin/bash -c '
141145
'"/usr/sbin/grub-mkconfig -o '
142146
'/boot/grub/grub.cfg"' % self.fake_dir),
@@ -193,6 +197,10 @@ def umount_raise_func(*args, **kwargs):
193197
'"/usr/sbin/grub-install %s"' %
194198
(self.fake_dir, self.fake_dev)), shell=True,
195199
env_variables={'PATH': '/sbin:/bin'}),
200+
mock.call(('chroot %s /bin/bash -c '
201+
'"/usr/sbin/grub-install %s --removable"' %
202+
(self.fake_dir, self.fake_dev)), shell=True,
203+
env_variables={'PATH': '/sbin:/bin'}),
196204
mock.call(('chroot %s /bin/bash -c '
197205
'"/usr/sbin/grub-mkconfig -o '
198206
'/boot/grub/grub.cfg"' % self.fake_dir),
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- The ironic-python-agent when writing a partition image now
4+
installs grub to the UEFI fallback path. e.g. EFI/BOOT/BOOTX64.EFI
5+
The fallback path is used to boot the bare metal node if the NVRAM is
6+
reset.

0 commit comments

Comments
 (0)