Page 1 of 1

Bootable LUKS doesn't work with EFI for Ubuntu

Posted: 15. Feb 2017, 14:03
by Paddy Landau
I have been trying to understand how to use LUKS and LVM under EFI, for which reason I have been using VirtualBox. However, I cannot boot the installed machine.

Software
  • Host: Ubuntu 16.04 64-bit
  • Guest: Ubuntu 16.04 64-bit and Lubuntu 16.04 64-bit
  • VirtualBox 5.1.14 r112924, installed from the VirtualBox PPA
What I've done
  • I created a virtual machine with "Enable EFI".
  • When installing either Ubuntu or Lubuntu in VirtualBox, I used the default installer with options "Erase disk and install Ubuntu" and "Encrypt the new Ubuntu installation for security" (which implements LUKS and LVM). I have also tried installing with these manually.
What happens
  • The installation completes without error.
  • On restarting the virtual machine, instead of booting correctly, I am presented with what looks to me like an EFI error — a "UEFI Interactive Shell". See the attached screenshot.
Is this a bug with VirtualBox; a bug with Ubuntu; some setting or procedure that I have misunderstood; or something else?

Re: Bootable LUKS doesn't work with EFI for Ubuntu

Posted: 15. Feb 2017, 15:09
by Perryg
Seeing the shell usually means that the startup.nsh file is missing or the creation of the file is corrupt or not correct, meaning it can not find the right grub2 to boot from. I would say it is more than likely your install failed at some point or was shut down before the file was created. Check fs0 and see if it is there and pointing to the proper file.

Re: Bootable LUKS doesn't work with EFI for Ubuntu

Posted: 15. Feb 2017, 16:32
by Paddy Landau
Perryg wrote:Seeing the shell usually means that the startup.nsh file is missing or the creation of the file is corrupt or not correct, meaning it can not find the right grub2 to boot from. I would say it is more than likely your install failed at some point or was shut down before the file was created. Check fs0 and see if it is there and pointing to the proper file.
Thank you for your reply, Perry. I attempted the installation more than once, with both Ubuntu and Lubuntu, and the installations did not crash; they ran right to the end when they requested a reboot. (The snapshot facility in VirtualBox was most helpful in retrying installations.)

I didn't know what fs0 was, so I had to look it up! The installation created two small partitions, namely:
  • /dev/sda1, 512 MiB, FAT32, "EFI System Partition"
    This is, I believe, fs0, containing a folder EFI/ubuntu. That folder contains an empty folder fw, and files fwupx64.efi, grub.cfg, grubx64.efi, MokManager.efi and shimx64.efi.
  • /dev/sda2, 488 MiB, ext2
    This partition contains a number of files and folders, including vmlinuz-4.4.0-62-generic.efi.signed, which looks to me like a kernel.
Neither of these partitions has a file named startup.nsh anywhere (I searched using "find").

I know next-to-nothing about EFI, so my question is, where is the file startup.nsh? Is it a bug that Ubuntu doesn't create it?

Re: Bootable LUKS doesn't work with EFI for Ubuntu

Posted: 15. Feb 2017, 16:46
by Perryg
Most of the time it is just the creation and that would be the OS you are installing. fs0 is the shell drive where you configure the bootable options. Search for how to use the shell using your favorite search engine, all shell commands are universal. If the startup.nsh file does not exist ( using the shell ) create one that points to the file and create it with the absolute path to the file. ( using dos commands )

I can't give you specifics right now but if you simply can not get the hang of it maybe I can later when I fulfil my daily duties.

Note: it would help if you stick with Ubuntu instead of one of their other forks, and I would start with creating a standard install without extras until you get the efi part sorted out. Adding more steps just muddies the water more.

Re: Bootable LUKS doesn't work with EFI for Ubuntu

Posted: 15. Feb 2017, 17:38
by Paddy Landau
Perryg wrote:If the startup.nsh file does not exist ( using the shell ) create one that points to the file and create it with the absolute path to the file. ( using dos commands )
I would be able to do this, if I had any clue what it is supposed to do!
Perryg wrote:Note: it would help if you stick with Ubuntu instead of one of their other forks, and I would start with creating a standard install without extras until you get the efi part sorted out. Adding more steps just muddies the water more.
So, you mean to install Ubuntu without encryption first? I'll give that a bash, and if it works, I'll be able to have a look at what startup.nsh is supposed to do.

In any case, I should raise a bug report on Ubuntu, because from what I now understand, it should have created startup.nsh.

Thank you again, Perry, for your time.

Re: Bootable LUKS doesn't work with EFI for Ubuntu

Posted: 15. Feb 2017, 17:54
by Perryg
startup.nsh.png
startup.nsh.png (14.02 KiB) Viewed 3608 times
At the shell prompt type the following:

FS0:

cd EFI\ubuntu

See if grubx64.efi exists if so then you need to create a startup.nsh with \EFI\ubuntu\grubx64.efi and save it in the root or FS0:\

Note: you can see how to do all of the commands here http://www.sysadminshare.com/2012/01/ef ... mands.html

to create the file you use edit startup.nsh which will create the file and enter the required information.

Additionally from what I have seen the folks at Ubuntu may not be too keen on helping since it is installed in VirtualBox but you never know. I can say that I have tested EFI with Ubuntu 16.04 and sometimes it works and sometimes not and I have to jump through a few hoops to fix it. Whether it is all Ubuntu's fault I can not say.

Re: Bootable LUKS doesn't work with EFI for Ubuntu

Posted: 16. Feb 2017, 14:12
by Paddy Landau
Perryg wrote:… create a startup.nsh with \EFI\ubuntu\grubx64.efi and save it in the root or FS0:\
Thank you, Perry, that seems to have done the trick!

(Now I'm left with a prompt to enter the LUKS unlock password but no way to actually do so (doh!). But that's a query for a new thread for the Ubuntu team.)

I shall raise a bug report about the missing file.

Thank you again, Perry. You have been most helpful.