Since I went through this exercise to do my review of PC-BSD, I decided to write a quick howto on dual booting the two, and also living with both on your computer. I will explain how to modify and configure GRUB2, and also how to mount the UFS file-system of PC-BSD 8.0 via terminal.

Interested? Let’s dive right in…

A Few Notes Before You Begin

The PC-BSD boot-loader is ugly, I prefer GRUB, yes even GRUB2, to the PC-BSD boot-loader. We are going to use GRUB for this excercise, but you should be able to install either PC-BSD first, or Ubuntu Karmic first, well explore both options.

PARTITIONING

I am assuming that you have at least one available partition to install either operating system on. If you don’t, G-Parted is a nice graphical tool that is included in Ubuntu for partitioning, or you can use the partioner during the Ubuntu installation to partition your drives. Beware though, I don’t know how kind the BSD UFS filesystem is to being partitioned, so do at your own risk. A golden rule of computer use for me is having at least one partition of about 20Gigs minimum where I can install new operating systems. BEWARE: Partitioning destroys whatever data used to be on that part of the disk – data loss is possible.

Option 1: Ubuntu  Karmic Koala First, and then PC-BSD 8.0

Let’s say you are an Ubuntuphile, and would like to try something new and PC-BSD is your poison of choice.

Install Ubuntu if you haven’t yet, and make sure you create an extra partition where PC-BSD 8.0 will live. Once you have finished installing Ubuntu you will have done the easy part. Now for installing PC-BSD 8.0

The PC-BSD installer is a little less user friendly than the Ubuntu one, so keep your wits about you and READ BEFORE YOU CLICK. You will be presented with your installation location in due course, and make sure you select the correct partition (I judge them by size.) If you are unsure you can try and mount the different partitions by pressing ALT+CTRL+F2 and logging in as root. The shell environment is very similar to Ubuntu, so you can do a mount and check the various partitions if you like.

If you fail to do so (as I did a few times) you can reboot and make sure of the file partitions before installing. Yes this seems like a lot of work, but /dev/ad1s1a is a lot less descriptive and more confusing than /dev/sda1, especially if you have a 20Gig partition housing Win7, and a 19Gig partition where you want to install PC-BSD

Once you have selected the correct partition you will note that at the bottom of this screen there is a tick-box that asks if you want to install the PC-BSD bootloader. DON’T. We will be editing GRUB2 in order to boot PC-BSD, in my experiance the PC-BSD bootloader is as unreliable in loading other operating systems as it is ugly.

Once installed you are done for now, reboot into Ubuntu and we will be manually configuring GRUB2 next.

Option 2: PC-BSD 8.0 first, and then Ubuntu Karmic Koala

If you have installed, or been using PC-BSD and would like to get your Ubuntu on, you basically do the reverse of above. You pop in the Ubuntu CD, and run the installer. Other than with PC-BSD the option to not install GRUB is less apparent. Install GRUB, you should be fine even if GRUB2 does not detect your BSD install.

Beware if you partition your hard-drive while installing Ubuntu, I am not sure how well UFS likes being treated like this, as I have said – I keep a spare partition handy for such occasions.

Configuring GRUB2

Here we will be delving into the command line a bit, if only to tell GRUB where your BSD installation is located, and how to boot it.

First off, find out where your BSD install is:

Type in:

dmesg | grep bsd

and note the output, it should be something like below:

[    1.198697]  sda3: <bsd:

sda3 is the important bit, it could be sda1, sdb1, 2 or whatever. It is where your BSD lives. In order to tell GRUB where sda3 (in my case) is you will need to understand how GRUB approaches partitions and harddrives. sda is hd0 in GRUB parlance, and GRUB starts numbering from 0, where sda1 would be hd0,1 to GRUB. If you have only one harddrive in your computer it will always be hd0, and if you have two drives, sda would be hd0 and sdb would be hd1 and so on. So sda3, where my BSD lives, would be hd0,3.

Now on to configuring GRUB to boot PC-BSD on sda3. If you look under /etc in Ubuntu there is a directory called grub.d. In /etc/grub.d you will find a file called 40_custom, this is a file that GRUB reads whenever it gets reconfigured in order to pick up custom user configurations. This is the file we will be editing to be able to boot BSD.

In the terminal enter the following:

sudo gedit /etc/grub.d/40_custom

Enter your password and the gedit text editor will appear with the contents of 40_custom. Edit the file until it looks like this, make sure that you have the correct partition specified – below is my 40_custom:

#!/bin/sh
exec tail -n +3 $0
menuentry “PCBSD 8 X64″ {
set root=(hd0,3)
chainloader +1
}

# 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.

Once you have done that it is time to get GRUB2 to load this file, do this with the following command:

sudo update-grub

Once done your file should now be included in the GRUB boot menu when you switch on the computer, it will be the last entry.

Now some people will want to edit the grub menu directly, but I advise against this because every time GRUB gets updated it will overwrite the custom entries you put in. Rather create a custom file like above and GRUB will always detect it and load it at boot. Beware thought that once you have installed something else you will need to remove this file or comment out the entries you don’t want any more with # otherwise you will have a grub filled with no longer existing installs.

Mounting BSD partitions in Ubuntu Karmic Koala

In BSD your Ubuntu partitions should be visible and accessable, unless you are one of those who use weird filesystems. Mounting BSD partitions in Ubuntu is a different proposition, however. You will note that Nautilus (the Ubuntu file manager) does not list the PC-BSD partition, and you will have to mount it from the command-line. Here’s how we will do it.

First, make a directory where you will mount your BSD partition:

sudo mkdir /mnt/ufspartition

THEN, find out exactly where the BSD partition is:

dmesg | grep bsd

Note the output, yes we are basically repeating the steps above to configure grub at this point;

[    1.198697]  sda3: <bsd:

Now to mount /dev/sda3 into /mnt/ufspartition, here’s how:

sudo mount -t ufs -r -o ufstype=ufs2 /dev/sda3 /mnt/ufspartition

This will mount the partition read only, for now UFS write support is noted as experimental, so I will not show you how to mount the disk as writeable – especially since this involves recompiling your kernel with UFS write support. If you want to do that do so at your own peril.

Summary

And there you have it. Dual booted Ubuntu Karmic Koala and PC-BSD 8.0, you can follow these steps to dual boot Ubuntu and most any other operating system.

Enjoy!

No related posts.