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
This commit is contained in:
Derek Higgins 2016-10-11 12:52:43 +01:00 committed by Julia Kreger
parent 6490425b5b
commit cc5556d06b
3 changed files with 27 additions and 0 deletions

View File

@ -118,6 +118,19 @@ def _install_grub2(device, root_uuid, efi_system_part_uuid=None):
'"/usr/sbin/%(bin)s-install %(dev)s"' %
{'path': path, 'bin': binary_name, 'dev': device},
shell=True, env_variables={'PATH': path_variable})
# Also run grub-install with --removable, this installs grub to the
# EFI fallback path. Useful if the NVRAM wasn't written correctly,
# was reset or if testing with virt as libvirt resets the NVRAM
# on instance start.
# This operation is essentially a copy operation. Use of the
# --removable flag, per the grub-install source code changes
# the default file to be copied, destination file name, and
# prevents NVRAM from being updated.
if efi_partition:
utils.execute('chroot %(path)s /bin/bash -c '
'"/usr/sbin/%(bin)s-install %(dev)s --removable"' %
{'path': path, 'bin': binary_name, 'dev': device},
shell=True, env_variables={'PATH': path_variable})
# Generate the grub configuration file
utils.execute('chroot %(path)s /bin/bash -c '

View File

@ -137,6 +137,10 @@ class TestImageExtension(test_base.BaseTestCase):
'"/usr/sbin/grub-install %s"' %
(self.fake_dir, self.fake_dev)), shell=True,
env_variables={'PATH': '/sbin:/bin'}),
mock.call(('chroot %s /bin/bash -c '
'"/usr/sbin/grub-install %s --removable"' %
(self.fake_dir, self.fake_dev)), shell=True,
env_variables={'PATH': '/sbin:/bin'}),
mock.call(('chroot %s /bin/bash -c '
'"/usr/sbin/grub-mkconfig -o '
'/boot/grub/grub.cfg"' % self.fake_dir),
@ -193,6 +197,10 @@ class TestImageExtension(test_base.BaseTestCase):
'"/usr/sbin/grub-install %s"' %
(self.fake_dir, self.fake_dev)), shell=True,
env_variables={'PATH': '/sbin:/bin'}),
mock.call(('chroot %s /bin/bash -c '
'"/usr/sbin/grub-install %s --removable"' %
(self.fake_dir, self.fake_dev)), shell=True,
env_variables={'PATH': '/sbin:/bin'}),
mock.call(('chroot %s /bin/bash -c '
'"/usr/sbin/grub-mkconfig -o '
'/boot/grub/grub.cfg"' % self.fake_dir),

View File

@ -0,0 +1,6 @@
---
fixes:
- The ironic-python-agent when writing a partition image now
installs grub to the UEFI fallback path. e.g. EFI/BOOT/BOOTX64.EFI
The fallback path is used to boot the bare metal node if the NVRAM is
reset.