[Nix-dev] uefi booting on nixos

Shea Levy shea at shealevy.com
Sun Mar 18 13:35:14 CET 2012


Hi Mathijs,

On 3/18/12 8:23 AM, Mathijs Kwik wrote:
> Little progress:
>
> I upgraded to kernel 3.3 and set this config:
>
>    boot.loader.efiBootStub = {
>      enable = true;
>      efiSysMountPoint = "/efi";
>      runEfibootmgr = true;
>      installStartupNsh = true;
>    };
>
> I had to disable grub, because it was now looking for a file named
> bzImagebzImage.

Yeah, I had a fix for that in NixOS but my solution was awkward so I 
reverted it, I'll have to put a better one in.

>
> I ended up with some nixos stuff on my efi partition, and a
> startup.nsh script in the root.
> efibootmgr shouted a few "cannot connect to efi" lines. I did modprobe
> efivars first, but that didn't help. In bios mode, efi is just not
> available at all.

Yeah, efibootmgr is not expected to work in bios mode. You'll need to 
get into efi mode some other way then run 
/run/current-system/bin/switch-to-configuration boot.

>
> So I added /startup.nsh to my boot options in the uefi shell manually.
> Trying to boot it doesn't work though. The fallback (bios/grub) takes
> over immediately, no error messages or anything.

.nsh files are EFI shell scripts. \startup.nsh is a special script that 
is run automatically when the EFI shell starts if you don't press esc to 
drop straight to the shell. If your system has a uefi shell (either 
built-in, or one you have on your system partition that you launch with 
'launch shell from filesystem', depends on your firmware), you should be 
able to just launch that and let it boot.

>
> Are .nsh files part of the UEFI spec?
> I was successful before booting grub2_efi. It would not let me boot
> linux yet, but at least the menu and mode switching worked.
>
> Any other suggestions I can try?

As I said above, if you can launch a UEFI shell it should automatically 
pickup startup.nsh. If not, but you have another way to add a boot 
option (e.g. through some firmware-specific menu), then you'll have to 
add \kernel.efi launched with the arguments found in startup.sh as a 
boot option. Otherwise, a fix for the CD on systems that don't support 
the protocol I used is in the pipeline.

>
> Thanks,
> Mathijs
>
>
>
> On Sun, Mar 18, 2012 at 12:18 PM, Mathijs Kwik<mathijs at bluescreen303.nl>  wrote:
>> Shea Levy<shea at shealevy.com>  writes:
>>
>>> Hi Mathijs,
>>>
>>> It's not totally complete. In particular, the
>>> installRemovableMediaImage option installs an EFI program that is a)
>>> really hacky and b) depends on protocols not available on every
>>> firmware (though when they're not available the boot fails with no bad
>>> effects). I'm working with the kernel devs to ameliorate the problem
>>> that necessitated the hack in the first place. I also need to do more
>>> extensive testing, especially on the macbook pro. That being said, I
>>> have been using it exclusively on my desktop for the past week or so
>>> with several successful rebuilds, so there's that. If you do want to
>>> try it out, I recommend trying the latest ISO from
>>> http://hydra.nixos.org/job/nixos/trunk/iso_efi but if it doesn't boot
>>> in EFI mode boot it in BIOS mode for the install then, if your system
>>> supports efibootmgr, re-run switch-to-configuration after booting into
>>> the built system to install the boot manager entries.
>> EFI mode doesn't boot. The CD does show up as an UEFI boot option, but
>> if I select it, I get a very fast blue flash (grub menu ?),
>> followed by my installed (harddisk) grub starting (in bios mode).
>>
>> Should I just try to switch my running system to UEFI using
>> boot.loader.efiBootStub?
>> I guess I can always just boot my current BIOS/grub entry when it fails.
>>
>> I don't fully see how efibootstub would work, how does it plug in to
>> grub2_efi? As far as I know (at least on my system) efibootmgr cannot
>> communicate with the uefi when booted in bios mode, so I'm pretty sure I
>> need a working boot cd, or supply the bootmgr entry in the UEFI shell
>> myself. (I had to do that for grub2_efi on Arch)
>>
>> Mathijs
>>
>>
>>> Let me know if you have any problems.
>>>
>>> Cheers,
>>> Shea
>>>
>>> On 3/16/12 4:34 PM, Mathijs Kwik wrote:
>>>> Hi Shea,
>>>>
>>>> I saw your commits dealing with uefi booting.
>>>> On my laptop, windows 7 boots fine from uefi.
>>>> However, linux doesn't. Grub-uefi boots, but something goes wrong
>>>> (memory mapping) when handig control to the kernel.
>>>> In the past, I've spent countless hours debugging it to no avail.
>>>>
>>>> I would like to give it another try someday soon.
>>>> Do you consider your uefi changes somewhat complete? Or do you still
>>>> have more changes planned?
>>>>
>>>> Anyway, thanks for your work.
>>>>
>>>> Mathijs



More information about the nix-dev mailing list