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

Bug#789798: grub-installer: add option to _not_ install to UEFI boot order



Package: grub-installer
Version: 1.124
Severity: wishlist
Tags: patch

I have a need to repeatedly install Debian from PXE on systems which are UEFI
only (arm64 as it happens but I think all of the below applies to x86 UEFI
too). When we want to actually boot the installed OS we chainload from the PXE
grub.efi to the one on the ESP (using grub-installer/force-efi-extra-removable
for simplicity, but that's by the by, I think).

This is for automated testing which does a fresh install before most tests.

The problem is that during install Debian inserts itself into the UEFI boot
order _before_ the PXE entry, this happens via grub-installer.udeb ->
grub-install (from the main grub deb) -> efibootmgr -c.

This means that when we come to want to regroove the box it won't boot from PXE.

grub-install offers an option to avoid this (--no-nvram) which is passed by
grub-installer under some very specific circumstances (known broken hardware)
but it would be very useful if this was a pre-seedable option so it could be
used in circumstances such as the above as well.

The attached patch adds a preseedable grub-installer/no-nvram (heavily inspired
by the grub-installer/force-efi-extra-removable option) which forces the
--no-nvram option to be used. I've tested this by rebuilding the Jessie
installer with a patched version of grub-installer. The English text could
probably do with some review on the appropriate list.

Thanks,
Ian.

-- System Information:
Debian Release: 8.0
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'unstable'), (500, 'testing'), (500, 'oldstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, armhf, armel

Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Init: sysvinit (via /sbin/init)
commit 3f74e51b6a10253d4fe598a1bf83a3d21783b0be
Author: Ian Campbell <ijc@hellion.org.uk>
Date:   Fri Jun 19 15:17:40 2015 +0100

    Add preseedable option to allow avoiding installation to NVRAM. (Closes: #xxxxxx)

diff --git a/debian/changelog b/debian/changelog
index cf6fda2..47a679c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+grub-installer (1.124) UNRELEASED; urgency=medium
+
+  * Add preseedable option to allow avoiding installation to NVRAM.
+    (Closes: #xxxxxx)
+
+ -- Ian Campbell <ijc@debian.org>  Fri, 19 Jun 2015 15:16:47 +0100
+
 grub-installer (1.123) unstable; urgency=medium
 
   [ Updated translations ]
diff --git a/debian/grub-installer.templates b/debian/grub-installer.templates
index e294afb..e5d090b 100644
--- a/debian/grub-installer.templates
+++ b/debian/grub-installer.templates
@@ -285,3 +285,15 @@ _Description: Force GRUB installation to the EFI removable media path?
  installing GRUB there will make that operating system temporarily
  unbootable. GRUB can be manually configured later to boot it if
  necessary.
+
+Template: grub-installer/no-nvram
+Type: boolean
+Default: false
+# :sl4:
+_Description: Avoid adding GRUB to Firmmware NVRAM configuration?
+ By default GRUB will be registered into NVRAM on platforms where this is
+ required. e.g. UEFI Boot Manager or OpenFirmware boot device.
+ .
+ This is sometimes not desirable, e.g. for systems which PXE boot and chainload
+ instead and do not want the firmware configuration adjusted. Answering no here
+ will avoid make such adjustments.
diff --git a/grub-installer b/grub-installer
index 777b3b2..ee186d2 100755
--- a/grub-installer
+++ b/grub-installer
@@ -813,6 +813,18 @@ grub2/force_efi_extra_removable boolean true
 EOF
 		fi
 
+                # Should we avoid installing/registering GRUB in NVRAM?
+		db_input low grub-installer/no-nvram || [ $? -eq 30 ]
+		db_go || exit 10
+		db_get grub-installer/no-nvram
+		if [ "$RET" = true ]; then
+			grub_install_params="$grub_install_params --no-nvram"
+			# Make sure this happens on upgrades too
+			$chroot $ROOT 'debconf-set-selections' <<EOF
+grub-installer/no-nvram boolean true
+EOF
+		fi
+
 		if [ "$ARCH" = "powerpc/chrp_pegasos" ] ; then
 			# nvram is broken here
 			grub_install_params="$grub_install_params --no-nvram"

Reply to: