Gentoo FreeBSD

Gentoo/FreeBSD is a Gentoo system based on FreeBSD. It is FreeBSD with the following changes:


 * Portage replaces ports.
 * The base system is managed by portage.
 * Software in and  is replaced with Gentoo Linux versions.
 * The rc system is replaced with OpenRC.
 * Python, wget and bash are included in the base system to support portage.
 * FreeBSD's bootloader is removed from the base system (useful for jails).

What is FreeBSD?
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 9.1. Gentoo/FreeBSD is based on version 9.1 and older versions of Gentoo/FreeBSD are discontinued and no longer supported.

What is Gentoo/FreeBSD?
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.

FreeBSD and Linux
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:


 * 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.
 * Contrary to the Linux kernel, FreeBSD development is not led by one person, but instead managed by a small group of people called the Core Team.

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:


 * To get run-time dynamic linking functions like dlopen, programs do not need to be linked against libdl like on GNU/Linux. Instead they are linked against libc.
 * FreeBSD doesn't have an official tool for kernel compilation, thus you'll have to resolve feature dependencies on your own.
 * FreeBSD supports UFS/UFS2 and ZFS as native file systems.
 * FreeBSD also supports Linux filesystems, but you cannot install your system on them. ext2/ext3 supports read/write access. ReiserFS, XFS are read-only support. details please see FreeBSD's handbook 21.3. Linux® Filesystems

Caution
Since this guide has only minimal information, knowledge of both Gentoo/Linux and FreeBSD may be needed. The Gentoo/Linux Handbook and FreeBSD Handbook are your friends.

Preparation
The installation media of FreeBSD 9.0 to which the LiveCD function was added are used for installation. Please get the more suitable one of i386 or amd64. Of course, -bootonly.iso can be used to install Gentoo/FreeBSD. Write to a CD or memory stick as necessary.

Boot the PC using the installation CD. Wait a moment while watching the boot process. Please choose Live CD, if a Welcome screen is displayed. Then login prompt, enter root.

Optional: Setting keymap
If your keyboard is not an English 101 keyboard, please set keymap.

A list of key map is available with the following command.

Network setting
First, create a directory /tmp/bsdinstall_etc to rewrite the resolv.conf.

Identify your network devices. This example is em0.

Set the default gateway and IP address.

If you not use DHCP (IP address is an example)

If you use DHCP

Optional: want to install via ssh
So far we could not use ssh. If you want to install via ssh from this step.

Please connect with any ssh client. The username is root.

Setting the Partition
The installation target device of serial ATA and IDE are /dev/ada*. SCSI and USB drive are /dev/da*. Please identify the HDD using ls /dev/ada* or dmesg | grep ada. In this case, the device is ada0.

If you want to use the UFS2 file system (GPT)
This example is simple only two partitions. If necessary, you can split /, /usr, /var, /tmp, and /home. Please set using gpart.

If you want to use FreeBSD's default bootloader. [Recommend]
Please run gpart show in order to verify the partition could be set.

Results when you create a partition with option -a 4k.

If you want to use the UFS2 file system
Please do not forget newfs -L option to label.

Your choice GPT)

Your choice MBR)

And mount it.

If you want to use the ZFS file system (experimental)
Load the kernel module in order to enable ZFS.

Prepare the RAM disk to write /boot/zfs/zpool.cache.

Please use gnop if you have 4KB/sector HDD. You can get the best performance.

Creates a new storage pool. if you are using gnop, please specify /dev/gpt/zfs-system.nop instead of /dev/gpt/zfs-system.

Creates a new ZFS file system.

Downloading the Stage3 Tarball and Portage snapshot
Now, Gentoo/FreeBSD 9.0 stage3 is available for x86-fbsd. And Gentoo/FreeBSD 9.1 stage3 is available for amd64-fbsd.

The first settings and time zone settings
env-update and time zone settings. Of course, you can modify /etc/portage/make.conf.

Bug fixes (for x86-fbsd users, 9.0 stage3 only)
Bugs have been fixed in several packages. Please upgrade them. For details, see, , and.

Special settings for ZFS
If you select ZFS file system, the following additional work is required.

Installing a kernel source
Unlike Gentoo/Linux, freebsd-sources package is the only sources.

Compiling and installing kernel
Now let's compile the kernel. Copy the GENERIC in conf, you can change it by changing the kernel configuration. For more information see the FreeBSD Handbook.

System setting
Familiar setting. Please refer to Gentoo Linux Handbook if you need more information.

If you select UFS2

If you select ZFS

Setting the host name

Editing network setting

Adding net.em0 to the default runlevel

Setting keymap

Please edit /etc/conf.d/syscons if you want to change keymap.

A list of key map is available with the following command.

Setting the root password

Adding a User for Daily Use (sample)

You can also be configured to run at startup sshd.

Special settings for ZFS
If you select ZFS file system, the following additional work is required.

Special settings for virtual machine
If you are installing on a virtual machine, require additional configuration.

Installing the required packages
If dhcpcd is required if you use DHCP.

Installing the boot loader
Let's install a boot loader to boot the Gentoo/FreeBSD.

Please see if you want to use grub2. But it is experimental!

Setting boot loader
Let's prepare for using sys-freebsd/boot0.

If you select UFS2 (GPT)

If you select UFS2 (MBR)

If you select ZFS (GPT)

Exit from chroot environment
Work done in the chroot environment. exit from chroot environment.

Cleaning up and setting the remaining
Do you want to reboot now ? Just a minute. ZFS user must have setting a little more.

Special settings for ZFS
If you select ZFS file system, the following additional work is required.

reboot!
Don't have a problem? Now we restart. Don't forget to remove the Installation CD of FreeBSD.

Howto run G/FBSD in vanilla FreeBSD's jail
Details of jail, please see the FreeBSD Handbook.

Setting
Configure jail to start with FreeBSD.

Setting to operate Gentoo/FreeBSD in jail.

run jail
Let's run jail.

Verify that worked.

To enter the jail environment will use the jexec command.

Upgrade howto
This guide will show you how to upgrade Gentoo/FreeBSD 9.1 from previous version.

Change to latest profile
To emerge related to FreeBSD 9.1 is necessary to change the profile.

Get a list of available profiles:

Set the profile of 9.1:

Updating sys-apps/portage
Please check first, what will be installed.

After confirming that masked by: EAPI error does not appear, please upgrade.

Please add --exclude sys-freebsd/* option if failed messages sys-freebsd packages are mask is displayed.

Successfully updated, please check the version.

need version 2.2. If it is not 2.2, update portage again.

Recheck the version.

In addition, check that it includes preserve-libs to FEATURES. If it does not, please add FEATURES="preserve-libs" in make.conf.

Move /etc/make.conf
Recently, /etc/make.conf has been moved to /etc/portage/make.conf. if it exists in /etc, please move it.

In addition, remove LDFLAGS from make.conf. If it is set, upgrade may fail.

Fixed collision of tabs
If you are using version 8.0 and fewer, tabs might collide. Please check the following steps.

And please update sys-libs/ncurses.

Package updates the minimum required
update the minimal packages needed to upgrade.

Migrate to lib from lib64 (for amd64-fbsd users, 9.0 stage3 only)
If you are using 9.0 stage3 of amd64-fbsd, you will need to migrate to lib from lib64 first.

If you skip this step, all the commands you will not be able to run when upgrade sys-apps/baselayout. For details, see

Kernel update
First of all, you need to update your kernel. It is because the package of a userland may use the new function of a kernel.

Please be sure to update a kernel first !

failed to compile the kernel
Please get the GENERIC kernel of FreeBSD if you fail to compile the kernel. If you are using amd64-fbsd, please replace the i386 to amd64 in URL.

reboot
Don't have a problem? Now we restart.

After rebooting your machine, please check if the kernel is new.

Updating FreeBSD userland
The first emerge the core library.

Update the userland of FreeBSD.

Cleanup, utmp related files

Change CHOST and rebuild toolchain
Change CHOST, and emerge binutils gcc. (FYI, Changing the CHOST variable)

x86-fbsd users)

amd64-fbsd users)

emerge binutils gcc

check gcc's 8.x stuff

remove 8.x stuff.

also check binutils

remove FreeBSD 8.x env data.

target file name is 04gcc-i686-gentoo-freebsd8.0, 05gcc-i486-gentoo-freebsd8.0 in this case.

Recreate all packages.

Failure to compile the package if any, 'emerge --resume --skipfirst' is your friend. Also, please bug report the problem if you like.

Cleaning
Let's remove the backup files when you have finished all the steps.

Re-select profile
Please re-select the profile if make.profile exists in /etc.

How to use X Window System with vesa video card
If you are using a USB mouse, please load kernel module first.

Configure...

Check the device for mouse

OK, In this case /dev/sysmouse has been detected.

Other video cards
xf86-video-vmware) Please see.

xf86-video-virtualbox) Please check my experimental overlay.

xf86-video-intel) Please see.

Q&A
Q. mouse does not work

A. PS/2 mouse is /dev/psm0、USB mouse is /dev/ums0. another one is /dev/sysmouse. Please specify in xorg.conf correctly. You need to start moused to use /dev/sysmouse. Run /etc/init.d/moused start.

Portage Overlay

 * Gentoo/BSD Project Overlay
 * It is the official overlay. Good quality, it contains bugfixes for e.g. system packages. You can add using layman -a gentoo-bsd.


 * nigoro's amd64-fbsd overlay
 * It is a highly experimental overlay. Bad quality, but most packages work. List of tested packages.

Experimental clang stages
clang stages is available from the following URL:

http://distfiles.gentoo.org/experimental/bsd/freebsd/stages/amd64-fbsd-9.1/clang/stage3-amd64-clangfbsd-9.1.tar.bz2

Please see bug list and page Clang. In addition, please report to Gentoo Bugzilla if you find a package that can not be compiled with clang.

Bug list

 * dev-libs/openssl-1.0.0j and dev-libs/openssl-1.0.1c fail to build with Clang
 * dev-libs/libgcrypt-1.5.2-r1: build fails with using clang-3.3 on x86-fbsd
 * [TRACKER] Packages that fail to build with LLVM/Clang on Gentoo FreeBSD

Why make the package once ?
When compiled with CXX="clang++ -stdlib=libc++" to llvm or clang, clang command does not work at all (Segmentation fault occurs always).

When set CXX="clang++ -stdlib=libc++", in order to successfully compile them, should both be linked to libc++.so.1.

Configure grub2
If you select UFS2 (GPT)

If you select UFS2 (MBR)

If you select ZFS (GPT)

How to help
There are many things you could help with, depending on your skill level and spare time:


 * 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.
 * 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.
 * 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.
 * 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.
 * Other areas where we need help include: system ebuilds, creation of installation CDs, documentation, kernel hacking.

All commands is not working after emerge sys-apps/baselayout
After failing to emerge baselayout, all commands will not work. Details, see

If you have not restarted the PC, please run this command first.

If you restart or turn off your PC already has a need to restore your system using the installation CD of FreeBSD.


 * 1) boot using the installation media of FreeBSD.
 * 2) Live CD select
 * 3) Mount the root partition of G/FBSD (eg. mount /dev/ufs/gfbsdroot /mnt)
 * 4) cd /mnt (Please replace to /mnt/,/mnt/usr... from /,/usr... )

Please check lib in /, /usr, /usr/local.

In this case, the symbolic link /lib is simply removed. Let's re-create symbolic link /lib.

You need to migrate from lib64 to lib before run emerge baselayout so far. Run the script for migration.

If you have to recover by using FreeBSD's installation media, please enter in G/FBSD run chroot /mnt !

can not boot a kernel panic always occurs
Details, see

workaround is to use gcc 4.3 or clang to compile the kernel.

amd64 kernel + x86 stage environment, tar will not work successfully.
Details, see

Error messages: tar: getvfsbyname failed: No such file or directory tar: Error exit delayed from previous errors.

workaround fix

gcc fails to compile, Error message is recompile -fPIC
Details, see.

workaround fix

The kernel fails to mount a ZFS root filesystem with error 2
Your /boot/zfs/zpool.cache file is missing information about the pool containing your root filesystem.

Boot a FreeBSD LiveCD and enter the shell. Then import your pool using the name of your pool intead of "rpool":

Inform ZFS what your root dataset is using its name instead of "rpool/ROOT/freebsd":

Export the pool

Import the pool again, except this time over your Live CD's root filesystem:

Now force the system to reboot and it should work. This procedure originally described on the FreeBSD forums.

Emerge fails net-misc/openssh
Details, see

workaround fix for openssh

Another issue. If the following error message is displayed, please try EXTRA_ECONF='--disable-lastlog' loginrec.c: In function 'lastlog_openseek': loginrec.c:1506:46: error: invalid application of 'sizeof' to incomplete type 'struct lastlog' loginrec.c: In function 'lastlog_write_entry': loginrec.c:1536:17: error: storage size of 'last' isn't known loginrec.c:1536:17: warning: unused variable 'last' [-Wunused-variable] loginrec.c: In function 'lastlog_get_entry': loginrec.c:1589:17: error: storage size of 'last' isn't known loginrec.c:1589:17: warning: unused variable 'last' [-Wunused-variable]

Emerge fails app-misc/screen
Details, see and.

Please use app-misc/tmux instead of app-misc/screen.

cc: not found
Details, see

Emerge fails sys-freebsd/boot0 using >gcc-4.6
Details, see

workaround:

Contacts

 * gentoo-bsd mailing list ( Gentoo Mailing Lists)
 * IRC Channel #gentoo-bsd on freenode ( Gentoo Linux IRC Resources )