0

I've recently created an Ubuntu 14.04 server 64 bit VM in VirtualBox, using EFI boot. I was being dropped to an EFI shell when booting the virtual machine, as presumably it could not find its correct .efi file to boot from.

Ubuntu creates that file at /boot/efi/EFI/grubx64.efi. I can tell the EFI shell to boot form that file using:

fd0:\efi\ubuntu\grubx64.efi

However, I don't want to do this every time I boot the VM. So I copied tha file to the default location of /boot/efi/EFI/boot/bootx64.efi. It now boots successfully without any further input.

I'm concerned that the /boot/efi/EFI/grubx64.efi file will be updated in the normal Ubuntu update process, which will mean that the new /boot/efi/EFI/boot/bootx64.efi file will be out of sync with it, unless I remember to copy it across.

Is it possible to use a symbolic link, or some other method to ensure that when the original file is updated, my copy at /boot/efi/EFI/grubx64.efi reflects any changes?

2 Answers 2

2

You can get VirtualBox's "NVRAM" variables to "stick" by using the VirtualBox EFI's user interface to manipulate the variables. In brief:

  1. "Power on" the virtual machine.
  2. Almost immediately, before GRUB appears, hit the space bar. You should see the VirtualBox EFI text-mode menu appear, with menu items called Continue, Select Language, Boot Manager, Device Manager, and Boot Maintenance Manager.
  3. Select "Boot Maintenance Manager." A new menu should appear.
  4. Select "Boot Options."
  5. Select "Add Boot Option." A "file explorer" menu appears, which shows your virtual disks, identified by long strings of hexadecimal numbers and other stuff that looks like gibberish to most people.
  6. Using the file explorer, you should be able to drill down to locate the EFI/ubuntu/grubx64.efi file on the virtual disk. Select it. You'll now see a menu called "Modify Boot Option Description."
  7. Highlight the "Input the description" line and hit the Enter key.
  8. You must now enter a description for the boot entry. Ubuntu calls it ubuntu by default, but you can call it something else, if you like.
  9. Back on the "Modify Boot Option Description" screen, select "Commit Changes and Exit." This brings you back to the "Boot Maintenance Manager" screen.
  10. Select "Boot Options" again.
  11. Select "Change Boot Order." You should see the boot order, with your new entry at the bottom.
  12. Press the Enter key to edit the boot order.
  13. Highlight your new entry and then hit the "+" key as many times as necessary to bring it to the top of the list.
  14. Press the Enter key. The edit dialog should disappear and you should see the new order on the "Change Boot Order" screen.
  15. Select "Commit Changes and Exit." This should bring you back to the "Boot Options" screen.
  16. Press the Esc key to return to the main "Boot Maintenance Manager" page.
  17. Select "Reset System." The virtual machine should reboot into GRUB.

The ubuntu entry (or whatever you call it) should now persist between reboots and even "power-off/power-on" sequences. Personally, I find this procedure too awkward and annoying to use on a regular basis; I just rename the boot loader files as you say you've already done. (With one variant: I almost always use my own rEFInd, not GRUB; but the principle's the same either way.)

5
  • This is exactly what I was looking for, thanks for the clear instructions. As this is a template vm to clone others from I should only have to do this the once, so not too tedious!
    – Arronical
    Mar 6, 2017 at 9:57
  • Oh no! It doesn't appear to persist through power off cycles!
    – Arronical
    Mar 6, 2017 at 11:39
  • Hrrm... It used to work. Maybe there's been a change to VirtualBox, or maybe I've forgotten some critical step. Sorry for the wild goose chase!
    – Rod Smith
    Mar 7, 2017 at 14:05
  • Don't worry, the information was useful anyway. It worked perfectly through using reboot from within the guest, just loses it on full power off. They do warn that efi support isn't fully implemented though.
    – Arronical
    Mar 7, 2017 at 17:28
  • 1
    EFI support has been a non-default setting for "special OSes" in VirtualBox for years now. With it being the default on almost all new consumer-grade computers sold since late 2011, I'd say it's long overdue that it become properly supported in virtual machines. (That said, I use VirtualBox mainly on Ubuntu LTS releases, which of course lag the latest VirtualBox releases. Maybe the most recent VirtualBox versions are better.)
    – Rod Smith
    Mar 9, 2017 at 15:28
1

If I understand correctly, the EFI partition has the FAT32 file system (and must have FAT32 or ISO 9660). And I don't think that linux symbolic links work in FAT32.

In your situation I would create a script that checks and updates grubx64.efi. The script might use rsync and might be called via crontab @reboot. Yes, it would delay copying it 'one' reboot, so there should be a better alternative (to trigger the copying script).

If you want to do an experiment, you could try UDF, which might work with some kind of links, and which might allow booting in UEFI mode. You could even try with ext2 (who knows, maybe the computer would boot).

Another alternative is to work around the problem by booting the virtual machine in BIOS mode (which works even if the host system runs in UEFI mode). See this link: Installation/UEFI-and-BIOS/stable-alternative

2
  • I don't think VirtualBox supports UDF, although it does support ISO-9660 and HFS+. In theory, the latter could be used on an ESP in VirtualBox, and will support symbolic links, but I don't know if this will work in practice. IMHO, it's better to stick with renaming the files or using the VirtualBox EFI's own tools to create entries, as described in my answer -- but the latter process is rather tedious.
    – Rod Smith
    Mar 5, 2017 at 22:41
  • Yes, it's probably easiest to stick with renaming the files.
    – sudodus
    Mar 6, 2017 at 9:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .