[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Setting up UEFI boot



Hello

QUICK VERSION OF QUESTION:

How can I set up a machine to boot in UEFI mode when the running kernel was booted in legacy mode?

MORE DETAILED VERSION WITH BACKGROUND 

I recently bought an Asus mini pc which I intend to install Linux on and use as a firewall for my home network. The machine came with Windows 10 installed which I took great delight in unceremoniously dumping from the disk without ever allowing it to boot.

I am building an LFS (Linux From Scratch) installation on this machine, primarily for learning purposes but also to make sure that only what I built, and nothing else, is running on it. I've built an LFS machine successfully before, but that was on old, pre-UEFI hardware.

When I try to boot it after building, I get the word GRUB in the top left corner of the screen, then it sits there until I press any key, at which point the screen goes blank, there are a few seconds of nothing during which I assume the machine is trying and failing to boot, then it falls back to an alternative boot source. UEFI and legacy boot modes are both on.

To install LFS, you need to be already running a Linux instance of some kind to give you a  place to stand to do the build. Being a Debian user since 1995, my first choice for this is naturally a Debian live CD. All my other machines are Debian Jessie, except one very old laptop which was my first (successful) attempt with LFS. Since the machine concerned this time has no removable disk drives of any kind, being a box about 5 inches on a side, I had the adventure of putting a Debian Jessie live .ISO file on a usb stick for the first time and booting from that. 

After figuring out how to disable secure boot and turn on support for legacy boot modes, I was able to get the USB stick to boot into a non-DE Linux live environment. By installing build-essential package in that environment, partitioning the 32GB SSD in the machine for EFI (GPT partition scheme, which the device already was, small FAT32 partition at the beginning for the EFI partition, 4GB swap space near the end, some free space at the end for the SSD to do its own housekeeping, and the rest the ext4 root partition), and an ingenious combination of build steps and judicious use of chroot, it's possible to build an instance of Linux from the ground up that will, once booted, be independent of the instance used to build it. I don't claim credit for that; much smarter people than me wrote the instructions and I followed them.

And everything went great until it came time to boot. Unfortunately mainstream LFS instructions assume you are either making an MBR LFS instance from an MBR host, or making a UEFI instance from a UEFI host. But the Debian live .ISO file is MBR, and I want to install UEFI. 

It looks like the Debian live kernel has all the modules and/or kernel config options set that it needs to be ABLE to talk to the EFI, but I notice that right at the end of the grub-install process it complains "EFI variables are not supported on this system". This is happening when grub-install is calling efibootmgr to register the boot loader with the EFI. I suspect that until I get rid of that error I am not going to get to a happy place... 

Can anyone help me with what I need to do to enable a Debian live .ISO's kernel to talk to the EFI variables? OR, is there a UEFI version of the live .ISO?

I did consider approaching the LFS community instead with this problem, but I am here because A) the problem is a generic issue of building and installing grub manually which I could equally do on Debian if I were crazy enough, and B) I suspect the LFS community will just tell me to use a UEFI-enabled host instance, and I don't know how I would do that in this configuration. 

Thanks all

Mark

PS grub.cfg available if you think it important -- personally  I don't think it is getting that far. I've tried many variations in it and confused myself royally, to no avail.

Reply to: