On Wed, Dec 03, 2014 at 04:18:23PM +0000, Steve McIntyre wrote: > >A more generic fix would be to add to a list of filesystems that need >unmounting, and trap to a new shell function that unmounts that >list. Not too hard, I think - I'll see if I can do that and get it >tested today. > >Frankly, I'd also like to move mountvirtfs and that new function over >to a more central d-i scripts location and cut down on the duplicated >code. That's definitely something for post-jessie, as it's going to >potentially cut across a lot of the d-i packages.
<snip> >>The unmount is wanted or the leaving of /boot/efi mounted is? (I could >>see an argument either way actually). > >I need to make sure that /target/boot/efi is unmounted; otherwise >exiting and re-entering the rescue menu fails. > >Updated patch coming soon... And here it is. Differences from v1 are: * s/UEFI/EFI/ in messages for consistency * s/step_force_efi/step_force_efi_removable/ * Better handling of mounting and unmounting -- Steve McIntyre, Cambridge, UK. st...@einval.com You lock the door And throw away the key There's someone in my head but it's not me
>From cb00fb6bcae21d0628bd11e959629adae9c8fe39 Mon Sep 17 00:00:00 2001 From: Steve McIntyre <st...@einval.com> Date: Wed, 3 Dec 2014 17:50:17 +0000 Subject: [PATCH] Add support for using the UEFI removable media path Either during installation (low priority or preseeding), or as an extra rescue-mode option to help people fix their systems post-install once they realise they need to. (#767037) --- debian/changelog | 10 ++++ debian/grub-installer.templates | 43 ++++++++++++++ grub-installer | 14 +++++ rescue.d/81grub-efi-force-removable | 93 +++++++++++++++++++++++++++++++ rescue.d/81grub-efi-force-removable.tst | 3 + 5 files changed, 163 insertions(+) create mode 100755 rescue.d/81grub-efi-force-removable create mode 100755 rescue.d/81grub-efi-force-removable.tst diff --git a/debian/changelog b/debian/changelog index 6d94005..2879e27 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +grub-installer (1.102) unstable; urgency=medium + + [ Steve McIntyre ] + * Add extra support for forcing installation to the EFI + removable media path, either during installation (low priority or + preseeding), or as an extra rescue-mode option to help people fix + their systems post-install once they realise they need to. (#767037) + + -- Steve McIntyre <93...@debian.org> Mon, 01 Dec 2014 02:49:36 +0000 + grub-installer (1.101) unstable; urgency=medium [ Steve McIntyre ] diff --git a/debian/grub-installer.templates b/debian/grub-installer.templates index e439ad0..e294afb 100644 --- a/debian/grub-installer.templates +++ b/debian/grub-installer.templates @@ -209,6 +209,21 @@ Type: text # :sl1: _Description: Updating /etc/kernel-img.conf... +Template: grub-installer/progress/step_force_efi_removable +Type: text +# :sl1: +_Description: Checking whether to force usage of the removable media path + +Template: grub-installer/progress/step_mount_filesystems +Type: text +# :sl1: +_Description: Mounting filesystems + +Template: grub-installer/progress/step_update_debconf_efi_removable +Type: text +# :sl1: +_Description: Configuring grub-efi for future usage of the removable media path + Template: debian-installer/grub-installer/title Type: text # Main menu item @@ -242,3 +257,31 @@ _Description: Failed to mount /target/proc Check /var/log/syslog or see virtual console 4 for the details. . Warning: Your system may be unbootable! + +Template: rescue/menu/grub-efi-force-removable +Type: text +# Rescue menu item +# :sl2: +_Description: Force GRUB installation to the EFI removable media path + +Template: grub-installer/force-efi-extra-removable +Type: boolean +Default: false +# :sl1: +_Description: Force GRUB installation to the EFI removable media path? + It seems that this computer is configured to boot via EFI, but maybe + that configuration will not work for booting from the hard + drive. Some EFI firmware implementations do not meet the EFI + specification (i.e. they are buggy!) and do not support proper + configuration of boot options from system hard drives. + . + A workaround for this problem is to install an extra copy of the EFI + version of the GRUB boot loader to a fallback location, the + "removable media path". Almost all EFI systems, no matter how buggy, + will boot GRUB that way. + . + Warning: If the installer failed to detect another operating system + that is present on your computer that also depends on this fallback, + installing GRUB there will make that operating system temporarily + unbootable. GRUB can be manually configured later to boot it if + necessary. diff --git a/grub-installer b/grub-installer index 4c12998..ef81dbf 100755 --- a/grub-installer +++ b/grub-installer @@ -785,6 +785,20 @@ if [ -z "$frdisk" ]; then fi fi + # Should we force a copy of grub-efi to be installed + # to the removable media path too? Ask at low + # priority, or can also be pre-seeded of course + db_input low grub-installer/force-efi-extra-removable || [ $? -eq 30 ] + db_go || exit 10 + db_get grub-installer/force-efi-extra-removable + if [ "$RET" = true ]; then + grub_install_params="$grub_install_params --force-extra-removable" + # Make sure this happens on upgrades too + $chroot $ROOT 'debconf-set-selections' <<EOF +grub2/force_efi_extra_removable boolean true +EOF + fi + if [ "$ARCH" = "powerpc/chrp_pegasos" ] ; then # nvram is broken here grub_install_params="$grub_install_params --no-nvram" diff --git a/rescue.d/81grub-efi-force-removable b/rescue.d/81grub-efi-force-removable new file mode 100755 index 0000000..8761511 --- /dev/null +++ b/rescue.d/81grub-efi-force-removable @@ -0,0 +1,93 @@ +#! /bin/sh -e + +. /usr/share/debconf/confmodule + +. /usr/share/grub-installer/functions.sh + +EXTRA_PATHS="" + +log () { + logger -t grub-installer "grub-efi-force-removable $@" +} + +error () { + log "error: $@" +} + +die () { + local template="$1" + shift + + error "$@" + db_input critical "$template" || [ $? -eq 30 ] + db_go || true + exit 1 +} + +mountvirtfs () { + fstype="$1" + path="$2" + if grep -q "[[:space:]]$fstype\$" /proc/filesystems && \ + ! grep -q "^[^ ]\+ \+$path " /proc/mounts; then + mkdir -p "$path" || \ + die grub-installer/mounterr "Error creating $path" + mount -t "$fstype" "$fstype" "$path" || \ + die grub-installer/mounterr "Error mounting $path" + EXTRA_PATHS="$EXTRA_PATHS $path" + trap "umount $EXTRA_PATHS" HUP INT QUIT KILL PIPE TERM EXIT + fi +} + +db_progress START 0 3 grub-installer/progress/title +db_progress INFO grub-installer/progress/step_force_efi_removable + +# Should we also install grub-efi to the removable media path? +# Ask the user +log "Prompting user about removable media path" +db_input high grub-installer/force-efi-extra-removable +if ! db_go; then + # back up to menu + db_progress STOP + exit 10 +fi +db_get grub-installer/force-efi-extra-removable +if [ "$RET" != true ]; then + db_progress STOP + exit 0 +fi + +db_progress STEP 1 +db_progress INFO grub-installer/progress/step_mount_filesystems + +log "Mounting filesystems" +# If we're installing grub-efi, it wants /sys mounted in the +# target. Maybe /proc too? +mountvirtfs proc /target/proc +mountvirtfs sysfs /target/sys +chroot /target mount /boot/efi || true +EXTRA_PATHS="$EXTRA_PATHS /target/boot/efi" +trap "umount $EXTRA_PATHS" HUP INT QUIT KILL PIPE TERM EXIT + +db_progress STEP 1 +db_progress INFO grub-installer/progress/step_install_loader +# Do the installation now +log "Running grub-install" +if ! chroot /target grub-install --force-extra-removable; then + db_input critical grub-installer/grub-install-failed || true + db_go || true + db_progress STOP + exit 1 +fi + +db_progress STEP 1 +db_progress INFO grub-installer/progress/step_update_debconf_efi_removable +# And add the debconf flag so the installed system will also do this in future +log "Running debconf-set-selections in the chroot" +chroot /target 'debconf-set-selections' <<EOF +grub2/force_efi_extra_removable boolean true +EOF + +db_progress STEP 1 +db_progress STOP + +# Don't need to clean up - the trap calls above will unmount filesystems for us diff --git a/rescue.d/81grub-efi-force-removable.tst b/rescue.d/81grub-efi-force-removable.tst new file mode 100755 index 0000000..9b78191 --- /dev/null +++ b/rescue.d/81grub-efi-force-removable.tst @@ -0,0 +1,3 @@ +#! /bin/sh -e +[ -f /target/boot/grub/grub.cfg ] && ( grep -q /boot/efi /target/etc/fstab ) + -- 1.7.10.4