So you have finished installing your Linux OS on your Virtual Machine and then you get the following error when the system reboots. I have also had a simliar issue when trying to boot of a CD/DVD. You will note this issue only occurs when using UEFI/EFI boot technology and not MBR. You should always use UEFI/EFI where possible.
And just for people search from the internet this is the message in text
Press ESC in 1 seconds to skip startup.nsh or any other key to continue.
This problem seems to only affect some Linux distributions, so far I have experience it with:
- CentOS
- Debian
This issue can happen on any Hypervisor but the ones I have had experience with are:
- KVM
- VirtualBox
The Cause
This is caused by the VM looking in the wrong place for the boot file, or the boot file is in the wrong place, not sure which is more correct but the outcome is the same.
Solutions
There are two methods of fixing this which we will go through below. Both allow the system to find the required boot file.
Method 1 - Manually add an entry to the UEFI boot order (preferred)
- Different distros might have different locations for the boot file but the fix should be the same or similar.
- This should stay after kernel updates.
- This fix can be done without booting into an OS.
- When at the interactive shell, type exit
- You are now on the Bhyve boot screen
- Select 'Boot Maintenance Manager'
- Select 'Boot Options'
- Select 'Add Boot Option'
- You are now in the File Explorer
- Select 'NO VOLUME LABEL'. The name might be different on your system.
- Select '<EFI>'
- Select '<debian>'. The name might be different on your system.
- Select 'grubx64.efi'. The name might be different on your system.
- You have now finished with the File explorer.
- Input the description, in this case 'Debian'.
- Commit and Changes and Exit
- Change Boot Order
- Your screen should look like this, just press enter.
- Move 'Debian' to the top
- Commit Changes and Exit
- Done, you can reboot now.
Method 2 - Copy the boot file to the correct location
- Different distros might have different locations for the boot file but the fix should be the same or similar.
- This might get wiped out upon kernel updates.
- You need to boot into the OS to correct this issue using this method.
- When at the interactive shell, type exit
- You are now on the Bhyve boot screen
- Select 'Boot From File'
- Select '<EFI>'
- Select '<debian>'. The name might be different on your system.
- Select 'grubx64.efi'. The name might be different on your system.
- Your VM will now boot up to your selected OS.
- Now we have booted the VM it is time to put the boot file where it needs to be.
- Login as root
- Navigate to the EFI directory of your operating system.
cd /boot/efi/EFI/debian/
- Check you are in the right directory by check to see if grubx64.efi exists. This is the boot file that needs to be loaded but it is in the wrong place.
ls
- Make a copy of grubx64.efi into the correct location
mkdir /boot/efi/EFI/BOOT/ cp grubx64.efi /boot/efi/EFI/BOOT/bootx64.efi
- You can now reboot or shutdown your PC.
reboot shutdown
Notes
- Tutorials
- Solving UEFI Boot Problems on Bhyve / FreeNAS / TrueNAS VM | Jon Gibbins
- After gracefully shutting down the VM and then starting it up again later on that day, my machine would not boot. Rather, the VM would start but the operating system would not boot past a UEFI Interactive Shell.
- After a bit of digging it seems this is a well known problem where the finger is being pointed towards jointly between the GRUB boot manager not saving files where Bhyve expects and Bhyve not looking for bootfiles in the location saved in by GRUB.
-
echo “grub-efi-amd64 grub2/force_efi_extra_removable boolean true” | debconf-set-selections
- TrueNAS Scale virtualization and Debian UEFI boot loader issue | TrueNAS Community
- After initial install of a Debian VM (with UEFI boot) it is not able to find the boot loader (i.e. debian/grubx64.efi). This can be fixed temporarily by going into the virtual UEFI/BIOS menus of the VM and manually adding a new boot option and pointing it to grubx64.efi and then saving the changes.
- Some fixes from the thread
su - cd /boot/efi/EFI mkdir BOOT cp debian/grubx64.efi BOOT/bootx64.efi # Now you can reboot to check if evrything is good. Save your work and reboot reboot
apt-get install --reinstall grub-efi grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub
- when i try to install a virtual machine sometimes i get this screen and cant get past it. what am i doing wrong? | Reddit
- In UEFI Interactive Shell, enter the file system:
fs0:
- Following up with creating this file:
edit startup.nsh
- Enter this or similar line to it:
\EFI\debian\grubx64.efi
- Press CTRL+S to save the file.
- Press ENTER to confirm the file name.
- Press CTRL+Q to exit the editor.
- Restart the Guest:
reset
- In UEFI Interactive Shell, enter the file system:
- Installing Debian 10 as a VM on FreeNAS/TrueNAS. Fix the EFI shell boot error and networking issues. - YouTube
- In this video I'll show you how to install Debian 10 (or Debian 11) as a VM inside FreeNAS or TrueNAS Core bhyve. The video will include some workarounds to make the VM more stable and trouble-free.
- Not all of the video is required but it is a good tutorial.
- 319s - How to temporarily boot debian use the EFI Boot Manager. Ignore the network bit.
- 498s - How to pproperly fix (this and above is same as jon biggins) + recommends a cron job to recopy this file.
- Solving UEFI Boot Problems on Bhyve / FreeNAS / TrueNAS VM | Jon Gibbins
- Virtualbox
- Virtualbox UEFI Shell startup.nsh Error Fixed (MacOS, Linux, Windows any OS) - YouTube - This tells you how to boot using the shell
- virtual machine - VirtualBox: Guest suddenly boots only into UEFI Interactive Shell - Unix & Linux Stack Exchange
- CentOS 7.4 [1708] - boot problems in UEFI mode on VirtualBox 5.x - CentOS - This is a known issue. VirtualBox UEFI is not offering a permanent virtualized NVRAM.
- Quick Fix: Virtualbox UEFI Booting Error - YouTube - Excellent video on configuring via the EFI Shell