Gentoo FreeBSD

From Gentoo Wiki
Revision as of 15:17, 12 December 2013 by Nigoro (Talk | contribs)

Jump to: navigation, search
Important
Sometimes, Gentoo/FreeBSD's @system is broken.

Please get latest information from "Depends on" of bug #462580.

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 ./contrib and ./crypto 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).
Note
Gentoo FreeBSD is not 100% binary-compatibility with regular FreeBSD due to SONAME differences. It is possible to workaround that by running regular FreeBSD in either a jail or chroot on Gentoo FreeBSD or vice versa.

Gentoo FreeBSD is also not 100% script-compatible with regular FreeBSD by default. Script compatibility can be restored by installing sys-freebsd/ubin-wrappers. This makes it possible to use *BSD software like pkgsrc.

Contents

Introduction to FreeBSD

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

Installation

Important
Part of x86-fbsd is out of date. Please install amd64-fbsd.

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.

Note
If you have 4KB/sector HDD (aka AFT Drive)

Please select "2. [Esc]ape to loader prompt" at boot time if you have a 4KB/sector HDD.

Set the device name of your HDD with 4KB sectors in the boot loader. ada1 and ada2... to increase if you have more than one.

set kern.cam.ada.0.quirks="1"
boot

Optional: Setting keymap

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

root # kbdcontrol -l uk.iso

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

root # ls -1 /usr/share/syscons/keymaps | less

Network setting

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

root # mkdir -p /tmp/bsdinstall_etc

Identify your network devices. This example is em0.

root # ifconfig
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
        ether 00:00:00:00:00:00
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=3<RXCSUM,TXCSUM>
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
        inet 127.0.0.1 netmask 0xff000000
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

Set the default gateway and IP address.

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

root # ifconfig em0 192.168.0.100
root #
route add default 192.168.0.1
root #
echo "nameserver 8.8.8.8" > /etc/resolv.conf (example used a Google Public DNS)

If you use DHCP

root # dhclient em0

Optional: want to install via ssh

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

root # mkdir -p /tmp/etc
root #
mount -t tmpfs tmpfs /tmp/etc
root #
mount -t unionfs /tmp/etc /etc
root #
passwd
root #
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
root #
/etc/rc.d/sshd onestart

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

Setting the Partition

Important
grub2 doesn't have KEYWORDS="~amd64-fbsd ~x86-fbsd" yet. sys-freebsd/boot0 is recommended for bootloader on Gentoo/FreeBSD.
Note
If you want to use grub2, you need 1MB free space at the beginning of the disk (MBR) or bios-boot partition (GPT).

grub2 can not find freebsd-boot partition. Please set the bios-boot (GPT).

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.

root # dmesg | grep ada
ada0 at ata0 bus 0 scbus0 target 0 lun 0
ada0: <QEMU HARDDISK 0.15.> ATA-7 device
ada0: 16.700MB/s transfers (WDMA2, PIO 8192bytes)
ada0: 12288MB (25165824 512 byte sectors: 16H 63S/T 16383C)
ada0: Previously was known as ad0
If you want to use the UFS2 file system (GPT)
Note
GPT partition is the standard FreeBSD 9.0. Please read the next MBR section if you want use MBR partition.

This example is simple only two partitions. If necessary, you can split /, /usr, /var, /tmp, and /home. Please set using gpart.

Partition Filesystem Size Description
/dev/ada0p1 none just a bit Reserved for bootloader
/dev/ada0p2 UFS2 + SU entire disk - swap space Root partition
/dev/ada0p3 swap Rest of the disk Swap partition
Note
Please add options -a 4k to gpart add command of all, if you have AFT drive (4096bytes/sector). Start of the partition is properly configured, you can get the best performance.
If you want to use FreeBSD's default bootloader. [Recommend]
root # gpart create -s GPT ada0
root #
gpart add -s 64k -t freebsd-boot ada0
root #
gpart add -s 10G -t freebsd-ufs -l root ada0
root #
gpart add -t freebsd-swap -l swap ada0

Please run gpart show in order to verify the partition could be set.

root # gpart show
=>      34  25165757  ada0  GPT  (12G)
        34       128     1  freebsd-boot  (64k)
       162  20971520     2  freebsd-ufs  (10G)
  20971682   4194109     3  freebsd-swap  (2G)

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

root # gpart show
=>      34  25165757  ada0  GPT  (12G)
        34         6        - free -  (3.0k)
        40       128     1  freebsd-boot  (64k)
       168  20971520     2  freebsd-ufs  (10G)
  20971688   4194096     3  freebsd-swap  (2G)
  25165784         7        - free -  (3.5k)
If you want to use grub2. [Experimental]
root # gpart create -s GPT ada0
root #
gpart add -s 1024k -t bios-boot ada0
root #
gpart add -s 10G -t freebsd-ufs -l root ada0
root #
gpart add -t freebsd-swap -l swap ada0
If you want to use the UFS2 file system (MBR)
Partition Filesystem Size Description
/dev/ada0s1a UFS2 + SU entire disk - swap space Root partition
/dev/ada0s1b swap Rest of the disk Swap partition
If you want to use FreeBSD's default bootloader. [Recommend]
root # gpart create -s mbr ada0
root #
gpart add -t freebsd ada0
root #
gpart set -a active -i 1 ada0
root #
gpart create -s bsd ada0s1
root #
gpart add -s 10G -t freebsd-ufs ada0s1
root #
gpart add -t freebsd-swap ada0s1
If you want to use grub2. [Experimental]
root # gpart create -s mbr ada0
root #
gpart add -b 1024k -t freebsd ada0
root #
gpart set -a active -i 1 ada0
root #
gpart create -s bsd ada0s1
root #
gpart add -s 10G -t freebsd-ufs ada0s1
root #
gpart add -t freebsd-swap ada0s1
If you want to use the ZFS file system (experimental) / (GPT)
If you want to use FreeBSD's default bootloader. [Recommend]
root # gpart create -s GPT ada0
root #
gpart add -s 64k -t freebsd-boot ada0
root #
gpart add -t freebsd-zfs -l zfs-system ada0
If you want to use grub2. [Experimental]
root # gpart create -s GPT ada0
root #
gpart add -s 1024k -t bios-boot ada0
root #
gpart add -t freebsd-zfs -l zfs-system ada0

Creating and mounting a file system

If you want to use the UFS2 file system

Please do not forget newfs -L option to label.

Note
Add option -j to newfs if you want to enable soft updates journaling. Add option -t if you want to enable TRIM.

Your choice GPT)

root # newfs -L gfbsdroot -U /dev/ada0p2

Your choice MBR)

root # newfs -L gfbsdroot -U /dev/ada0s1a

And mount it.

root # mount /dev/ufs/gfbsdroot /mnt
root #
swapon /dev/gpt/swap (GPT)
root #
swapon /dev/ada0s1b (MBR)
If you want to use the ZFS file system (experimental)

Load the kernel module in order to enable ZFS.

root # kldload zfs

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

root # mount -t tmpfs tmpfs /boot/zfs

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

root # gnop create -S 4096 /dev/gpt/zfs-system

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

root # zpool create zsys /dev/gpt/zfs-system
root #
zfs set mountpoint=none zsys

Creates a new ZFS file system.

root # zfs create zsys/root
root #
zfs set mountpoint=/mnt zsys/root
root #
zfs mount -a
root #
zfs create zsys/root/usr
root #
zfs create zsys/root/var
root # zfs create zsys/root/tmp
root #
zfs create zsys/home
root #
zfs create -V 8gb zsys/swap
root #
zfs set org.freebsd:swap=on zsys/swap
root #
zfs set checksum=off zsys/swap
root # mkdir /mnt/home
root #
mount -t zfs zsys/home /mnt/home

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.

Important
If you want to use x86-fbsd, please upgrade to 9.1 after the installation is complete. FreeBSD 9.0 is EOL on March 31, 2013.

Unpacking stage3 and Portage snapshot

Important
The following error may be displayed. But, please continue the installation don't worry. This problem will be fixed in 9.2. Details, see bug #469454
./bin/fuser: Can't create 'bin/fuser'
tar: Error exit delayed from previous errors.
root # cd /mnt
root #
setenv LANG "en_US.UTF-8"
root #
tar xjpf stage3-*.tar.bz2 -C /mnt
root #
tar xjf portage-latest.tar.bz2 -C /mnt/usr

Entering the new Environment

root # mount -t devfs devfs /mnt/dev
root #
cp /etc/resolv.conf /mnt/etc/
root #
chroot /mnt /bin/bash

Settings and install more in chroot environment

The first settings and time zone settings

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

(chroot) root # env-update && source /etc/profile
(chroot) root #
cp /usr/share/zoneinfo/GMT /etc/localtime (please select your time zone)
(chroot) root #
emerge -u sys-apps/portage ; emerge sys-devel/libtool app-admin/eselect
(chroot) root #
emerge app-editors/nano
(chroot) root #
mv /etc/make.conf /etc/portage/ (if /etc/make.conf is exist.)
(chroot) root #
nano -w /etc/portage/make.conf (if necessary)

Bug fixes (for x86-fbsd users, 9.0 stage3 only)

Bugs have been fixed in several packages. Please upgrade them. For details, see bug #324445, bug #412319, bug #417031 and bug #421191.

(chroot) root # emerge sys-devel/gcc-config
(chroot) root #
emerge sys-freebsd/freebsd-mk-defs sys-freebsd/freebsd-lib app-arch/libarchive dev-libs/libedit

Special settings for ZFS

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

(chroot) root # emerge flaggie
(chroot) root #
flaggie +zfs
(chroot) root #
emerge sys-devel/flex
(chroot) root #
emerge sys-freebsd/freebsd-cddl
(chroot) root #
emerge sys-freebsd/freebsd-lib sys-freebsd/freebsd-ubin sys-freebsd/boot0

Installing a kernel source

Unlike Gentoo/Linux, freebsd-sources package is the only sources.

(chroot) root # USE=symlink emerge freebsd-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.

(chroot) root # emerge -u sys-devel/flex
(chroot) root #
cd /usr/src/sys/i386/conf (case of x86-fbsd)
(chroot) root #
cd /usr/src/sys/amd64/conf (case of amd64-fbsd)
(chroot) root #
cp GENERIC.hints /boot/device.hints
(chroot) root # config GENERIC
(chroot) root #
cd ../compile/GENERIC
(chroot) root #
make cleandepend && make depend && make -j3 && make install

System setting

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

If you select UFS2

(chroot) root # nano -w /etc/fstab
# Device	Mountpoint	FStype	Options	Dump	Pass#
/dev/ufs/gfbsdroot	/		ufs	rw	1	1

#your choice GPT (don't forget comment out)
#/dev/gpt/swap	none		swap	sw	0	0

#your choice MBR (don't forget comment out)
#/dev/ada0s1b	none		swap	sw	0	0

If you select ZFS

(chroot) root # nano -w /etc/fstab
# Device	Mountpoint	FStype	Options	Dump	Pass#
#/dev/ad0s1a	/		ufs	rw	1	1
#/dev/ad0s1b	none		swap	sw	0	0
zsys/root	/		zfs	rw	0	0

Setting the host name

(chroot) root # nano -w /etc/conf.d/hostname
# (Set the hostname variable to your host name)
hostname="daemon"

Editing network setting

(chroot) root # nano -w /etc/conf.d/net
# (Set the dns_domain variable to your domain name)
dns_domain_lo="homenetwork"

# Manually setting)
config_em0="192.168.0.100 netmask 255.255.255.0"
routes_em0="default via 192.168.0.1"

# Using DHCP)
config_em0="dhcp"

Adding net.em0 to the default runlevel

(chroot) root # cd /etc/init.d
(chroot) root #
ln -s net.lo0 net.em0
(chroot) root #
rc-update add net.em0 default

Setting keymap

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

(chroot) root # nano -w /etc/conf.d/syscons

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

(chroot) root # ls -1 /usr/share/syscons/keymaps | less

Setting the root password

(chroot) root # passwd

Adding a User for Daily Use (sample)

(chroot) root # adduser
Username: nigoro
Full name:
Uid (Leave empty for default):
Login group [nigoro]:
Login group is nigoro. Invite nigoro into other groups? []: wheel
Login class [default]:
Shell (bash csh esh fish ksh sash sh tcsh zsh nologin) [sh]: bash
Home directory [/home/nigoro]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password:
Enter password again:
Lock out the account after creation? [no]:
Username   : nigoro
Password   : *****
Full Name  :
Uid        : 1001
Class      :
Groups     : nigoro wheel
Home       : /home/nigoro
Home Mode  :
Shell      : /bin/bash
Locked     : no
OK? (yes/no): yes
adduser: INFO: Successfully added (nigoro) to the user database.
Add another user? (yes/no): no
Goodbye!

You can also be configured to run at startup sshd.

(chroot) root # emerge -u net-misc/openssh
(chroot) root #
rc-update add sshd default
Special settings for ZFS

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

(chroot) root # rc-update add zfs boot
(chroot) root #
rc-update add zvol default
(chroot) root #
echo 'zfs_load="YES"' >> /boot/loader.conf
(chroot) root #
echo 'vfs.root.mountfrom="zfs:zsys/root"' >> /boot/loader.conf
Special settings for virtual machine

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

(chroot) root # echo 'kern.hz=100' >> /boot/loader.conf

Installing the required packages

If dhcpcd is required if you use DHCP.

(chroot) root # emerge net-misc/dhcpcd

Installing the boot loader

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

(chroot) root # emerge sys-freebsd/boot0

Please see #How to use sys-boot/grub2 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)

(chroot) root # gpart bootcode -b /boot/pmbr ada0
(chroot) root #
gpart bootcode -p /boot/gptboot -i 1 ada0

If you select UFS2 (MBR)

(chroot) root # gpart bootcode -b /boot/boot0 ada0
(chroot) root #
gpart bootcode -b /boot/boot ada0s1

If you select ZFS (GPT)

(chroot) root # gpart bootcode -b /boot/pmbr ada0
(chroot) root #
gpart bootcode -p /boot/gptzfsboot -i 1 ada0

Exit from chroot environment

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

(chroot) root # exit

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.

root # umount /mnt/dev
root #
cd /
root #
zpool set bootfs=zsys/root zsys
root #
zpool export zsys
root #
gnop destroy /dev/gpt/zfs-system.nop (please run if you are using gnop)
root # zpool import zsys
root #
mkdir /mnt/boot/zfs
root #
cp /boot/zfs/zpool.cache /mnt/boot/zfs/
root #
zfs unmount -a
root # zfs set mountpoint=none zsys
root #
zfs set mountpoint=/usr zsys/root/usr
root #
zfs set mountpoint=/var zsys/root/var
root #
zfs set mountpoint=/tmp zsys/root/tmp
root #
zfs set mountpoint=/home zsys/home
root #
zfs set mountpoint=legacy zsys/root

reboot!

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

root # shutdown -r now

Howto run G/FBSD in vanilla FreeBSD's jail

Details of jail, please see the FreeBSD Handbook.

Preparing directory

root # mkdir -p /usr/jail/gfbsd
root #
cd /usr/jail/gfbsd

Downloading and Unpacking the Stage3 Tarball and Portage snapshot

root # fetch http://dev.gentoo.org/~aballier/fbsd9.0/x86/stage3-i686-freebsd-9.0.tar.bz2 (for x86-fbsd users)
root #
fetch http://distfiles.gentoo.org/experimental/bsd/freebsd/stages/amd64-fbsd-9.1/stage3-amd64-freebsd-9.1.tar.bz2 (for amd64-fbsd users)
root #
fetch http://distfiles.gentoo.org/snapshots/portage-latest.tar.bz2
root #
tar xjpf stage3-*.tar.bz2
root #
tar xjf portage-latest.tar.bz2 -C /usr/jail/gfbsd/usr

Setting

Configure jail to start with FreeBSD.

File/etc/rc.confExample for start automatically jail

jail_enable="YES"
jail_list="gfbsd"

jail_gfbsd_rootdir="/usr/jail/gfbsd"
jail_gfbsd_hostname="gfbsd.example.org"
jail_gfbsd_devfs_enable="YES"

# You will also need to add the following line if you need network access.
# em0, please specify your network devices.
jail_gfbsd_interface="em0"
jail_gfbsd_ip="192.168.0.10"

Setting to operate Gentoo/FreeBSD in jail.

root # echo 'rc_sys="jail"' >> /usr/jail/gfbsd/etc/rc.conf
root #
echo 'hostname="gfbsd"' > /usr/jail/gfbsd/etc/conf.d/hostname
root #
echo 'syslogd_args="-ss"' >> /usr/jail/gfbsd/etc/conf.d/syslogd
root # chroot /usr/jail/gfbsd /bin/bash
(chroot) root # rc-update add vixie-cron default
(chroot) root #
exit

run jail

Let's run jail.

root # /etc/rc.d/jail start

Verify that worked.

root # jls
   JID  IP Address      Hostname                      Path
     1  192.168.0.10    gfbsd                         /usr/jail/gfbsd

To enter the jail environment will use the jexec command.

root # jexec 1 /bin/bash

Upgrade howto

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

Note
This guide is targeted to version 7.2 or higher.

Preparation

Change to latest profile

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

Get a list of available profiles:

root # eselect profile list
Available profile symlink targets:
  [1]   default/bsd/fbsd/x86/9.0
  [2]   default/bsd/fbsd/x86/9.1

Set the profile of 9.1:

root # eselect profile set 2

Updating sys-apps/portage

Please check first, what will be installed.

root # emerge -pu sys-apps/portage
[ebuild     UD] sys-apps/portage-2.1.11.33 [2.2_rc49] USE="(ipc%*) (-pypy1_9) -python2% -xattr%"

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.

root # emerge -u sys-apps/portage

Successfully updated, please check the version.

root # emerge --version
Portage 2.1.11.33 (default/bsd/fbsd/x86/9.1, gcc-4.4.2, freebsd-lib-7.2, 9.1_rc3-Gentoo i386)

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

root # emerge -u sys-apps/portage --exclude sys-freebsd/*

Recheck the version.

root # emerge --version
Portage 2.2.0_alpha144 (default/bsd/fbsd/x86/9.1, gcc-4.4.2, freebsd-lib-7.2, 9.1_rc3-Gentoo i386)

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

Important
Please be sure to check whether preserve-libs is set to FEATURES. If it is not set, then your system will not work because required libraries are removed.
root # emerge --info | grep FEATURES= | grep preserve-libs
FEATURES="assume-digests binpkg-logs chflags config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"

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.

root # mkdir -p /etc/portage
root #
if [ -e /etc/make.conf ] && [ ! -e /etc/portage/make.conf ] ; then
root #
mv /etc/make.conf /etc/portage/make.conf
root #
fi
root #
gsed -i '/LDFLAGS=/d' /etc/portage/make.conf

Fixed collision of tabs

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

root # cd /var/db/pkg/sys-freebsd
root # grep -r tabs * | grep obj
freebsd-ubin-7.2/CONTENTS:obj /usr/bin/tabs 741bc04f9e321d5d0f312b5cb8a87d6a 1257735235
freebsd-ubin-7.2/CONTENTS:obj /usr/share/man/man1/tabs.1.bz2 ed7bca86bc66d164cc1434583f6d8cd7 1257735225
root # rm /usr/bin/tabs /usr/share/man/man1/tabs.1.bz2

And please update sys-libs/ncurses.

root # emerge -u sys-libs/ncurses --exclude sys-freebsd/*

Package updates the minimum required

update the minimal packages needed to upgrade.

root # emerge sys-freebsd/freebsd-mk-defs
root #
emerge -u sys-apps/findutils --exclude sys-freebsd/*
root #
emerge sys-devel/libtool --exclude sys-freebsd/*
root #
emerge -u sys-devel/flex sys-devel/patch sys-devel/m4 net-libs/libpcap sys-devel/gettext app-arch/libarchive dev-libs/libelf --exclude sys-freebsd/*
root #
emerge sys-devel/libtool --exclude sys-freebsd/*

Migrate to lib from lib64 (for amd64-fbsd users, 9.0 stage3 only)

Important
Do not skip this chapter!

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 bug #436560

root # wget -O /tmp/migrate_libdir.sh "http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-bsd.git;a=blob_plain;f=scripts/migrate_libdir.sh;hb=HEAD"
root #
bash /tmp/migrate_libdir.sh
root #
emerge -u sys-apps/baselayout --exclude sys-freebsd/*

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 !

root # USE=symlink emerge freebsd-sources
root #
cd /usr/src/sys/i386/conf (case of x86-fbsd)
root #
cd /usr/src/sys/amd64/conf (case of amd64-fbsd)
root #
cp GENERIC.hints /boot/device.hints
root # config GENERIC
root #
cd ../compile/GENERIC
root #
make cleandepend && make depend && make -j3 && make install

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.

Important
Don't forget to rebuild the kernel after updating FreeBSD userland!
root # wget -P /tmp http://ftp.freebsd.org/pub/FreeBSD/releases/i386/i386/9.1-RELEASE/base.txz
root #
wget -P /tmp http://ftp.freebsd.org/pub/FreeBSD/releases/i386/i386/9.1-RELEASE/kernel.txz
root #
mv /boot /boot.orig
root #
cd /
root #
tar xvJf /tmp/base.txz ./boot
root #
tar xvJf /tmp/kernel.txz

reboot

Don't have a problem? Now we restart.

root # shutdown -r now

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

root # uname -a
FreeBSD daemon 9.1-Gentoo FreeBSD Gentoo 9.1 #0: Fri Jan 20 00:01:04 JST 2012
     root@daemon:/usr/src/sys-9.1-r0/amd64/compile/GENERIC  amd64

Updating FreeBSD userland

The first emerge the core library.

root # USE=build emerge -1 --nodeps sys-freebsd/freebsd-lib

Update the userland of FreeBSD.

root # emerge -C sys-process/fuser-bsd
root #
USE=symlink emerge -auN boot0 freebsd-bin freebsd-contrib freebsd-lib freebsd-libexec freebsd-mk-defs freebsd-pam-modules freebsd-sbin freebsd-share freebsd-ubin freebsd-usbin

Cleanup, utmp related files

root # rm /var/run/utmp /var/log/lastlog /var/log/wtmp*

Change CHOST and rebuild toolchain

Note
You can skip this step if you are minor upgrading. Please next Cleaning step.

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

x86-fbsd users)

root # gsed -i 's:CHOST=.*:CHOST="i686-gentoo-freebsd9.1":g' /etc/portage/make.conf

amd64-fbsd users)

root # gsed -i 's:CHOST=.*:CHOST="x86_64-gentoo-freebsd9.1":g' /etc/portage/make.conf

emerge binutils gcc

root # emerge -1 sys-devel/binutils sys-devel/gcc

check gcc's 8.x stuff

root # gcc-config -l
 * broken config file: /etc/env.d/gcc/i686-gentoo-freebsd8.0-4.4.3
 [1] i686-gentoo-freebsd8.0-4.4.3 *
 [2] i686-gentoo-freebsd9.1-4.6.3

remove 8.x stuff.

root # emerge -C '<gcc-4.6'
root # gcc-config -c
i686-gentoo-freebsd9.1-4.6.3

also check binutils

root # binutils-config -l
 [1] i686-gentoo-freebsd9.1-2.20.1 *
root # binutils-config -c
i686-gentoo-freebsd9.1-2.20.1

remove FreeBSD 8.x env data.

root # cd /etc/env.d/
root #
grep gentoo-freebsd8. *
04gcc-i686-gentoo-freebsd8.0:PATH="/usr/i686-gentoo-freebsd8.0/gcc-bin/4.4.3"
04gcc-i686-gentoo-freebsd8.0:ROOTPATH="/usr/i686-gentoo-freebsd8.0/gcc-bin/4.4.3"
04gcc-i686-gentoo-freebsd8.0:MANPATH="/usr/share/gcc-data/i686-gentoo-freebsd8.0/4.4.3/man"
04gcc-i686-gentoo-freebsd8.0:INFOPATH="/usr/share/gcc-data/i686-gentoo-freebsd8.0/4.4.3/info"
04gcc-i686-gentoo-freebsd8.0:LDPATH="/usr/lib/gcc/i686-gentoo-freebsd8.0/4.6.3
04gcc-i686-gentoo-freebsd8.0:/usr/lib/gcc/i686-gentoo-freebsd8.0/4.4.3"
05gcc-i486-gentoo-freebsd8.0:MANPATH="/usr/share/gcc-data/i486-gentoo-freebsd8.0/4.4.3/man"
05gcc-i486-gentoo-freebsd8.0:INFOPATH="/usr/share/gcc-data/i486-gentoo-freebsd8.0/4.4.3/info"
05gcc-i486-gentoo-freebsd8.0:LDPATH="/usr/lib/gcc/i486-gentoo-freebsd8.0/4.4.3"
05gcc-i486-gentoo-freebsd8.0:PATH="/usr/i486-gentoo-freebsd8.0/gcc-bin/4.4.3"
05gcc-i486-gentoo-freebsd8.0:ROOTPATH="/usr/i486-gentoo-freebsd8.0/gcc-bin/4.4.3"

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

root # rm 04gcc-i686-gentoo-freebsd8.0 05gcc-i486-gentoo-freebsd8.0
root #
env-update && source /etc/profile
root #
/usr/share/gcc-data/i686-gentoo-freebsd9.1/4.6.3/fix_libtool_files.sh 4.4.3 --oldarch i686-gentoo-freebsd8.0

Recreate all packages.

root # emerge sys-devel/libtool
root #
emerge -ae @world --exclude sys-apps/portage
root #
emerge sys-apps/portage

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

Note
If emerge fails to compile sys-freebsd/boot0, please see #Troubleshooting.

Cleaning

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

Important
don't forget etc-update !
root # emerge sys-devel/libtool app-admin/eselect
root #
emerge @preserved-rebuild
root #
etc-update

Re-select profile

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

root # ls -l /etc/make.profile
lrwxr-xr-x  1 root  portage  48 Dec  1 00:00 /etc/make.profile -> ../usr/portage/profiles/default/bsd/fbsd/x86/9.1
root # rm /etc/make.profile
root #
eselect profile list
Available profile symlink targets:
  [1]   default/bsd/fbsd/x86/9.0
  [2]   default/bsd/fbsd/x86/9.1
root # eselect profile set 2

Experimental Zone

How to use X Window System with vesa video card

Note
Please update wiki if you know a better way. Also welcome to fix the problem. Please file a bug.
root # emerge portage ; emerge libtool app-admin/eselect
root #
mv /etc/make.conf /etc/portage/make.conf (be careful !)
root #
emerge -u flaggie
root #
flaggie +python +X
root # echo 'INPUT_DEVICES="keyboard mouse"' >> /etc/portage/make.conf
root #
echo 'VIDEO_CARDS="vesa"' >> /etc/portage/make.conf
root # emerge -p xorg-x11
root #
emerge xorg-x11
root #
emerge xterm twm xclock

If you are using a USB mouse, please load kernel module first.

root # kldload ums
root #
echo 'ums_load="YES"' >> /boot/loader.conf

Configure...

root # Xorg -configure
root #
mv /root/xorg.conf.new /etc/X11/xorg.conf

Check the device for mouse

root # grep /dev /etc/X11/xorg.conf
        Option      "Device" "/dev/sysmouse"

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

root # /etc/init.d/moused start
root #
rc-update add moused default
root #
startx

Other video cards

xf86-video-vmware) Please see bug #477604.

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

xf86-video-intel) Please see bug #493436.

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

Important
clang stages is using clang as the system compiler. It's very experimental.

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

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

How to migrate from amd64/9.1 profile to amd64/9.1/clang

Important
Please check bug #474042 first. Please apply patches attached to the bug.
root # emerge -a sys-devel/clang sys-libs/libcxx
root #
CC=clang CXX="clang++ -stdlib=libc++" emerge -B sys-devel/llvm sys-devel/clang
root #
emerge -K sys-devel/llvm sys-devel/clang
root #
eselect profile set default/bsd/fbsd/amd64/9.1/clang

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.

How to use sys-boot/grub2

Install grub2

root # mkdir -p /etc/portage/package.keywords /etc/portage/patches/sys-boot/grub
root #
echo "=sys-boot/grub-2.00_p5107* amd64" >> /etc/portage/package.keywords/grub
root #
wget -P /etc/portage/patches/sys-boot/grub https://raw.github.com/nigoro/amd64-fbsd/master/etc/portage/patches/sys-boot/grub/grub-2.00_p5107-fbsd.patch
root #
emerge sys-boot/grub

Configure grub2

If you select UFS2 (GPT)

root # grub2-install --modules="part_gpt fat ufs2" --no-floppy /dev/ada0
root #
grub2-mkconfig -o /boot/grub/grub.cfg

If you select UFS2 (MBR)

root # grub2-install --modules="biosdisk part_msdos bsd search_fs_uuid ufs2 msdospart" --no-floppy /dev/ada0
root #
grub2-mkconfig -o /boot/grub/grub.cfg

If you select ZFS (GPT)

root # grub2-install --modules="part_gpt fat zfs" --no-floppy /dev/ada0
root #
grub2-mkconfig -o /boot/grub/grub.cfg

Developing for Gentoo/FreeBSD

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.

Troubleshooting

amd64-fbsd

All commands is not working after emerge sys-apps/baselayout

After failing to emerge baselayout, all commands will not work. Details, see bug #436560

root # ls
Shared object "libutil.so.9" not found, required by "ls"

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

root # export LD_LIBRARY_PATH="/lib64:/usr/lib64"

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.

root # ls -l /lib /usr/lib /usr/local/lib
ls: /lib: No such file or directory
lrwxr-xr-x  1 root  wheel  5 Oct 14 06:41 /usr/lib -> lib64

lrwxr-xr-x  1 root  wheel  5 Oct 14 06:41 /usr/local/lib -> lib64

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

root # ln -s lib64 /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 !

root # wget -O /tmp/migrate_libdir.sh "http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-bsd.git;a=blob_plain;f=scripts/migrate_libdir.sh;hb=HEAD"
root #
bash /tmp/migrate_libdir.sh
root #
emerge sys-apps/baselayout

can not boot a kernel panic always occurs

Details, see bug #408019

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 bug #444918

Error messages:

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

workaround fix

root # emerge =libarchive-3.0.3

gcc fails to compile, Error message is recompile -fPIC

Details, see bug #415185 .

workaround fix

root # emerge --ask sys-devel/gcc

Architecture Independent Issues

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":

root # zpool import -f -N rpool

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

root # zfs set mountpoint=/ rpool/ROOT/freebsd

Export the pool

root # zpool export rpool

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

root # zpool import rpool

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 bug #391011

workaround fix for openssh

root # EXTRA_ECONF='--disable-utmp --disable-wtmp' emerge '>net-misc/openssh-6.0'

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 bug #393039 and bug #409819.

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

lex: not found

root # emerge --ask sys-devel/flex

cc: not found

Details, see bug #412319

root # emerge '>=sys-devel/gcc-config-1.7.1'

Emerge fails sys-freebsd/boot0 using >gcc-4.6

Details, see bug #409815

workaround:

root # emerge -u '<sys-devel/gcc-4.6'
root #
CC=gcc-4.5.4 emerge boot0

Contacts

See also