From 3aae8bfa61ac413e27165f8e08abd42b30c80ae1 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Fri, 4 May 2012 22:16:35 +0000 Subject: [PATCH] Switch to using efi shell + startup.nsh as the removable media efi boot option. svn path=/nixos/trunk/; revision=33984 --- modules/installer/cd-dvd/iso-image.nix | 19 +++++++++++-- .../efi-boot-stub/efi-boot-stub-builder.sh | 10 +++---- .../installer/efi-boot-stub/efi-boot-stub.nix | 28 ++++++++++++++----- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/modules/installer/cd-dvd/iso-image.nix b/modules/installer/cd-dvd/iso-image.nix index 08b0cdbbd74..060dd2d2d32 100644 --- a/modules/installer/cd-dvd/iso-image.nix +++ b/modules/installer/cd-dvd/iso-image.nix @@ -119,6 +119,17 @@ let ''; + efiShell = if pkgs.stdenv.isi686 then + pkgs.fetchurl { + url = "https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/Ia32/Shell_Full.efi"; + sha256 = "0ymm3mbbwx9f6cq0bp2nr7ikyagxgsg4sjs5q1s4xbnms27slwjq"; + } + else + pkgs.fetchurl { + url = "https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/X64/Shell_Full.efi"; + sha256 = "1xchy8a05mgqzr82mmahdni0jbxsz6xf6vm2bg1bch9i6l72qgmh"; + }; + # The efi boot image efiImg = pkgs.runCommand "efi-image_eltorito" {} '' @@ -129,11 +140,13 @@ let ${pkgs.mtools}/bin/mmd -i "$out" efi/boot ${pkgs.mtools}/bin/mmd -i "$out" efi/nixos ${pkgs.mtools}/bin/mcopy -v -i "$out" \ - ${config.boot.kernelPackages.kernel + "/bzImage"} ::efi/boot/boot${targetArch}.efi + ${efiShell} ::efi/boot/boot${targetArch}.efi + ${pkgs.mtools}/bin/mcopy -v -i "$out" \ + ${config.boot.kernelPackages.kernel + "/bzImage"} ::bzImage.efi ${pkgs.mtools}/bin/mcopy -v -i "$out" \ ${config.system.build.initialRamdisk + "/initrd"} ::efi/nixos/initrd - 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/boot/linux.conf + echo "bzImage.efi 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 ::startup.nsh ''; targetArch = if pkgs.stdenv.isi686 then diff --git a/modules/installer/efi-boot-stub/efi-boot-stub-builder.sh b/modules/installer/efi-boot-stub/efi-boot-stub-builder.sh index 145b406922b..3c55363a44d 100644 --- a/modules/installer/efi-boot-stub/efi-boot-stub-builder.sh +++ b/modules/installer/efi-boot-stub/efi-boot-stub-builder.sh @@ -76,11 +76,6 @@ addEntry() { set -e fi - if test -n "@installRemovableMediaImage@"; then - mkdir -pv "@efiSysMountPoint@"/efi/boot - cp $kernel "@efiSysMountPoint@"/efi/boot/boot"@targetArch@".efi - sed 's|.*@kernelFile@.efi ||' $startup > "@efiSysMountPoint@"/efi/boot/linux.conf - fi if test -n "@installStartupNsh@"; then sed 's|.*@kernelFile@.efi|@kernelFile@.efi|' < $startup > "@efiSysMountPoint@/startup.nsh" cp $kernel "@efiSysMountPoint@/@kernelFile@.efi" @@ -116,6 +111,11 @@ if test -n "@runEfibootmgr@"; then set -e fi +if test -n "@efiShell@"; then + mkdir -pv "@efiSysMountPoint@"/efi/boot + cp "@efiShell@" "@efiSysMountPoint@"/efi/boot/boot"@targetArch@".efi +fi + # Remove obsolete files from the EFI system partition for fn in "@efiSysMountPoint@/efi/nixos/"*; do if ! test "${filesCopied[$fn]}" = 1; then diff --git a/modules/installer/efi-boot-stub/efi-boot-stub.nix b/modules/installer/efi-boot-stub/efi-boot-stub.nix index 72b7fa28ac3..def1e10dd52 100644 --- a/modules/installer/efi-boot-stub/efi-boot-stub.nix +++ b/modules/installer/efi-boot-stub/efi-boot-stub.nix @@ -59,15 +59,14 @@ let ''; }; - installRemovableMediaImage = mkOption { + installShell = mkOption { default = false; description = '' - Whether to build/install a BOOT{machine type short-name}.EFI file - in \EFI\BOOT. This _should_ only be needed for removable devices + Whether to install an EFI shell in \EFI\BOOT. + This _should_ only be needed for removable devices (CDs, usb sticks, etc.), but it may be an option for broken - systems where efibootmgr doesn't work. It reads the UCS-2 - encoded \EFI\NIXOS\BOOT-PARAMS to find out which kernel to boot - with which parameters. + systems where efibootmgr doesn't work. Particularly useful in + conjunction with installStartupNsh ''; }; @@ -85,7 +84,22 @@ let isExecutable = true; 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]); - inherit (config.boot.loader.efiBootStub) efiSysMountPoint runEfibootmgr installStartupNsh efiDisk efiPartition installRemovableMediaImage; + inherit (config.boot.loader.efiBootStub) efiSysMountPoint runEfibootmgr installStartupNsh efiDisk efiPartition; + + efiShell = if config.boot.loader.efiBootStub.installShell then + if pkgs.stdenv.isi686 then + pkgs.fetchurl { + url = "https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/Ia32/Shell_Full.efi"; + sha256 = "0ymm3mbbwx9f6cq0bp2nr7ikyagxgsg4sjs5q1s4xbnms27slwjq"; + } + else + pkgs.fetchurl { + url = "https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/X64/Shell_Full.efi"; + sha256 = "1xchy8a05mgqzr82mmahdni0jbxsz6xf6vm2bg1bch9i6l72qgmh"; + } + else + null; + kernelFile = platform.kernelTarget; targetArch = if pkgs.stdenv.isi686 then "IA32"