GPT Multiboot

wblock@

Developer
A quick overview of how to create a multiboot disk with sysutils/grub2 for FreeBSD and some other operating system.
  1. Create the partitioning:
    gpart create -s gpt ada0
  2. Add a freebsd-boot partition for FreeBSD bootcode:
    gpart add -t freebsd-boot -a4k -s512k ada0
  3. Add a special partition for GRUB2:
    gpart add -t \!21686148-6449-6E6F-744E-656564454649 -a4k -s1m ada0
  4. Add a FreeBSD UFS partition for the filesystem and a swap partition. The sizes are arbitrary. A real installation must leave enough room for additional partitions. Other operating systems could conceivably use the freebsd-swap partition for swap, but might resist due to the partition type.
    gpart add -t freebsd-ufs -a4k -s80g ada0
    gpart add -t freebsd-swap -a4k ada0
  5. Format the filesystem partition and install FreeBSD:
    newfs -U /dev/ada0p3 (required to keep bsdinstall(8) from failing)
    (install FreeBSD)
  6. Install sysutils/grub2.:
  7. Edit /boot/grub/grub.cfg
    Code:
    menuentry "FreeBSD" {
      set root="(hd0,gpt3)"  # GPT partition 3
      kfreebsd /boot/loader
    }
  8. Update the GRUB2 bootcode:
    grub-install /dev/ada0

On boot, GRUB2 displays a multiboot menu.
 
A piece of advice from here: attach the commands used, maybe on a 3x5 card, to the disk or near it if possible. One may wish to make an identical one, and/or find it useful for data recovery, eventually. I've been perplexed by not having done so.
 
For gpt support grub-install must be exec with part_gpt module grub-install --modules=part_gpt /dev/da0
 
Back
Top