FreeBSD is a free (license) Unix-like operating system. Back in 1993 when development of 386BSD stopped, two projects were born: NetBSD, commonly known to run on a huge number of architectures, 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 is version 7.1. Gentoo/FreeBSD is based on version 6.2 and older versions of Gentoo/FreeBSD are discontinued and no longer supported.
Gentoo/FreeBSD is a subproject of the Gentoo/Alt project, with the goal of providing a fully-capable FreeBSD operating system featuring design sensibilities taken from Gentoo Linux, such as the init system and the Portage package management system.
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:
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:
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. This guide will describe how to use the FreeSBIE LiveCD as an installation medium for Gentoo/FreeBSD.
Note: If you are intending to use FreeSBIE for installing Gentoo/FreeBSD, please make sure to use a version based on FreeBSD 6.x, such as FreeSBIE 2.0 (or one of its release candidates). You can download it from FreeSBIE's Bittorrent tracker. |
First, boot the CD in order to begin the installation process. You'll be presented with a login screen. The username is freesbie, and there is no password. Next, run sudo su to become root, and optionally setup a password. If you want to pass time during the installation process, you can run startx to enter into an Xfce environment, suitable for web browsing, AIM, and other things. Unlike Linux, FreeBSD bases the name of your interface on the driver for the interface. For example, the Intel EtherExpress driver (fxp) appears as fxp0 (driver fxp, first network card). To see what your interface is, use ifconfig:
Code Listing 2.1: Finding out the network interface name using ifconfig |
# ifconfig
fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=8<VLAN_MTU>
inet6 fe80::2d0::b7ff:febc:4fe3%fxp0 prefixlen 64 scopeid 0x1
inet 192.168.0.106 netmask 0xffffff00 broadcast 192.168.0.255
ether 00:d0:b7:bc:4f:e3
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
lo0: flags=8007<LOOPBACK,MULTICAST> mtu 16384
|
If the original DHCP request during the CD bootup failed, you can use the dhclient command to obtain an IP:
Code Listing 2.2: Obtaining a DHCP address using dhclient |
# dhclient fxp0
DHCPDISCOVER on fxp0 to 255.255.255.255 port 67 interval 9
DHCPOFFER from 192.168.0.1
DHCPREQUEST on fxp0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.1
bound to 192.168.0.106 -- renewal in 302400 seconds
|
Note: The output presented here will differ based on your network. |
Now that we have a mount point, it's time to partition the drive. This is done with the sysinstall command:
Code Listing 2.3: Running the sysinstall command to fdisk the drive |
# sysinstall diskPartitionEditor diskPartitionWrite
|
We recommend that you use the default layout. Press enter at the dialog, then press a followed by q to accept the default layout. The next screen will present you with the option of a bootloader. For this option, choose "None" as we'll be installing the bootloader later on. Next comes the actual partition sizing and mount points.
This next step also uses sysinstall, but with different arguments:
Code Listing 2.4: Running sysinstall to setup partition sizing and mount points |
# sysinstall diskLabelEditor diskLabelCommit
|
Here, we'll refrain from using the automatic layout, and create one giant root partition, followed by a swap partition. Hit c to create a new partition. A dialog prompts you to enter a size. Go ahead and do so, using MB/GB for setting different sizes, or C for cylinders. For root, choose FS as the partition type, and set the mount point as /mnt/. If you do not adjust the mount point, it will overwrite the FreeSBIE environment! As /boot is not a separate partition, you'll need to disable soft-updates, or your system will not boot! To do so, use the arrow keys to navigate to your newly created partition, then hit the s key, until "Newfs" contains no +S. Now navigate the arrow keys until the "Disk" line is highlighted, and hit c again to create a swap partition. Generally, we recommend a swap space that is twice the size of your RAM. Choose SWAP as the partition type, and don't worry about soft-updates, as it does not apply to swap. Now we're finished, so hit q to finish the process.
When choosing a different mountpoint than / for your partition, sysinstall will actually create a 'd' slice, which the bootloader won't boot from. To fix this, run the following:
Note: Please, make sure ad0s1 is unmounted before running the following command, otherwise it will not work. |
Code Listing 2.5: Fixing the root partition letter |
# disklabel ad0s1 | sed 's/^ d:/ a:/' | disklabel -R ad0s1 /dev/stdin
|
This will finalize the partitioning process, and format the drive in UFS for FreeBSD to utilize. This will also mount the drive for you at the mount point specified earlier (/mnt/). You can verify this worked by running mount:
Code Listing 2.6: Verifying the new disk layout was mounted with mount |
# mount
...
/dev/ad0s1a on /mnt (ufs, local)
|
Now that you have mounted the target partition, it is time to start on the Gentoo setup.
First, we need to download a stage3 tarball and unpack it into the chroot. Point your browser to http://distfiles.gentoo.org/experimental/x86/freebsd/stages/, grab the latest snapshot, and unpack it into the mountpoint:
Code Listing 2.7: Obtaining and unpacking a stage3 tarball |
# cd /mnt/ (Any other Gentoo mirror which includes the experimental/ directory will also work.) # wget http://distfiles.gentoo.org/experimental/x86/freebsd/stages/stage3-x86-freebsd-6.2-r1.tar.bz2 # tar -jxvpf stage3-x86-freebsd-6.2-r1.tar.bz2 (You can delete the tarball with the following command if you want to.) # rm stage3-x86-freebsd-6.2-r1.tar.bz2 |
Note: If you want you can use the transition overlay that contains semi-experimental ebuilds with patches not yet in the main Portage tree, but does allow a wider range of supported packages, please refer to the Gentoo/ALT overlay documentation. Please note that the overlay is not critical and you can easily install and use Gentoo/FreeBSD without it. |
In order for your install to work, you need to mount the /dev filesystem from the currently running system into the Gentoo/FreeBSD mount point before proceeding with the chroot.
Code Listing 2.8: Mounting the /dev filesystem and chrooting |
# mount -t devfs none /mnt/dev/ # cp /etc/resolv.conf /mnt/etc/ # chroot /mnt/ /bin/bash # env-update && source /etc/profile |
After you obtain the Gentoo/FreeBSD overlay, it's time to link /etc/make.profile to the correct profile and get your /etc/make.conf ready for Gentoo/FreeBSD.
Now, you have to obtain a copy of the main Gentoo Portage tree, which depending on your connection might take quite a while.
Code Listing 2.9: Obtaining the Portage tree |
# emerge --sync (It's also possible to retrieve the Portage tree in another way:) # cd / # wget http://distfiles.gentoo.org/snapshots/portage-latest.tar.bz2 # tar -xjf portage-latest.tar.bz2 -C /usr/ # emerge --metadata |
Code Listing 2.10: Setting up the profile and editing /etc/make.conf |
# ln -sf /usr/portage/profiles/default-bsd/fbsd/6.2/x86/ /etc/make.profile # nano /etc/make.conf (Please make sure you add at least the following entries:) CHOST="i686-gentoo-freebsd6.2" FEATURES="collision-protect" |
Note: The ~x86-fbsd keyword does not yet fully cover the same tree as ~x86, but please do not put ~x86 in ACCEPT_KEYWORDS. Rather use /etc/portage/package.keywords to test packages, and report working packages on Bugzilla. |
If you want, you can now rebuild the system's core packages.
Code Listing 2.11: Rebuilding the FreeBSD core packages (optional) |
# emerge -e system
|
First make sure your date and time is set correctly using date yyyymmddHHMM. Use UTC time.
Code Listing 3.1: Set the date and UTC time |
(Check the clock) # date Mon Mar 6 00:14:13 UTC 2006 (Set the current date and time if required) # date 200603060016 (Format is yyyymmddHHMM) Mon Mar 6 00:16:00 UTC 2006 |
Next, set your time zone information by using the correct listing in /usr/share/zoneinfo.
Code Listing 3.2: Setting your timezone |
# ls /usr/share/zoneinfo (Using Brussels as an example) # cp /usr/share/zoneinfo/Europe/Brussels /etc/localtime # date Wed Mar 8 00:46:05 CET 2006 |
Edit /etc/conf.d/clock to define the time zone you used previously.
Code Listing 3.3: Edit /etc/conf.d/clock |
# nano -w /etc/conf.d/clock
TIMEZONE="Europe/Brussels"
|
If you ran emerge -e system, the sources for the FreeBSD kernel were installed to /usr/src/sys. If you skipped this step, you can get them in the following way:
Code Listing 3.4: Getting the FreeBSD kernel sources |
# emerge freebsd-sources
|
Configuring and compiling a custom kernel is quite different from compiling Linux, so if you are not familiar with the process we encourage you to have a look at chapter 8 of the FreeBSD handbook. For now, you can do an installation of the GENERIC kernel, which works on most systems. To begin, enter the source directory for the kernel:
Important: Please note that currently only the "Traditional" way of building the kernel is supported on Gentoo/FreeBSD! |
Code Listing 3.5: Entering the kernel source directory |
# cd /usr/src/sys/
|
Looking over the layout, you'll see various architectures and subdirectories for various parts of the kernel. To begin the installation, we head into the i386/conf/ directory:
Code Listing 3.6: The kernel configuration directory |
# cd i386/conf/ # ls .cvsignore GENERIC Makefile PAE DEFAULTS GENERIC.hints NOTES SMP |
The main files to note are GENERIC and GENERIC.hints. As it will be needed by the installation of the kernel, go ahead and copy GENERIC.hints file to /boot/device.hints:
Code Listing 3.7: Copying over the GENERIC.hints file |
# cp GENERIC.hints /boot/device.hints
|
This file is used by the kernel drivers for basic configuration information such as IRQ settings. Now it's time to configure the kernel. FreeBSD uses the config command to do this. config uses the given file (in this instance GENERIC) to copy over the required build files to a compile directory in the parent directory. GENERIC is similiar to the .config file for the Linux kernel. Run config to produce the build directory:
Code Listing 3.8: Configuring the kernel build |
# config GENERIC
Kernel build directory is ../compile/GENERIC
Don't forget to ''make cleandepend; make depend''
|
config has created a GENERIC build directory for us in the parent directory. cd into it, then run the following to do a complete build:
Code Listing 3.9: Building and installing the kernel |
# cd ../compile/GENERIC # make cleandepend && make depend && make && make install |
This will give us a complete kernel to work with. Now we'll need to setup the bootloader for the kernel to boot. The next chapter will discuss two methods of setting up the bootloader: boot0 and grub.
Setting up the bootloader (boot0)
Important: boot0 is the FreeBSD bootloader. Previously, it was the only supported bootloader until grub was introduced into ports with UFS slice support. To install and configure boot0, run the following. Remember to replace adXsY with the actual number and slice of your disk. |
Code Listing 3.10: Installing and setting up boot0 |
# emerge boot0 (Leave the chroot environment) # exit (Issued from outside the chroot) # fdisk -B -b /mnt/boot/boot0 /dev/adX # chroot /mnt/ /bin/bash # disklabel -B adXsY |
If you need additional information on setting up boot0, please consult chapter 12 of the FreeBSD handbook. Now it's time to do some basic system configuration and settings.
The next section will look at using the alternative bootloader, grub.
Setting up the bootloader (grub)
As of grub 0.97-r1, UFS slices are readable to grub. This lets us use grub as a bootloader, the prefered method for those coming from a Linux background. To begin, emerge grub and setup the label as bootable. Remember to replace adXsY with the actual number and slice of your disk.
Code Listing 3.11: Emerge grub |
# emerge grub # disklabel -B adXsY |
Now run grub to bring up the command prompt, and set up the partition as shown:
Code Listing 3.12: Setting up grub |
(This is done to prevent disk error 29) # sysctl kern.geom.debugflags=16 # grub (Example using ad0s1d) grub> root (hd0,0,d) Filesystem type is ufs2, partition type 0xa5 grub> setup (hd0) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/ufs2_stage1_5" exists... yes Running "embed /boot/grub/ufs2_stage1_5 (hd0)"... 14 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd0) (hd0)1+14 p (hd0,0,d)/boot/grub/stage 2 /boot/grub/menu.lst"... succeeded Done. grub> quit |
To make the loader find the kernel on a specific slice (the default is 'a'), add a vfs.root.mountfrom line to the /boot/loader.conf file:
Code Listing 3.13: Tell the loader where to look for the kernel |
# echo 'vfs.root.mountfrom="ufs:ad0s1d"' >> /boot/loader.conf
|
When you first boot, you may not receive a grub menu. If so, run this at the prompt:
Code Listing 3.14: Booting the kernel with no menu |
grub> find /boot/grub/stage1 (The output here is what you'll use in the next command) (hd0,0,d) grub> kernel (hd0,0,d)/boot/loader [FreeBSD-a.out, loadaddr=0x200000, text=0x1000, data=0x3a000, bss=0x0, entry=0x200000] grub> boot |
Note: For more information on configuring grub, please refer to the Gentoo Linux Handbook. |
Warning: Grub doesn't follow UFS symlinks so be sure to delete the /boot/grub/menu.lst symlink and to use menu.lst to setup Grub (grub.conf isn't used). |
First, we are going to setup the filesystem mounting points in /etc/fstab.
Code Listing 3.15: Editing the filesystem in /etc/fstab |
# nano /etc/fstab (This is an example, replace X and Y with the correct numbers for your hard disk.) #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 |
Now would also be a good time to set up your network connection before the final reboot. You can find all the information necessary to configure your network in the Gentoo Handbook. To have your network interface activated at boot time, you have to add it to the default runlevel:
Code Listing 3.16: Adding your network adapter to the default runlevel |
# rc-update add net.fxp0 default
|
Your system's hostname can be changed in /etc/conf.d/hostname.
Code Listing 3.17: Setting up the machine's hostname |
# nano /etc/conf.d/hostname (Set the HOSTNAME variable to your hostname) HOSTNAME="tux" |
You should also configure your domain name, which is done in the /etc/conf.d/domainname file:
Code Listing 3.18: Setting the domainname |
# nano /etc/conf.d/domainname (Set the dns_domain variable to your domain name, and lo to your local network interface) dns_domain_lo="homenetwork" |
If you have a NIS domain, you need to define it in the /etc/conf.d/domainname file:
Code Listing 3.19: Setting the NIS domainname |
# nano /etc/conf.d/domainname (Set the nis_domain variable to your NIS domain name, and lo to your local network interface) nis_domain_lo="my-nisdomain" |
Note: For more information on domainnames and networking, please refer to the Gentoo Linux Handbook, and please read the documentation in /etc/conf.d/net.example. |
In case you need to use another keyboard layout for your language, you have to set the correct value in /etc/conf.d/syscons. The following example uses the Spanish layout, so you'll have to adjust it to your need if you want to use another one.
Code Listing 3.20: Changing your keyboard layout (Optional) |
# nano /etc/conf.d/syscons KEYMAP="spanish.iso.acc" (Possible layouts can be found in /usr/share/syscons/keymaps). |
Now would be a good time to set a password for the root user and to add another user account for your day-to-day work.
Code Listing 3.21: Changing the root password and adding a new user |
# passwd # adduser Username: fred Full Name: Fred Smith (Accepting the default here, just hit Enter.) Uid (Leave empty for default): (OK to accept the default here as well; hit Enter.) Login group [fred]: (Enter your groups here, space separated. They must exist.) Login group is fred. Invite fred into other groups? []: wheel portage (OK to accept the default here, hit Enter) Login class [default]: (Somewhat of a personal preference. Make sure the shell exists in /etc/shells) Shell (sh bash tcsh csh esh ksh zsh sash nologin) [sh] bash (OK to accept the default here, hit Enter for all these) User password-based authentication [yes] Use an empty password (yes/no) [no]: Use a random password? (yes/no) [no]: Enter password: password goes here Enter password again: retype it (OK to accept the default here, hit Enter) Lock out the account after creation? [no]: Username : fred Password : ***** Full Name : Fred Smith (This will vary) Uid : 1002 Class : Groups : fred wheel portage Home : /home/fred Shell : /bin/bash Locked : no (Confirm the information is correct) OK? (yes/no): yes adduser: INFO: Sucessfully added (fred) to the user database Add another user? (yes/no): no Goodbye! # |
Congratulations, you have just finished your Gentoo/FreeBSD installation which you can start exploring after the final reboot. Have fun!
Code Listing 3.22: Rebooting the system |
# exit # reboot |
4. Developing for Gentoo/FreeBSD
There are many things you could help with, depending on your skill level and spare time:
At the moment, there are still quite a lot of known issues. Here are the ones really worth noting:
A list of Gentoo/FreeBSD developers can be found at the project page. Other ways to contact Gentoo/FreeBSD developers include our IRC Channel #gentoo-bsd on Freenode, as well as the gentoo-bsd mailing list.
The contents of this document are licensed under the Creative Commons - Attribution / Share Alike license.