This is an untested patch to grub-installer that adds a partman check to make sure that people using GPT labels create a bios_grub partition, otherwise GRUB won't be able to embed itself reliably (see http://grub.enbug.org/BIOS_Boot_Partition for a detailed technical description). I'll test this before commit, but if somebody has the time, I'd like review of the proposed additional strings.
Index: check.d/biosgrub_check =================================================================== --- check.d/biosgrub_check (revision 0) +++ check.d/biosgrub_check (revision 0) @@ -0,0 +1,71 @@ +#! /bin/sh +# When installing to a GPT disk, GRUB 2 needs a bios_grub partition so that +# it has somewhere reliable to embed core.img. + +. /lib/partman/lib/base.sh + +ARCH="$(archdetect)" +case $ARCH in + i386/mac|amd64/mac) + # Note: depends on partman-efi to load the efivars module! + if [ -d /sys/firmware/efi ]; then + # GRUB not yet usable on Intel-based Macs booted using EFI + exit 0 + fi + ;; + powerpc/chrp_pegasos) + ;; + powerpc/*) + # GRUB not yet usable on PowerPC systems other than Pegasos/Efika + exit 0 + ;; +esac + +db_get grub-installer/skip +if [ "$RET" = true ]; then + exit 0 +fi + +# If there are any GPT disks, is there at least one bios_grub partition on +# them? (This check is not perfect because we don't yet know where the user +# plans to install GRUB.) +gpt=no +biosgrub=no +for dev in $DEVICES/*; do + [ -d "$dev"] || continue + cd "$dev" + + open_dialog GET_LABEL_TYPE + read_line label + close_dialog + [ "$label" = gpt ] || continue + gpt=yes + + partitions= + open_dialog PARTITIONS + while { read_line num id size type fs path name; [ "$id" ]; }; do + if [ "$fs" != free ]; then + partitions="$partitions $id" + fi + done + close_dialog + + for id in $partitions; do + [ -f "$id/method" ] || continue + method="$(cat "$id/method")" + if [ "$method" = biosgrub ]; then + biosgrub=yes + fi + done +done + +if [ "$gpt" = yes ] && [ "$biosgrub" = no ]; then + db_input critical grub-installer/no_bios_grub || true + db_go || exit 1 + db-get grub-installer/no_bios_grub + if [ "$RET" = true ]; then + exit 1 + fi +fi + +exit 0 Property changes on: check.d/biosgrub_check ___________________________________________________________________ Added: svn:executable + * Index: check.d/_numbers =================================================================== --- check.d/_numbers (revision 0) +++ check.d/_numbers (revision 0) @@ -0,0 +1 @@ +05 biosgrub_check Index: debian/control =================================================================== --- debian/control (revision 60596) +++ debian/control (working copy) @@ -3,7 +3,7 @@ Priority: standard Maintainer: Debian Install System Team <debian-boot@lists.debian.org> Uploaders: Joey Hess <jo...@debian.org>, Otavio Salvador <ota...@debian.org>, Robert Millan <r...@aybabtu.com>, Felix Zielcke <fziel...@z-51.de>, Colin Watson <cjwat...@debian.org> -Build-Depends: debhelper (>= 7.3.10~), po-debconf (>= 0.5.0) +Build-Depends: debhelper (>= 7.3.10~), dh-di, po-debconf (>= 0.5.0) Vcs-Svn: svn://svn.debian.org/d-i/trunk/packages/arch/i386/grub-installer DM-Upload-allowed: yes Index: debian/di-numbers =================================================================== --- debian/di-numbers (revision 0) +++ debian/di-numbers (revision 0) @@ -0,0 +1 @@ +check.d lib/partman Index: debian/grub-installer.templates =================================================================== --- debian/grub-installer.templates (revision 60595) +++ debian/grub-installer.templates (working copy) @@ -213,6 +213,25 @@ # :sl2: _Description: Reinstall GRUB boot loader +Template: grub-installer/no_bios_grub +Type: boolean +# :sl2: +#flag:comment:2,3 +# The translation of "reserved BIOS boot area" here should match the +# translation of the similar string in partman-partitioning. +_Description: Go back to the menu and resume partitioning? + You are using the GPT partition table format, but no reserved BIOS boot + area was found. + . + You should create a partition to be used as a "reserved BIOS boot area". + This partition provides the GRUB boot loader with a location where it can + embed its second stage in a reliable way. + . + If you do not create such a partition, it may still be possible to install + GRUB, but it will be much less reliable. For example, it is likely to break + if you do such things as defragmenting or resizing the file system + containing /boot. + Template: grub-installer/skip Type: boolean Default: false Index: debian/rules =================================================================== --- debian/rules (revision 60595) +++ debian/rules (working copy) @@ -1,3 +1,3 @@ #! /usr/bin/make -f %: - dh $@ + dh --with d-i $@ Thanks, -- Colin Watson [cjwat...@debian.org] -- To UNSUBSCRIBE, email to debian-boot-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org