Bug#422370: should switch to grub2 when using GPT
tags 422370 patch
thanks
On Sat, May 05, 2007 at 03:00:15PM +0200, Robert Millan wrote:
> Package: grub-installer
> Severity: important
>
> As of 1.95+20070505-1, grub2 supports GPT on PC/BIOS systems [1]. When user
> is installing a GPT disk, grub-installer should automaticaly switch to grub2
> (or the install will fail with errors).
>
> I'll send a patch later when I have some minutes.
Here it is. I tested it with grub-installer from trunk, but only in combination
with an etch installer because of current mklibs/gcc/binutils breakage.
Note: The last chunk is not very readable directly from the diff. I suggest you
apply and read it from the file to make sense of it.
--
Robert Millan
My spam trap is honeypot@aybabtu.com. Note: this address is only intended
for spam harvesters. Writing to it will get you added to my black list.
Index: debian/control
===================================================================
--- debian/control (revision 46727)
+++ debian/control (working copy)
@@ -9,7 +9,7 @@
Package: grub-installer
Architecture: i386 hurd-i386 amd64 kfreebsd-i386 kfreebsd-amd64
Provides: bootable-system
-Depends: cdebconf-udeb, kernel-installer, created-fstab, di-utils (>= 1.15), di-utils-mapdevfs, os-prober
+Depends: cdebconf-udeb, kernel-installer, created-fstab, di-utils (>= 1.15), di-utils-mapdevfs, os-prober, parted-udeb
XB-Installer-Menu-Item: 7300
XC-Package-Type: udeb
Description: Install GRUB on a hard disk
Index: grub-installer
===================================================================
--- grub-installer (revision 46727)
+++ grub-installer (working copy)
@@ -212,39 +212,78 @@
fi
}
+findfs () {
+ mount | grep "on /target${1%/} " | cut -d' ' -f1
+}
+
findfstype () {
mount | grep "on $ROOT${1%/} " | cut -d' ' -f5
}
+rootfs=$(findfs /)
+bootfs=$(findfs /boot)
+[ -n "$bootfs" ] || bootfs="$rootfs"
+
bootfstype=$(findfstype /boot)
[ -n "$bootfstype" ] || bootfstype="$(findfstype /)"
+# This code to set disc_offered was taken from lilo-installer
+rootfs_nodevfs=$(mapdevfs $rootfs)
+bootfs_nodevfs=$(mapdevfs $bootfs)
+prefix=$(echo "$bootfs" | sed 's/\(\/dev\/[a-z]\+\).*/\1/')
+case $prefix in
+ /dev/md)
+ disc_offered_devfs="$bootfs"
+ ;;
+ /dev/[hs]d[a-z])
+ disc_offered_devfs="$prefix"
+ ;;
+ *)
+ disc_offered_devfs=$(find $prefix -follow -name disc | head -n 1)
+ ;;
+esac
+disc_offered=$(mapdevfs "$disc_offered_devfs")
+
+# Identify partition table of the disk containing our boot partition
+bootfslabel=`parted $disc_offered print | grep "^Partition Table: " | sed -e "s/.* //g"`
+
+info "Identified partition label for $bootfs: $bootfslabel"
+
# GRUB Legacy defaults
grub_version="grub"
menu_file="menu.lst"
-# reiserfs is the only filesystem that d-i supports and grub2 doesn't yet
-if [ "$bootfstype" != "reiserfs" ]; then
- db_input low grub-installer/grub2_instead_of_grub_legacy || [ $? -eq 30 ]
- db_go || true
- db_get grub-installer/grub2_instead_of_grub_legacy
- if [ "$RET" = true ]; then
+case "$bootfstype:$bootfslabel" in
+ reiserfs:gpt)
+ # GPT is only supported in version 2, which doesn't have a
+ # reiserfs implementation yet.
+ exit 10
+ ;;
+ *:gpt)
grub_version="grub2"
menu_file="grub.cfg"
- fi
-fi
+ ;;
+ xfs:*)
+ # Warn user that grub on xfs is not safe and let them back out to
+ # main menu
+ db_input critical grub-installer/install_to_xfs || [ $? -eq 30 ]
+ db_go || exit 10
+ db_get grub-installer/install_to_xfs
+ if [ "$RET" != true ]; then
+ exit 10
+ fi
+ ;;
+ *:*)
+ db_input low grub-installer/grub2_instead_of_grub_legacy || [ $? -eq 30 ]
+ db_go || true
+ db_get grub-installer/grub2_instead_of_grub_legacy
+ if [ "$RET" = true ]; then
+ grub_version="grub2"
+ menu_file="grub.cfg"
+ fi
+ ;;
+esac
-if [ "$bootfstype" = "xfs" ]; then
- # Warn user that grub on xfs is not safe and let them back out to
- # main menu
- db_input critical grub-installer/install_to_xfs || [ $? -eq 30 ]
- db_go || exit 10
- db_get grub-installer/install_to_xfs
- if [ "$RET" != true ]; then
- exit 10
- fi
-fi
-
db_progress START 0 6 grub-installer/progress/title
db_progress INFO grub-installer/progress/step_install
Reply to: