FreeBSD Port: grub2-1.98

Rick rick at
Sun Oct 10 11:49:45 UTC 2010

 Hello, I have a couple FreeBSD patches for grub2 to contribute.  These
allow grub to install to FreeBSD gpt partitions.

The gpt partition scheme allows for a small boot partition of type
bios-boot to hold bootloader code.  gpart, however, does not make this
parition.  Instead it makes the same kind of partition with a different
GUID (freebsd-boot).  These patches allow grub2 to recognize and install
to a freebsd-boot partition.  They also add support for solaris-boot

I hope somebody will kindly add these to the port and publish.

ALSO:  I believe the patch-util-getroot.c patch currently in the port is
a mistake and should be removed.  I had to undo this change to get
grub-probe to work.  Upon further inspection, this does not seem like
the right way to solve whatever problem the patch author was having and
it will likely break grub for most people.  The purpose of the patched
routine is to map a directory to the character device that provides it
(given /boot/grub/, return /dev/ad4p2, for example).  It stat()'s the
directory to get its parent device ID (st_dev) and then recursively
searches the devices in /dev to match on their device ID (st_rdev).  The
patch changes this so that the function searches /dev for the ID of the
folder, instead of the folder's parent.  This is not right and breaks
grub-install.  I think the author of the patch was passing the wrong
argument on the command line and that's why this patch was necessary.

Rick Richard
-------------- next part --------------
--- include/grub/gpt_partition.h.orig	2010-03-06 12:51:37.000000000 -0800
+++ include/grub/gpt_partition.h	2010-10-10 02:57:26.000000000 -0700
@@ -40,6 +40,17 @@
     { 0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } \
+  { grub_cpu_to_le32 (0x83BD6B9D), grub_cpu_to_le16 (0x7F41), grub_cpu_to_le16 (0x11DC), \
+    { 0xBE, 0x0B, 0x00, 0x15, 0x60, 0xB8, 0x4F, 0x0F } \
+  }
+  { grub_cpu_to_le32 (0x6A82CB45), grub_cpu_to_le16 (0x1DD2), grub_cpu_to_le16 (0x11B2), \
+    { 0x99, 0xA6, 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } \
+  }
 struct grub_gpt_header
   grub_uint8_t magic[8];
-------------- next part --------------
--- util/i386/pc/grub-setup.c.orig	2010-03-06 12:51:37.000000000 -0800
+++ util/i386/pc/grub-setup.c	2010-10-10 02:56:55.000000000 -0700
@@ -38,7 +38,8 @@
 #include <grub/util/getroot.h>
 static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
+static const grub_gpt_part_type_t grub_gpt_partition_type_freebsd_boot = GRUB_GPT_PARTITION_TYPE_FREEBSD_BOOT;
+static const grub_gpt_part_type_t grub_gpt_partition_type_solaris_boot = GRUB_GPT_PARTITION_TYPE_SOLARIS_BOOT;
 #include <grub_setup_init.h>
 #include <stdio.h>
@@ -138,7 +139,9 @@
       struct grub_gpt_partentry *gptdata = p->data;
       /* If there's an embed region, it is in a dedicated partition.  */
-      if (! memcmp (&gptdata->type, &grub_gpt_partition_type_bios_boot, 16))
+      if (! memcmp (&gptdata->type, &grub_gpt_partition_type_bios_boot, 16) || 
+	      ! memcmp (&gptdata->type, &grub_gpt_partition_type_freebsd_boot, 16) ||
+		  ! memcmp (&gptdata->type, &grub_gpt_partition_type_solaris_boot, 16))
 	  embed_region.start = p->start;
 	  embed_region.end = p->start + p->len;

More information about the freebsd-ports mailing list