Add a kernel patch for the efi boot stub to read a config file when booted without arguments, and base removable media booting off of that patch

The patch is currently being discussed on LKML and hopefully will be included
in mainline in some form in the future. Note that booting from the livecd has
to do a lot of work before anything is output to the console, so if the drive
is still busy don't assume the boot has hanged

svn path=/nixos/trunk/; revision=33235
This commit is contained in:
Shea Levy 2012-03-18 17:14:52 +00:00
parent 2cc8d0363e
commit b82c253b24
4 changed files with 7 additions and 46 deletions

View File

@ -129,15 +129,11 @@ let
${pkgs.mtools}/bin/mmd -i "$out" efi/boot ${pkgs.mtools}/bin/mmd -i "$out" efi/boot
${pkgs.mtools}/bin/mmd -i "$out" efi/nixos ${pkgs.mtools}/bin/mmd -i "$out" efi/nixos
${pkgs.mtools}/bin/mcopy -v -i "$out" \ ${pkgs.mtools}/bin/mcopy -v -i "$out" \
${config.boot.kernelPackages.kernel + "/bzImage"} ::efi/nixos/bzImage ${config.boot.kernelPackages.kernel + "/bzImage"} ::efi/boot/boot${targetArch}.efi
${pkgs.mtools}/bin/mcopy -v -i "$out" \ ${pkgs.mtools}/bin/mcopy -v -i "$out" \
${config.system.build.initialRamdisk + "/initrd"} ::efi/nixos/initrd ${config.system.build.initialRamdisk + "/initrd"} ::efi/nixos/initrd
echo "\\efi\\nixos\\bzImage initrd=\\efi\\nixos\\initrd init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}" | iconv -f utf-8 -t UCS-2 > boot-params echo "initrd=\\efi\\nixos\\initrd init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}" > boot-params
${pkgs.mtools}/bin/mcopy -v -i "$out" boot-params ::efi/nixos/boot-params ${pkgs.mtools}/bin/mcopy -v -i "$out" boot-params ::efi/boot/linux.conf
${pkgs.mtools}/bin/mcopy -v -i "$out" \
${import ../efi-boot-stub/nixos-boot-pkg.nix {
inherit (pkgs) edk2 stdenv fetchhg;
}}/*/NixosBoot.efi ::efi/boot/boot${targetArch}.efi
''; '';
targetArch = if pkgs.stdenv.isi686 then targetArch = if pkgs.stdenv.isi686 then

View File

@ -78,10 +78,8 @@ addEntry() {
if test -n "@installRemovableMediaImage@"; then if test -n "@installRemovableMediaImage@"; then
mkdir -pv "@efiSysMountPoint@"/efi/boot mkdir -pv "@efiSysMountPoint@"/efi/boot
cp "@removableMediaImage@" \ cp $kernel "@efiSysMountPoint@"/efi/boot/boot"@targetArch@".efi
"@efiSysMountPoint@"/efi/boot/boot"@targetArch@".efi sed 's|.*@kernelFile@.efi ||' $startup > "@efiSysMountPoint@"/efi/boot/linux.conf
iconv -f utf-8 -t UCS-2 < $startup > "@efiSysMountPoint@"/efi/nixos/boot-params
filesCopied["@efiSysMountPoint@"/efi/nixos/boot-params]=1
fi fi
if test -n "@installStartupNsh@"; then if test -n "@installStartupNsh@"; then
sed 's|.*@kernelFile@.efi|@kernelFile@.efi|' < $startup > "@efiSysMountPoint@/startup.nsh" sed 's|.*@kernelFile@.efi|@kernelFile@.efi|' < $startup > "@efiSysMountPoint@/startup.nsh"

View File

@ -80,24 +80,20 @@ in
###### implementation ###### implementation
let let
efiBootStubBuilder = pkgs.substituteAll ({ efiBootStubBuilder = pkgs.substituteAll {
src = ./efi-boot-stub-builder.sh; src = ./efi-boot-stub-builder.sh;
isExecutable = true; isExecutable = true;
inherit (pkgs) bash; inherit (pkgs) bash;
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.glibc] ++ (pkgs.stdenv.lib.optionals config.boot.loader.efiBootStub.runEfibootmgr [pkgs.efibootmgr pkgs.module_init_tools]); path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.glibc] ++ (pkgs.stdenv.lib.optionals config.boot.loader.efiBootStub.runEfibootmgr [pkgs.efibootmgr pkgs.module_init_tools]);
inherit (config.boot.loader.efiBootStub) efiSysMountPoint runEfibootmgr installStartupNsh efiDisk efiPartition installRemovableMediaImage; inherit (config.boot.loader.efiBootStub) efiSysMountPoint runEfibootmgr installStartupNsh efiDisk efiPartition installRemovableMediaImage;
kernelFile = platform.kernelTarget; kernelFile = platform.kernelTarget;
} // pkgs.stdenv.lib.optionalAttrs config.boot.loader.efiBootStub.installRemovableMediaImage rec {
removableMediaImage = ''${import ./nixos-boot-pkg.nix {
inherit (pkgs) edk2 stdenv fetchhg;
}}/${targetArch}/NixosBoot.efi'';
targetArch = if pkgs.stdenv.isi686 then targetArch = if pkgs.stdenv.isi686 then
"IA32" "IA32"
else if pkgs.stdenv.isx86_64 then else if pkgs.stdenv.isx86_64 then
"X64" "X64"
else else
throw "Unsupported architecture"; throw "Unsupported architecture";
}); };
# Temporary check, for nixos to cope both with nixpkgs stdenv-updates and trunk # Temporary check, for nixos to cope both with nixpkgs stdenv-updates and trunk
platform = pkgs.stdenv.platform; platform = pkgs.stdenv.platform;

View File

@ -1,29 +0,0 @@
{ stdenv, edk2, fetchhg }:
let
src = fetchhg {
url = https://bitbucket.org/shlevy/nixosbootpkg;
tag = "1ff4c2891c8c1eb03677a6f8b04b8d05807ec198";
sha256 = "06zwy0g9a7g2sny7phvn2z76pb3wnw4vm9vsrjjaj7f7nzcsn13k";
};
in
stdenv.mkDerivation (edk2.setup "NixosBootPkg/NixosBootPkg.dsc" {
name = "NixosBootPkg-2012-03-15";
unpackPhase = ''
ln -sv ${src} NixosBootPkg
ln -sv ${edk2.src}/MdePkg .
'';
meta = {
description =
"Simple EFI app to load the kernel with NixOS-specific arguments";
homepage = http://www.shealevy.com;
license = "MIT";
maintainers = [ stdenv.lib.maintainers.shlevy ];
platforms = ["x86_64-linux" "i686-linux"];
};
})