RHEL 7.4 works with EFI boot after power cycle. CentOS 7.4 does not. (#15835)

Discussions about using Linux guests in VirtualBox.

RHEL 7.4 works with EFI boot after power cycle. CentOS 7.4 does not. (#15835)

Postby Oliver Jones » 8. Mar 2018, 18:02


[ModEdit; related ticket: #15835: UEFI NVRAM seems to broken]

I am having issues with VirtualBox 5.2.8 and CentOS 7.4 [1708]. One can install CentOS 7.4 on a VirtualBox 5.2.8 system with EFI BIOS enabled, and reboot without issue. However, when the VM is powered down, the CentOS system will no longer boot when the VM is brought back up again - instead, the UEFI Interactive Shell is shown.

Steps to replicate the issue:

1) Create a new Linux VM in VirtualBox 5.2.8 (Red Hat Linux 64-bit, 4GB of memory, accept 8GB default disk size and type).
2) Go to Settings -> System -> Extended Features, and tick the box "Enable EFI (special OSes only)". Select the boot media for the CD/DVD device.
3) Start the virtual machine, and install a minimal install of CentOS, with all the defaults (including default disk layout.)
4) When the install is finished, click the "Reboot" button, and observe that the system will boot in UEFI mode.
5) Shut the system down (either select ACPI Shutdown, or power-off the machine manually from the command line.)
6) Start the virtual machine back up again. Note that it will not boot - you will get the UEFI Interactive Shell, instead of GRUB.

Briefly before the UEFI Interactive Shell appears, there is an error message:
Code: Select all   Expand viewCollapse view
Boot failed. EFI DVD/CDROM
Failed to open \EFI\BOOT\grubx64.efi - Not Found
Failed to load image \EFI\BOOT\grubx64.efi: Not Found
start_image() returned Not Found

Note that the above steps work perfectly fine for RHEL 7.4 installs, but do not work for CentOS 7.4 installs. Given that CentOS is not much more than a recompile of RHEL 7.4 (with branding removed), whatever code is in place to support RHEL 7.4 booting from EFI mode should also be in place for CentOS 7.4.

I did raise this issue on the CentOS forum, but the issue appears to lie with VirtualBox's EFI implementation. CentOS certainly works fine on all the hardware I tested (and VMware ESXi) in EFI mode. Several reasonable workarounds were discussed (which I'll repeat below), but a fix for VirtualBox would be appreciated.

The workarounds, in order of opportunity and efficiency:

1) When installing, wait for the "Reboot" button to appear, then press Ctrl-Alt-F2 to get a shell, then enter:
Code: Select all   Expand viewCollapse view
cp -p /mnt/sysimage/boot/efi/EFI/centos/grubx64.efi /mnt/sysimage/boot/efi/EFI/BOOT/
Press Ctrl-Alt-F6 to return to the installer screen, then click the "Reboot" button to finish. The VM should now behave itself after future power cycles (real or virtual).

2) On first boot, sudo to (or login as) root, then enter:
Code: Select all   Expand viewCollapse view
cp -p /boot/efi/EFI/centos/grubx64.efi /boot/efi/EFI/BOOT/
The VM can be safely powered down after this point, and restarted again without further issues.

3) When the VM has been started again, and won't boot, wait until the VM automatically enters the UEFI Shell, then enter:
Code: Select all   Expand viewCollapse view
cp fs0:\EFI\centos\grubx64.efi fs0:\EFI\BOOT
fs0:\EFI\BOOT\grubx64.efi
The first line will copy the required file, making startup automatic in future. The second line will start GRUB2 for you, without requiring a further reboot.

4) When the VM has been started again, and won't boot, wait until the VM automatically enters the UEFI Shell, then enter:
Code: Select all   Expand viewCollapse view
edit startup.nsh
Within the editor, add the following line:
Code: Select all   Expand viewCollapse view
fs0:\EFI\centos\grubx64.efi
Press F2 to save the file, press Enter to accept the default name [startup.nsh] and then press F3 to exit the editor. Either reboot or enter the last line of workaround 3 to start GRUB2 directly.

Thanks go to the CentOS forum's TrevorH, avij and owl102 for information leading to the first two workarounds (TrevorH), and the third workaround (direct tip from avij) and a link to the fourth workaround (direct tip from owl102, fourth tip written by AskUbuntu.com's emash.)
Last edited by socratis on 8. Mar 2018, 23:09, edited 1 time in total.
Reason: Added ticket related information.
Oliver Jones
 
Posts: 8
Joined: 19. Feb 2018, 14:22

Re: RHEL 7.4 works with EFI boot after power cycle. CentOS 7.4 does not.

Postby socratis » 8. Mar 2018, 23:06

There is an open ticket for that. See https://www.virtualbox.org/ticket/15835
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 22860
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: RHEL 7.4 works with EFI boot after power cycle. CentOS 7.4 does not. (#15835)

Postby Winyl » 10. Mar 2018, 08:51

Thre are event more open tickets on switching permanent NVRAM in VirtualBox. Check these out:

https://www.virtualbox.org/ticket/14279
https://www.virtualbox.org/ticket/9055

The last one is 7 years old. Seems no dev working on VB is interested on adding a code for dumping NVRAM to a file on VM shutdown and loading it on VM boot. I mean how hard is it really?'
Winyl
 
Posts: 3
Joined: 18. Sep 2017, 20:23

Re: RHEL 7.4 works with EFI boot after power cycle. CentOS 7.4 does not. (#15835)

Postby socratis » 10. Mar 2018, 10:52

Winyl wrote:I mean how hard is it really?

Hard to justify the time spent on fixing it? More than you can imagine... On the other hand, it would be relatively easy to include such a feature, if anyone contributes the code to do it.

Disclaimer: I'm not a programmer so I can't really make assumptions on the degree of difficulty of such an endeavor...
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 22860
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: RHEL 7.4 works with EFI boot after power cycle. CentOS 7.4 does not. (#15835)

Postby FateRover » 28. May 2018, 04:29

thx ,this really helps instead of keeping ask y should be fixed
FateRover
 
Posts: 3
Joined: 26. Aug 2017, 15:02

Re: RHEL 7.4 works with EFI boot after power cycle. CentOS 7.4 does not. (#15835)

Postby ChipMcK » 28. May 2018, 10:49

IMHO:

    CentOS 7.4 fails to copy grub for boot when "Enable EFI" is checked
ChipMcK
Volunteer
 
Posts: 1096
Joined: 20. May 2009, 02:17
Location: U S of A
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Windows, OSX


Return to Linux Guests

Who is online

Users browsing this forum: Google [Bot] and 6 guests