<?xml version="1.0" encoding="UTF-8"?>
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/gentoo-freebsd.xml,v 1.16 2006/03/30 08:41:57 neysx Exp $ -->
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">

<guide link="/doc/en/gentoo-freebsd.xml">
<title>A short guide to Gentoo/FreeBSD</title>

<author title="Author">
  <mail link="ignacio.arquelatour@gmail.com">Ignacio Arque-Latour</mail>
</author>
<author title="Author">
  <mail link="citizen428@gentoo.org">Michael Kohl</mail>
</author>
<author title="Author">
  <mail link="angusyoung@gentoo.org">Otavio R. Piske</mail>
</author>
<author title="Author">
  <mail link="ka0ttic@gentoo.org">Aaron Walker</mail>
</author>

<abstract>
This document gives some general information on FreeBSD, as well as
installation instructions for Gentoo/FreeBSD. It also includes some reference
for people interested in helping out with development.
</abstract>

<!-- The content of this document is licensed under the CC-BY-SA license -->
<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
<license/>

<version>2.3</version>
<date>2006-03-24</date>

<chapter>
<title>Introduction to FreeBSD</title>
<section>
<title>What is FreeBSD?</title>
<body>

<p>
<uri link="http://www.freebsd.org/">FreeBSD</uri> is a free (<uri
link="http://www.freebsd.org/copyright/freebsd-license.html">license</uri>)
Unix-like operating system. Back in 1993 when development of <uri
link="http://www.386bsd.org/">386BSD</uri> stopped, two projects were born:
<uri link="http://www.netbsd.org/">NetBSD</uri>, commonly known to run on a
huge number of architetures, and FreeBSD which supports the x86, amd64, ia64, 
sparc64 and alpha platforms.FreeBSD is renowned for its stability, performance 
and security, thus being used from small to huge companies all over the world. 
FreeBSD's current production release version is 6.0, which is also used as the 
foundation for the Gentoo/FreeBSD project. The previous 5.x branch is being 
continued by the FreeBSD project as a service release, but is no more worked on by 
the Gentoo/FreeBSD developers.
</p>

</body>
</section>
<section>
<title>What is Gentoo/FreeBSD?</title>
<body>

<p>
<uri link="/proj/en/gentoo-alt/bsd/fbsd/">Gentoo/FreeBSD</uri> is a subproject of the 
<uri link="/proj/en/gentoo-alt/">Gentoo/Alt project</uri>,  with the goal of providing 
a fully-capable FreeBSD operating system featuring the design sensibilities known from 
Gentoo Linux, like the init system and the portage package management system.
</p>

</body>
</section>
<section>
<title>FreeBSD and Linux</title>
<body>

<p>
Users migrating from Linux to FreeBSD commonly consider the two operating
systems "almost the same". In fact, FreeBSD really shares a lot of similarities
with Linux distributions in general. Nevertheless, it has some key differences
that are worth noting:
</p>

<ul>
  <li>
    Contrary to Linux, which actually only refers to the kernel, FreeBSD is a
    complete operating system, consisting of a C library, userland tools and
    much more. This development approach makes the overall system very
    consistent.
  </li>
  <li>
    Contrary to the Linux kernel, FreeBSD development is not led by one person,
    but instead managed by a small group of people called the <uri
    link="http://www.freebsd.org/doc/en_US.ISO8859-1/articles/contributors/staff-core.html">Core
    Team</uri>.
  </li>
</ul>

<p>
Besides, FreeBSD also has some technical differences which set it apart
from Linux. Some of them are very important to know, even if you don't plan on
joining the Gentoo/FreeBSD development effort:
</p>

<ul>
  <li>
    To get run-time dynamic linking functions like <c>dlopen()</c>, programs do
    not need to be linked against libdl like on GNU/Linux. Instead they are
    linked against libc.
  </li>
  <li>
    FreeBSD doesn't have an official tool for kernel compilation, thus you'll
    have to resolve feature dependencies on your own.
  </li>
  <li>
    FreeBSD uses UFS/UFS-2 as its filesystems and has no official support for
    e.g. ReiserFS or XFS. However, there are projects for adding read-only
    support for these filesystems. Accessing ext2/ext3 partitions is already
    possible, but you cannot install your system on them.
  </li>
</ul>

</body>
</section>
</chapter>

<chapter>
<title>Installing Gentoo/FreeBSD</title>
<section>
<title>Installation instructions</title>
<body>

<p>
After this short introduction, it's about time to finally install
Gentoo/FreeBSD. Unfortunately, we currently lack our own installation media, so
you have to choose between two alternative installation methods. The first
would be to use an existing FreeBSD installation to partition your hard drive
and use it as a base for installing Gentoo/FreeBSD. Alternatively, you can also
use the excellent <uri link="http://www.freesbie.org/">FreeSBIE LiveCD</uri> as
an installation medium for Gentoo/FreeBSD.
</p>

<note>
If you are intending to use FreeSBIE for installing Gentoo/FreeBSD, please make
sure to use a version based on FreeBSD 6.0! Experimental versions can be downloaded 
from <uri link="http://torrent.freesbie.org/">FreeSBIE's Bittorrent tracker</uri> and 
version 20060118 has been tested to work for the purposes described in this document.
</note>

<p>
Before you can begin with the installation, you have to setup a hard disk for
use with Gentoo/FreeBSD. This can either be done via <c>sysinstall</c>
(available from a current FreeBSD installation as well as from within FreeSBIE)
or by manually using the commands <c>fdisk</c>, <c>disklabel</c> and <c>newfs</c>. 
If you have never set up a FreeBSD system before, <c>sysinstall</c> may be the 
better option for you. In that case make sure that you don't use the sysinstall
launched by FreeBSD's or FreeSBIE's installers, but use the following command instead:
</p>

<pre caption="Partitioning with sysinstall">
# <i>sysinstall diskPartitionEditor diskPartitionWrite diskLabelEditor diskLabelCommit</i>
</pre>

<p>
If you face difficulties
while partitioning or formatting your hard disks, have a look at the great
<uri link="http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/">FreeBSD
Handbook</uri> or hop onto <c>#gentoo-bsd</c> on the Freenode IRC server.
</p>

<p>
Once you're done setting up your disks, you have to create a mount point for
your Gentoo/FreeBSD installation and mount all the necessary partitions.
</p>

<pre caption="Creating a mount point and mounting partitions">
# <i>mkdir /mnt/gentoo</i>
<comment>(Replace X with the correct numbers for your hard disk.)</comment>
# <i>mount /dev/adXsXa /mnt/gentoo</i>
</pre>

<p>
If you're using the FreeSBIE LiveCD and you already had an UFS partition on 
your hard disk, it has already been mounted read-only to <path>/mnt/ufs.1</path>. 
If you want to use that location for your installation, you'll have to remount it
in read-write mode:
</p>

<pre caption="Remounting a partition in read-write mode">
# <i>mount -u -o rw /mnt/ufs.1</i>
</pre>


<p>
Now that you have mounted the target partition, it is time to fetch and unpack
a stage3 tarball.
</p>

<pre caption="Obtaining and unpacking a stage3 tarball">
# <i>cd /mnt/gentoo/</i>
<comment>(Any other Gentoo mirror which includes the experimental/ directory will also work.)</comment>
# <i>wget http://gentoo.osuosl.org/experimental/x86/freebsd/stages/gentoo-freebsd-6.0-stage-20060221.tar.bz2</i>
# <i>tar -jxvpf gentoo-freebsd-6.0-stage-20060221</i>
<comment>(You can delete the tarball with the following command if you want to.)</comment>
# <i>rm gentoo-freebsd-6.0-stage-20060221</i>
</pre>

<p>
Before chrooting into the newly-extracted stage, you first must obtain an
up-to-date copy of the Gentoo/FreeBSD overlay. The easiest way to achieve this
is to to get our latest snapshot which you then extract to
<path>/mnt/gentoo/usr/local/portage</path>.
</p>

<pre caption="Getting the Gentoo/FreeBSD Portage overlay">
# <i>cd /mnt/gentoo/usr/local/portage</i>
# <i>wget http://gentoo.osuosl.org/experimental/snapshots/portage-alt-overlay-latest.tar.bz2</i>
# <i>tar -xjf portage-alt-overlay-latest.tar.bz2</i>
<comment>(You now can safely delete the snapshot with the following command.)</comment>
# <i>rm portage-alt-overlay-latest.tar.bz2</i>
</pre>

<p>
Alternatively, you can also use Subversion to check out the current version of
the overlay. If you are interested in this possibility, please refer to the 
<uri
link="/proj/en/gentoo-alt/contribute/index.xml?part=1&amp;chap=3">Gentoo/ALT 
overlay documentation</uri>.
</p>

<p>
In order for your install to work, you need to mount the <path>/dev</path>
filesystem from the currently running system into the Gentoo/FreeBSD mount
point before proceeding with the chroot.
</p>

<pre caption="Mounting the /dev filesystem and chrooting">
# <i>mount -t devfs none /mnt/gentoo/dev/</i>
# <i>cp /etc/resolv.conf /mnt/gentoo/etc</i>
# <i>chroot /mnt/gentoo/ /bin/bash</i>
# <i>source /etc/profile</i>
</pre>

<p>
After you got hold of the Gentoo/FreeBSD overlay, it's time to link
<path>/etc/make.profile</path> to the correct profile and add get your
<path>/etc/make.conf</path> ready for Gentoo/FreeBSD.
</p>

<pre caption="Setting up the profile and editing /etc/make.conf">
# <i>ln -sf /usr/local/portage/portage-alt-overlay/profiles/default-bsd/fbsd/6.0/x86/ /etc/make.profile</i>
<comment>(FreeBSD's standard editor is ee, which is used to edit /etc/make.conf)</comment>
# <i>ee /etc/make.conf</i>
<comment>(Please make sure you add at least the following entries:)</comment>
CHOST="i686-gentoo-freebsd6.0"
ACCEPT_KEYWORDS="~x86-fbsd ~x86"
FEATURES="-sandbox collision-protect"
PORTDIR_OVERLAY="/usr/local/portage/portage-alt-overlay"
</pre>

<note>
If you're installing using an old 5.4 stage, please replace "5.4" by "6.0" when symlinking the profile and 
setting the CHOST variable.
</note>

<p>
In order to boot correctly, you will need to create the <path>/proc</path>
directory.
</p>

<pre caption="Creating the /proc directory">
# <i>mkdir /proc</i>
</pre>

<p>
Now, you have to obtain a copy of the main Gentoo Portage tree, which depending
on your connection might take quite a while.
</p>

<pre caption="Obtaining the Portage tree">
# <i>emerge --sync</i>
<comment>(It's also possible to retrieve the Portage tree in another way:)</comment>
# <i>cd /</i>
# <i>wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2</i>
# <i>tar -xjf portage-latest.tar.bz2 -C /usr/</i>
# <i>emerge --metadata</i>
</pre>

<p>
If you want, you can now rebuild the system's core packages.
</p>

<pre caption="Rebuilding the FreeBSD core packages (Optional)">
# <i>emerge -e system</i>
</pre>

<p>
When you did <c>emerge -e system</c>, the sources for the FreeBSD kernel got
installed to <path>/usr/src/sys</path>. If you skipped this step, you can get
them in the following way:
</p>

<pre caption="Geting the FreeBSD kernel sources">
# <i>emerge freebsd-sources</i>
</pre>

<p>
Configuring and compiling a custom kernel is really different from compiling
Linux, so if you are not familiar with the process we encourage you to have a
look at <uri
link="http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html">
chapter 8</uri> of the FreeBSD handbook.
</p>

<p>
Please note that currently only the "Traditional" way of building the kernel is
supported on Gentoo/FreeBSD! Also note that <c>make install</c> will probably
ask you for a <path>/boot/device.hints</path> file. A default version can be
found in the <path>conf</path> subdirectory of the <c>GENERIC</c> configuration
and is called <path>GENERIC.hints</path>.
</p>

<note>
When building a kernel, you should use the command "make WERROR=NO_WERROR"
because the Gentoo/FreeBSD developers have not yet been able to patch out all
occurrences of -Werror and the currently used GCC doesn't accept FreeBSD's
extensions to the printf() function.
</note>

<p>
Now is the time to do some basic system configuration and settings. First, we
are going to setup the filesystem mounting points in <path>/etc/fstab</path>.
</p>

<pre caption="Editing the filesystem in /etc/fstab">
# <i>ee /etc/fstab</i>
<comment>(This is an example, replace X and Y with the correct numbers for your hard disk.)</comment>
#Device         Mountpoint      Fstype          Options         Dump    Pass
/dev/adXsYb     none            swap            sw              0       0
/dev/adXsYa     /               ufs             rw              1       1
/dev/adXsYe     /usr/home       ufs             rw              2       2
/dev/adXsYd     /tmp            ufs             rw              2       2
/dev/acdX       /cdrom          cd9660          ro,noauto       0       0
</pre>

<p>
Now would also be a good time to set up your network connection before the final
reboot.
</p>

<pre caption="Setting up your network">
# <i>ee /etc/conf.d/net</i>
<comment>(This is just an example which you have to adjust for your network.)</comment>
ifconfig_rl0=("192.168.0.10 netmask 255.255.255.0 broadcast 192.168.0.255")
routes_rl0=("-net 0.0.0.0 -host 192.168.0.1")
</pre>

<p>
To have your network interface activated at boot time, you have to add it to the default runlevel.
</p>

<pre caption="Adding your network adapter to the default runlevel">
# <i>rc-update add net.rl0 default</i>
</pre>

<p>
Your system's hostname can be changed in  <path>/etc/hostname</path>.
</p>

<pre caption="Setting up the machine's hostname">
# <i>echo "YOUR_HOSTNAME_HERE" > /etc/hostname</i>
</pre>

<p>
In case you need to use another keyboard layout for your language, you have to
set the correct value in <path>/etc/conf.d/syscons</path>. The following example
uses the Spanish layout, so you'll have to adjust it to your need if you want to
use another one.
</p>

<pre caption="Changing your keyboard layout (Optional)">
# <i>ee /etc/conf.d/syscons</i>
KEYMAP="spanish.iso.acc"
<comment>(Possible layouts can be found in /usr/share/syscons/keymaps).</comment>
</pre>

<impo>
Please make absolutely sure you add your new Gentoo/FreeBSD installation to the
configuration of your bootloader, otherwise you won't be able to boot your newly
installed system! If you don't have another bootloader installed, you should use
<c>boot0</c>, as it is currently the only one supported by FreeBSD. In this case
please don't forget to use your other operating systems to <c>boot0</c>'s
configuration.
</impo>

<pre caption="Installing and setting up boot0">
# <i>emerge boot0</i>
<comment>(Leave the chroot environment)</comment>
# <i>exit</i>
<comment>(Issued from outside the chroot)</comment>
# <i>fdisk -B -b /mnt/gentoo/boot/boot0 /dev/adX</i>
# <i>chroot /mnt/gentoo /bin/bash</i>
# <i>disklabel -B adXsY</i>
</pre>

<p>
If you need additonal information on setting up <c>boot0</c>, please consult
<uri
link="http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/boot.html">chapter
12</uri> of the FreeBSD handbook.
</p>

<p>
Now would be a good time to set a password for the <c>root</c> user and to add
another user account for your day-to-day work.
</p>

<pre caption="Changing the root password and adding a new user">
# <i>passwd</i>
<comment>(If you need help in adding a user please consult the FreeBSD handbook).</comment>
# <i>adduser</i>
</pre>

<p>
Congratulations, you have just finished your Gentoo/FreeBSD installation which
you can start exploring after the final reboot. Have fun!
</p>

<pre caption="Rebooting the system">
# <i>exit</i>
# <i>reboot</i>
</pre>

</body>
</section>
</chapter>

<chapter>
<title>Developing for Gentoo/FreeBSD</title>
<section>
<title>How to help</title>
<body>

<p>
There are many things you could help with, depending on your skill level and
spare time:
</p>

<ul>
  <li>
    Working on current ebuilds: this means working closely with ebuild
    maintainers in order to create patches or modify ebuilds in a way that can
    be accepted into the main tree.
  </li>
  <li>
    Security: if you are into security, we need you! Although security
    advisories from the FreeBSD project are tracked and fixed, we can always
    use help in this area.
  </li>
  <li>
    Contacts: we need people who can get in touch with FreeBSD developers to
    maintain contacts between us and the original project to exchange patches
    and discuss various problems and their solutions. Note that this should
    never involve any kind of spamming of mailing lists or IRC channels.
  </li>
  <li>
    Testing: the more people are actively using Gentoo/FreeBSD, the more bugs
    will be discovered, which helps us improving the quality of the port. If
    you are good at describing bugs or problems, we definitely want to hear
    from you.
  </li>
  <li>
    Other areas where we need help include: system ebuilds, baselayout,
    creation of installation CDs, documentation, kernel hacking.
  </li>
</ul>

</body>
</section>

<section>
<title>Known issues</title>
<body>

<p>
At the moment, there are still quite a lot of known issues. Here are the ones
really worth noting:
</p>

<ul>
  <li>
    Some init scripts depend on the clock service which we don't provide right
    now. You can just remove it from the dependencies of the script and report
    that on our <uri link="http://bugs.gentoo.org/">bugzilla</uri>. Please
    remember to use the "Gentoo BSD" product for your submission.
  </li>
  <li>glib and gnome in general need a lot of fixes to be backported.</li>
  <li>
    The init system currently provided by Gentoo/FreeBSD's baselayout package is 
    not the same version used by Gentoo Linux and lacks some of its features. Work 
    on making newer versions working is underway.
  </li>
</ul>

</body>
</section>
</chapter>

<chapter>
<title>Contact</title>
<section>
<body>

<p>
A list of Gentoo/FreeBSD developers can be found at the <uri
link="/proj/en/gentoo-alt/bsd/fbsd/">project page</uri>. Other ways to contact
Gentoo/FreeBSD developers include our IRC Channel <c>#gentoo-bsd</c> on
Freenode, as well as the <uri link="/main/en/lists.xml">gentoo-bsd mailing
list</uri>.
</p>

</body>
</section>
</chapter>
</guide>
