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

Discussions about using Linux guests in VirtualBox.
Post Reply
Oliver Jones
Posts: 8
Joined: 19. Feb 2018, 14:22

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

Post by Oliver Jones »


[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

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

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

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

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

edit startup.nsh
Within the editor, add the following line:

Code: Select all

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.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

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

Post by socratis »

There is an open ticket for that. See https://www.virtualbox.org/ticket/15835
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
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)

Post by Winyl »

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?'
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

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

Post by socratis »

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...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
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)

Post by FateRover »

thx ,this really helps instead of keeping ask y should be fixed
ChipMcK
Volunteer
Posts: 1095
Joined: 20. May 2009, 02:17
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Windows, OSX
Location: U S of A

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

Post by ChipMcK »

IMHO:
  • CentOS 7.4 fails to copy grub for boot when "Enable EFI" is checked
Post Reply