Dual-Boot Configuration of FreeBSD and Gentoo Linux




This document describes the installation of FreeBSD (5.5-RELEASE) and Gentoo Linux (2.6.22-r9) in a dual-boot configuration.


I. FreeBSD Installation




1. Download ISO images from FreeBSD.org and Burn to CD

Connect to the FreeBSD ftp server:

ftp.freebsd.org/pub/FreeBSD/ISO-IMAGES-i386/5.5

Download:

5.5-RELEASE-i386-disc1.iso
5.5-RELEASE-i386-disc2.iso

and burn each image to a CD.

2. Sysinstall Main Menu

Boot up from CD disc1 and you'll come to the Sysinstall Main Menu [1].
Select "Standard installation". You will be prompted to set up a partitioning scheme using FDISK.

Press 'OK' twice to pass messages to get to the FDISK utility.

3. FDISK Partition Editor

Select 'C' to create a new slice.

You'll be prompted to specify the size of a new FreeBSD slice in blocks or in megabytes by appending a trailing 'M'.

Since the hard drive will be split in half into two separate partitions, each containing the filesystems of its OS, specify the size in megabytes.

In our example, 125GB of disk space is allocated, so 125000M is entered.

Press 'OK'.

4. Enter Type of Partition to Create

Press ENTER to choose the default (type 165) which is a native FreeBSD slice.

Highlight the freebsd partition and select 'S' to make this partition bootable.

As an example, the FDISK Partition Editor shows new partition table:

   Offset        Size(ST)        End        Name        PType        Desc        Subtype        Flags
   ------        --------        ---        ----        -----        ----        -------        -----
   0             63              62         -           12           unused      0
   63            255995712       255995774  ad0s1       8            freebsd     165            A
   255995775     232401393       488397167  -           12           unused      0
   
Select 'Q' to Finish.

5. Install Boot Manager

Install the FreeBSD Boot Manager (BootMgr) which is highlighted by default, select 'OK' and hit ENTER.

This will later be overwritten by Grub, but for now configure FreeBSD's Boot Manager.

6. Create BSD partitions (filesystems)

Select 'OK' and hit ENTER to continue until the FreeBSD Disklabel Editor is reached.

Perform the following commands to create the new filesystems.

/:
Select 'C'.
Enter '132M', select 'OK', and hit ENTER.
Select 'FS' and hit ENTER.
Enter '/' as a mount point and hit ENTER.

Swap:
Select 'C'.
Enter '1G', select 'OK', and hit ENTER.
Select 'Swap' and hit ENTER.

/home:
Select 'C'.
Enter '10G', select 'OK', and hit ENTER.
Select 'FS' and hit ENTER.
Enter /home as mount point and hit ENTER.

/usr:
Select 'C'.
Enter '80G', select 'OK', and hit ENTER.
Enter /usr as mount point and hit ENTER.

/var:
Select 'C'.
Select 'OK' to accept the remaining number of free blocks.
Select 'FS' and hit ENTER.
Enter /var as mount point and hit ENTER.

The following filesystems are displayed:

   Part        Mount        Size        Newfs
   ----        -----        ----        -----
   ad0s1a      /            132MB       UFS2 Y
   ad0s1b      swap         1024MB      SWAP
   ad0s1d      /home        10240MB     UFS2+S Y
   ad0s1e      /usr         81920MB     UFS2+S Y
   ad0s1f      /var         316881MB    UFS2+S Y

Select 'Q' to Finish.

7. Choose PrePackaged Distribution Sets

There are several prepackaged distribution sets to choose from. Select the following to ensure that all sources will be extracted:

'Developer'
'X-Developer'
'Kern-Developer'
'X-Kern-Developer'
'User'

Next, highlight 'Exit' and 'OK' and hit ENTER.

Also, confirm that the FreeBSD ports collection is to be installed from CD. So select 'Yes' from the User Confirmation Requested screen.

At this point, sources will be copied from CD to disk while progress of the extraction is displayed.

Hit 'OK' from the installation congratulatory screen.

8. Configure Networking

You will be asked the following questions, please answer accordingly.

Would you like to configure network devices? ==> 'Yes'
Select the ethernet card from the displayed list and hit 'OK'.
Would you like to configure IPv6 on the Ethernet interface? ==> 'No'
Would you like to configure DHCP on the Ethernet interface? ==> 'No'

Now enter Network configuration information:

Host: yourhost
Domain: yourdomain.com
IPv4 Gateway: 10.0.0.1
Name Server: 68.87.76.178 (any nameserver ip)
IPv4 Address: 10.0.0.6
Netmask: 255.255.255.0

As information is entered, some fields may be dynamically populated (such as the netmask field).

Press TAB to select 'OK' and hit ENTER.

Would you like to bring the XXX interface up right now? ==> 'Yes'

Do you want this machine to function as a network gateway? ==> 'No'

Do you want to configure inetd and the network services that it provides? ==> 'No'

Would you like to enable SSH login? ==> 'Yes'

Do you want to have anonymous FTP access to this machine? ==> 'No'

Do you want to configure this machine as an NFS server? ==> 'No'

Do you want to configure this machine as an NFS client? ==> 'No'

Would you like to customize your console settings? ==> 'No'

Would you like to set this machine's time zone now? ==> 'Yes'

Is this machine's CMOS clock set to UTC? If it is set to local time, or you don't know, please choose NO here! ==> 'No"

9. Time Zone Selector

Select 'America -- North and South'

Select 'United States'

Select 'Pacific Time'

Does the abbreviation 'PST' look reasonable? ==> 'Yes'

10. Set Other Configuration Parameters

Would you like to enable Linux binary compatibility? ==> 'Yes'

Does this system have a PS/2, serial, or bus mouse? ==> 'No'

Next, you will be prompted to browse any number of software packages. Some to choose are:

Xorg (if you want to run X)
vim
bash
Would you like to add initial user accounts to the system? ==> 'Yes'

10. User and Group Management

Select 'Add a new User' and fill in the fields. If you're adding an account for yourself, add yourself to the "wheel" group in order to su to root.

Exit this screen and set the root password.

Visit the general configuration menu for a chance to set any last options? ==> 'No'

Select 'X Exit Install' and hit ENTER.

Are you sure you wish to exit? ==> 'Yes'

As machine is rebooting, remove CD from drive.

Your FreeBSD installation is complete.

II. Gentoo Linux Installation




Closely follow the installation instructions from the Gentoo Linux x86 handbook for installing the distribution from a Minimal CD[2]:

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?full=1

Keep in mind that there is an existing FreeBSD partition at this point. So, in Section 4.c., create the following partitions using Gentoo's fdisk utility:

    Partition        Description
    ---------        -----------

    /dev/hda2        Boot partition        32MB
    /dev/hda3        Swap partition        1GB
    /dev/hda4        Root partition        <Rest of the disk>
After executing the command 'fdisk /dev/hda' and typing p to display the current partition table, the following will be displayed (per our example):

    Device        Boot        Start        End        Blocks        Id         System
    ------        ----        -----        ---        ------        --         ------

    /dev/hda1     *           1            15935      127997856     a5         FreeBSD
We want to add the new Linux partitions to this table.

Create new partitions following Section 4 in the Gentoo Handbook. Once done the following is displayed (per our example).

    Device        Boot        Start        End        Blocks        Id         System
    ------        ----        -----        ---        ------        --         ------
    /dev/hda1     *           1            15935      127997856     a5         FreeBSD
    /dev/hda2     *           15936        15940      40162+        83         Linux
    /dev/hda3                 15941        16065      1004062+      82         Linux Swap/Solaris
    /dev/hda4                 16066        30401      115153920     83         Linux
Type w to save partition table.

Next, create the filesystems, but make sure to use the correct devices.

      # mke2fs /dev/hda2
      # mke2fs -j /dev/hda4
      # mkswap /dev/hda3
      # swapon /dev/hda3
      # mount /dev/hda4 /mnt/gentoo
      # mkdir /mnt/gentoo/boot
      # mount /dev/hda2 /mnt/gentoo/boot
   
Continue with installing the Gentoo Installation Files in Section 5 onward.

When configuring /etc/fstab in Section 8, the following may be used (per our example):

      /dev/hda2   /boot        ext2    defaults,noatime     1 2
      /dev/hda3   none         swap    sw                   0 0
      /dev/hda4   /            ext3    noatime              0 1
   
When configuring Grub and the grub.conf file, use the following configuration:

       default 0
       timeout 30

       title=Gentoo Linux 2.6.22-r9
       root (hd0,1)
       kernel /boot/kernel-2.6.22-gentoo-r9 root=/dev/hda4

       title=Gentoo Linux 2.6.22-r9 (rescue)
       root (hd0,1)
       kernel /boot/kernel-2.6.22-gentoo-r9 root=/dev/hda4 init=/bin/bb

       title=FreeBSD 5.5-RELEASE
       root (hd0,0,a)
       kernel /boot/loader
    
Once all configuration changes above have been completed, remove any CDs, and reboot the system.

You should be able to boot into either FreeBSD or Gentoo Linux with Grub.

III. References


[1] "Chapter 2: Installing FreeBSD." FreeBSD Handbook. 2007. 19 Nov. 2007 <http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/install-steps.html>.

[2] "Gentoo Linux x86 Handbook." Gentoo.org. 18 Nov. 2007. 19 Nov. 2007 <http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?full=1>.


Teresa Johnson
Last Modified: Friday, 30-Nov-2007 08:08:08 UTC