# Booting Linux and FreeBSD with GRUB 2



## tfueg (Feb 26, 2013)

1. Overview
This document describes the strategy to multiboot FreeBSD and Linux using GRUB 2 boot loader.
I have found after several tries, that a stable multiboot system will be achieved very fast, if you do exactly the described steps - like a cookbook.
Maybe there is another way to achieve the same result...

1.1. Step 1
Boot the installation DVD of OpenSuse 12.1 on a PC with an not partitioned, empty disk and go through the setup to install the system. 

1.2. Step 2
Starting from a 500 GB disk, you can create a partition layout like below. Reserve e.g. 314 GB for Linux root and e.g. 8 GB for Linux swap. Let the remaining disk space free to use it later with FreeBSD. 
Please make sure, that you have created a extended partition holding the two logical Linux devices #5 and #6. The GRUB 2 bootloader must be installed into the extended partition #1 and not in the MBR of the disk.


```
Number  Start   End      Size        Type       File system       Flags
 1      1049kB  322GB   322GB    extended                         boot, lba, type=0f
 5      2097kB  8587MB  8585MB   logical     linux-swap(v1)       type=82
 6      8588MB  322GB   314GB    logical     ext4                 type=83 (Linux)
```

1.3. Step 3
Boot the installation DVD of FreeBSD 9.0 and go through the setup to install the system. Please make sure that you haven't selected the entire disk to create the default UFS partitions for FreeBSD. Use a partition layout as follows:


```
Number  Start   End     Size      Type         File system       Flags
 1      1049kB  322GB   322GB   extended                        lba, type=0f
 5      2097kB  8587MB  8585MB  logical   linux-swap(v1)        type=82
 6      8588MB  322GB   314GB   logical    ext4                 type=83 (Linux)
 2      322GB   499GB   177GB   primary                         boot, type=a5(FreeBSD)
```

1.4. Step 4
After completing the FreeBSD installation process and rebooting the system, the FreeBSD bootloader was installed in the MBR and partition #2 becomes active (boot flag). Therefore the OpenSuse system (partition #1) will no longer boot. But don't worry - you can fix this fast!
Boot again the installation DVD of OpenSuse 12.1 and choose Rescue System.
Start parted and make again partition #1 active; set the boot flag with the command:

`# parted> set 1 boot on`

1.5. Step 5
Now you can boot into OpenSuse - but where is your FreeBSD? Again, don't worry - you can fix this fast!
You have to modify your GRUB configuration, that you are also able to boot FreeBSD. Insert following new menu entry of your FreeBSD system located on partition #2.

```
vi /boot/grub2/grub.cfg
```


```
menuentry 'FreeBSD' --class os {
    set root='(hd0,2)'
    chainloader +1
}
```

Please note, the recommended way to configure GRUB 2 is to use the custom menu as described here:
https://help.ubuntu.com/community/Grub2/CustomMenus

That's it! You've got it! Please enjoy your new FreeBSD/Linux multiboot system!


----------

