Quadruple system Windows 7, OSX Snow Leopard, Ubuntu Lucid and FreeBSD 8 on GPT with BURG (supports UEFI/Apple EFI/PCBIOS)

ref: http://code.google.com/p/burg/wiki/QuadBoot

 QuadBoot  
Quadruple system Windows 7, OSX Snow Leopard, Ubuntu Lucid and FreeBSD 8 on GPT with BURG (supports UEFI/Apple EFI/PCBIOS)
Updated Mar 22, 2010 by bean12...@gmail.com

Introduction

This guide shows how to install the four OS on GPT and boots with BURG. In preparation, you needs to have:
  • GParted Live CD
  • Windows 7 64-bit Installation DVD
  • Snow Leopard Retail DVD
  • iDeneb or other OSX86 Installation DVD
  • Ubuntu Lucid beta 64-bit DVD or netboot CD
  • FreeBSD 8 amd64 Installation DVD or USB memstick
The following installation process requires to remove all partitions and create new disk layout, make sure to backup important data first !

UEFI

My test environment: HP ProBook 4510s
  • Enter BIOS and turn on UEFI boot mode.
  • Insert Windows 7 64-bit Install DVD. To ensure booting in UEFI mode, press F9 to open boot device selection page, choose "Boot From UEFI File", then browse to \EFI\BOOT\BOOTX64.EFI on DVD.
  • In the disk partition dialog, remove all partitions, then create a new partition using all available space. It should create two extra partition, EFI system partition and Microsoft reserved partition. If you don't see EFI system partition, then it's not using GPT. If this happens, you can try removing all partition, reboot using UEFI mode and try again.
  • Remove that one large partition, and create small partitions for each OS, I use the following partition layout:
    1. EFI system partition (created previously)
    2. Microsoft reserved (created previously)
    3. Windows 7 (at least 20G)
    4. OSX Snow Leopard (at least 10G)
    5. Linux swap
    6. Linux ext4
    7. FreeBSD swap
    8. FreeBSD ufs
    9. Extra OSX partition for leopard
    10. Other data partitions ...
  • After creating partition layout, you can reboot, no need to install windows right now (more on this later).
  • Enter BIOS and turn off UEFI boot mode.
  • Insert GParted Live CD, format the linux ext4 and swap partition. In theory this step could be done by ubuntu installer, but I have encountered some issue and it even mess up the MBR.
  • Reboot and insert the ubuntu lucid install disc. In partition page, don't change partition layout and use the ext4 formatted previously as root device.
  • GRUB2 fails to install properly, but it's still a good idea to choose the install GRUB step as it would download the package automatically.
  • Reboot ubuntu disc into rescue mode, open a shell on linux partition /dev/sda6, and use these commands to install grub2:
  • grub-install --force /dev/sda
    update-grub
  • Reboot and you should be able to enter ubuntu properly. Install burg according to this page InstallUbuntu, then use dd to backup mbr to an usb flash drive.
  • Insert iDeneb DVD, install leopard to the extra OSX partition.
  • Insert ubuntu disc and enter rescue mode, use dd to restore the mbr you have previously saved.
  • After reboot, you enter burg rescue shell, why ? It appears that OSX installer has removed EFI system partition, format microsoft reserved partition as EFI system partition, and create a /EFI/Apple directory in it, what a mess ! (If you install windows previously, it'd be screwed up by this and not repairable, therefore you have to install again.) You can enter this in rescue shell:
  • set prefix=(hd0,5)/boot/burg
    insmod normal
    normal
This would bring you to the normal burg menu, press 'c' to enter a console windows, and enter these commands:
gptsync hd0
reboot
  • Enter BIOS and turn on UEFI boot mode.
  • Insert Windows 7 64-bit Install DVD and boot with UEFI mode. In the partition editor, remove EFI system partition and windows 7 partition, create a new partition in the empty space and the EFI+MS reserved combo reappears. Continue with the installation.
  • After windows is done, boot GParted Live CD, use dd to restore mbr saved previously.
  • Reboot and you should see burg menu, enter ubuntu.
  • It's recommended remove /etc/burg.d/30_os-prober as the boot item generated by os-prober is not much useful, we need to construct menu items manually by create a new script /etc/burg.d/40_custom:
  • #!/bin/sh
    exec tail -n +3 $0# This file provides an easy way to add custom menu entries.  Simply type the
    # menu entries you want to add after this comment.  Be careful not to change
    # the 'exec tail' line above.
    menuentry "Boot Snow Leopard" --class macosx {
      set root=(hd0,4)
      multiboot /boot}
    menuentry "Boot Leopard" --class macosx {
      set root=(hd0,9)
      multiboot /boot}
    menuentry "Boot FreeBSD" --class freebsd {
      set root=(hd0,8)
      kfreebsd /boot/loader}
    menuentry "Reboot to EFI mode" {
      gptsync hd0
      reboot}
then use update-burg to update the configuration file. Mount the EFI partition and create burg directory:
sudo mount /dev/sda1 /mnt
sudo mkdir /mnt/EFI/burg
Download the latest burg-efi64 and burg-themes package from: http://code.google.com/p/burg/downloads/list, extract to /mnt/EFI/burg directory, and rename /mnt/EFI/burg/burg_uefi.cfg as /mnt/EFI/burg/burg.cfg.
  • Reboot, and you should see a new menu "Reboot to EFI mode", use this and it should reboot into EFI mode, which means start windows.
  • If windows doesn't boot properly, use install disk to repair it.
  • Reboot and enter F9 to open boot device selection page, choose "Boot From UEFI File", then browse to \EFI\burg\burg64.efi.
  • Now the EFI version of BURG should start, it would have three menu: "Boot Windows 7", "Boot Ubuntu" and "Reboot to PC mode". Use "Boot Ubuntu" to boot ubuntu in EFI mode.
  • In ubuntu, install efibootmgr:
  • sudo apt-get install efibootmgr
Then use this to add a new EFI boot item for burg:
sudo efibootmgr -v -c -L "BURG" -l "\\EFI\\burg\\burg64.efi"
burg would be the default boot loader for EFI now, you don't need to use "Boot From UEFI File" to choose it.
  • You can use "Reboot to PC mode" and "Reboot to EFI mode" to switch between EFI and PC version of BURG. This feature is implemented using a trick I found out about UEFI firmware. It's very strict with regarding to GPT structure. I set some incompatible field in MBR so that it would be treated as invalid GPT and boot into PC mode. After reconstruct a valid GPT, it would boot into UEFI mode again. This allows you to switch modes without entering BIOS. However, this behavior may not apply to other UEFI implementation. If it doesn't work for you, you have to use BIOS to switch mode.
  • Insert FreeBSD 8 Install DVD or USB memstick, first open a fixit shell, format and mount ufs partition:
  • newfs -O2 -U /dev/da4p8
    mount /dev/sda8 /mnt
Exit fixit shell. In Options, change install root from / to /mnt. Choose "Configure" and "Distribution" to install. Make sure you don't touch the "Fdisk" and "Disklabel" as they'd mess up the MBR. After it, reopen a fixit shell, cd to /mnt/boot, and rename GENERIC directory to kernel. You also need to create /mnt/etc/fstab as follows:
/dev/ad4p7  none  swap  ew  0  0
/dev/ad4p8  /     ufs   rw  1  1
  • Reboot into PC mode, and you should be able to use the "Boot FreeBSD" menu to enter FreeBSD.
  • Use "Boot Leopard" to enter OSX Leopard, insert the snow leopard retail disc and use OSInstall.mpkg to install snow leopard, add kext and related fixes to make it bootable. Finally, copy Chameleon loader boot to the root directory and it can be chainloaded by BURG.

Apple EFI

My test environment: Mac Mini 3.1 (early 2009 version)
  • Install OSX install disc and create the partition layout. OSX is very picky for GPT structure and refuses to install to GPT created by GParted. Please note that the EFI system partition is hidden from the disk utility, so you starts with microsoft reserved partition. After partition, install OSX normally.
  • After OSX boots, use dd to backup mbr. Then install rEFIt loader.
  • Create /EFI/burg directory in OSX. Download the latest burg-efi64 and burg-themes package fromhttp://code.google.com/p/burg/downloads/list, extract to /EFI/burg directory, and rename /mnt/EFI/burg/burg_apple.cfg as /mnt/EFI/burg/burg.cfg. Now you can start the EFI version of BURG in rEFIt menu.
  • Insert GParted Live CD, format ms reserved and windows 7 partition as ntfs, and format the linux partition as ext4.
  • Insert Ubuntu disc and install. As previously, GRUB2 fails to install, and this time it even mess up MBR. Restore the backup mbr, then reboot ubuntu disc and enter rescue mode, use the following commands to install grub2 manually:
  • grub-install --force /dev/sda
    update-grub
  • Reboot and use rEFIt to enter PC mode, you should be able to boot into ubuntu. Install burg according to this page InstallUbuntu.
  • As before, remove /etc/burg.d/30_os-prober and create our own script /etc/burg.d/40_custom:
  • #!/bin/sh
    exec tail -n +3 $0# This file provides an easy way to add custom menu entries.  Simply type the
    # menu entries you want to add after this comment.  Be careful not to change
    # the 'exec tail' line above.
    menuentry "Boot Windows" --class windows {
      set root=(hd0,2)
      chainloader +1
    }
    menuentry "Boot FreeBSD" --class freebsd {
      set root=(hd0,8)
      kfreebsd /boot/loader}
then use update-burg to update the configuration file.
  • Reboot into BURG (PC or EFI), use gptsync to create hybrid MBR:
  • gptsync hd0 2+ 3 4
    reboot
The advantage of BURG's gptsync is that you can choose which partition to mapped into MBR slots. For example, if you have a data partition at (hd0,10), you can use this to make it visible to Windows:
gptsync hd0 2+ 3 10
  • Insert Windows install disc and install. Windows 7 EFI don't support apple's implementation, you can only install using PC mode. Don't change any partition structure, just install to the partition allocated to it.
  • Windows would overwrite MBR, use rescue mode from ubuntu disc to reinstall burg:
  • burg-install --force /dev/sda
    update-burg
  • Now it's time to install FreeBSD, although it's a little tricky as the generic kernel hangs on apple hardware. You need to follow instruction here http://wiki.freebsd.org/AppleMacbook , revert r189055 and rebuild a new kernel from another FreeBSD machine. After that, copy new kernel, mfsroot.gz and devices.hints from boot directory of FreeBSD 8 install disc to /fbsd_install/ directory in ubuntu partition.
  • Reboot into PC version of BURG, enter the following commands from console to launch the FreeBSD installer:
  • set root=(hd0,6)
    kfreebsd /fbsd_install/kernel
    kfreebsd_module /fbsd_install/mfsroot.gz type=mfs_root
    kfreebsd_loadenv /fbsd_install/devices.hintset FreeBSD.vfs.root.mountfrom=ufs:/dev/md0
    boot
After that, install FreeBSD using similar method described in UEFI section.

PCBIOS

Install in PCBIOS machine is a combination of the above methods, here are highlights:
  • Install iDeneb OSX first, use it to create the partition layout.
  • Install Ubuntu next, install burg
  • Use gptsync to create hybrid MBR, then install Windows 7.
  • Fix burg boot loader.
  • Install FreeBSD.

虹光大成就-密教灌頂(一)