Gentoo FreeBSD

From Gentoo Wiki
Revision as of 16:31, 14 May 2012 by Nigoro (Talk | contribs)

Jump to: navigation, search

Gentoo/FreeBSD is FreeBSD-based Gentoo system.

Contents

Introduction

Please see #Links if you want details for Gentoo/FreeBSD.

Installing howto

Caution

Since this guide has only minimum information, the knowledge of both Gentoo/Linux and FreeBSD may be needed. 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. Please do write to a CD or memory stick if 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.

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 # mdconfig -a -t malloc -s 5M -u 9
root #
newfs /dev/md9
root #
mkdir -p /tmp/etc
root #
mount /dev/md9 /tmp/etc
root #
cp -a /etc/* /tmp/etc/
root # umount /tmp/etc
root #
mount /dev/md9 /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

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.0> 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

Next, set the 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
root # gpart create -s GPT ada0
root #
gpart add -b 34 -s 128 -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)

Creating and mounting a file system

You can select the UFS and ZFS in FreeBSD. However, this guide is not intended ZFS. Please do not forget newfs -L option to label.

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

And mount it.

root # mount /dev/ufs/gfbsdroot /mnt
root #
swapon /dev/gpt/swap

Downloading the Stage3 Tarball and Portage snapshot

Now, Gentoo/FreeBSD 9.0 stage3 is available.

Unpacking stage3 and Portage snapshot

root # cd /mnt
root #
sh
root #
tar xjpf stage3-*.tar.bz2
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

etc-update and time zone settings. Of course, you can modify /etc/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 nano
(chroot) root #
nano -w /etc/make.conf (if necessary)

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 FreeBSD Handbook please see.

(chroot) root # emerge flex
(chroot) root #
emerge '>=sys-devel/gcc-config-1.7.1'
(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

Installing the boot loader

Let's install a boot loader to boot the Gentoo/FreeBSD. Boot loader configuration is done after exiting the chroot.

(chroot) root # emerge sys-freebsd/boot0

System setting

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

(chroot) root # nano -w /etc/fstab
# Device	Mountpoint	FStype	Options	Dump	Pass#
/dev/ufs/gfbsdroot	/		ufs	rw	1	1
/dev/gpt/swap	none		swap	sw	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 the root password

(chroot) root # passwd

You can also be configured to run at startup sshd.

(chroot) root # ACCEPT_KEYWORDS="~x86-fbsd" emerge net-misc/openssh
(chroot) root #
rc-update add sshd default

Installing the required packages

If dhcpcd is required if you use DHCP.

(chroot) root # emerge dhcpcd

Exit from chroot environment

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

(chroot) root # exit

Writes boot loader and Cleaning up

Do you want to reboot now ? Just a minute. We forgot to setting the boot loader.

root # gpart bootcode -b /mnt/boot/pmbr ada0
root #
gpart bootcode -p /mnt/boot/gptboot -i 1 ada0

Unmount the partition.

root # cd /
root #
umount /mnt/dev
root #
umount /mnt

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

root # shutdown -r now

Major Upgrade howto

This guide will show you how to upgrade Gentoo/FreeBSD 9.0 from 8.x version.

Preparation

Updating the @system

The update to eliminate the problems caused by outdated versions of installed packages.

root # emerge -uDN system

Change profile

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

root # cd /etc rm make.profile

x86-fbsd users)

root # ln -s ../usr/portage/profiles/default/bsd/fbsd/x86/9.0 make.profile

amd64-fbsd users)

root # ln -s ../usr/portage/profiles/default/bsd/fbsd/amd64/9.0 make.profile

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 flex
root #
emerge '>=sys-devel/gcc-config-1.7.1'
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

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.0-Gentoo FreeBSD Gentoo 9.0 #0: Fri Jan 20 00:01:04 JST 2012
     root@daemon:/usr/src/sys-9.0-r0/amd64/compile/GENERIC  amd64

Backup of the library

Please backup your 8.x library. When a problem occurs, will help solve the problem.

root # mkdir -p /var/tmp/8-bkp/usr
root #
cp -a /lib64 /var/tmp/8-bkp/
root #
cp -a /libexec /var/tmp/8-bkp/
root #
cp -a /usr/lib64 /var/tmp/8-bkp/usr/

Updating userland

The first emerge the core library.

root # emerge -1 freebsd-mk-defs
root #
LD_LIBRARY_PATH="/var/tmp/8-bkp/libexec:/var/tmp/8-bkp/lib64:/var/tmp/8-bkp/usr/lib64" emerge -C dev-libs/libedit
root #
LD_LIBRARY_PATH="/var/tmp/8-bkp/libexec:/var/tmp/8-bkp/lib64:/var/tmp/8-bkp/usr/lib64" emerge -1 --nodeps freebsd-lib

Some changes to the file name of the library. Create a symbolic link to the previous file name. After all packages are recreated, you'll be able to remove the symbolic link.

root # rm /lib64/libutil.so.8 /lib64/libedit.so.0
root #
ln -s libutil.so.9 /lib64/libutil.so.8
root #
ln -s libedit.so.7 /lib64/libedit.so.0

Update the userland of FreeBSD.

root # emerge -a1 boot0 freebsd-bin freebsd-contrib freebsd-lib freebsd-libexec freebsd-mk-defs freebsd-pam-modules freebsd-sbin freebsd-share freebsd-ubin freebsd-usbin

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

x86-fbsd users)

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

amd64-fbsd users)

root # gsed -i 's:CHOST=.*:CHOST="x86_64-gentoo-freebsd9.0":g' /etc/make.conf
root # emerge -1 sys-devel/binutils sys-devel/gcc
root # gcc-config -l
 [1] x86_64-gentoo-freebsd8.2-4.3.4
 [2] x86_64-gentoo-freebsd8.2-4.4.5
 [3] x86_64-gentoo-freebsd9.0-4.5.3 *

remove 8.x stuff.

root # emerge -C '<gcc-4.5'
root # gcc-config -c
x86_64-gentoo-freebsd9.0-4.5.3

also check binutils

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

remove FreeBSD 8.x env data.

root # cd /etc/env.d/
root #
grep gentoo-freebsd8. *
05gcc-x86_64-gentoo-freebsd8.2:MANPATH="/usr/share/gcc-data/x86_64-gentoo-freebsd8.2/4.5.3/man"
05gcc-x86_64-gentoo-freebsd8.2:INFOPATH="/usr/share/gcc-data/x86_64-gentoo-freebsd8.2/4.5.3/info"
05gcc-x86_64-gentoo-freebsd8.2:LDPATH="/usr/lib/gcc/x86_64-gentoo-freebsd8.2/4.5.3:/usr/lib/gcc/x86_64-gentoo-freebsd8.2/4.4.5:/usr/lib/gcc/x86_64-gentoo-freebsd8.2/4.3.4"
05gcc-x86_64-gentoo-freebsd8.2:PATH="/usr/x86_64-gentoo-freebsd8.2/gcc-bin/4.5.3"
05gcc-x86_64-gentoo-freebsd8.2:ROOTPATH="/usr/x86_64-gentoo-freebsd8.2/gcc-bin/4.5.3"

target file name is 05gcc-x86_64-gentoo-freebsd8.2 in this case.

root # rm 05gcc-x86_64-gentoo-freebsd8.2
root #
env-update && source /etc/profile
root #
emerge -av1 libtool
root #
/usr/share/gcc-data/x86_64-gentoo-freebsd9.0/4.5.3/fix_libtool_files.sh 4.5.3 --oldarch x86_64-gentoo-freebsd8.2

Some packages need emerge first.

root # emerge -1 libiconv
root #
ln -s libiconv.so.2 /lib64/libiconv.so.7

Recreate all packages.

root # emerge -ae world

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.

root # chflags -R noschg /var/tmp/8-bkp/*
root #
rm -rf /var/tmp/8-bkp
root #
rm /lib64/libutil.so.8 /lib64/libedit.so.0 /lib64/libiconv.so.7

Troubleshooting

amd64-fbsd

can not boot a kernel panic always occurs

Details, see bug #408019

workaround is to use gcc 4.3 to compile the kernel.

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

Details, see bug #413865

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

common

Emerge fails net-misc/openssh

Details, see bug #391011

workaround fix for openssh

root # EXTRA_ECONF='--disable-utmp --disable-wtmp --disable-wtmpx' ACCEPT_KEYWORDS=~x86-fbsd emerge '>net-misc/openssh-6.0'

Emerge fails app-misc/screen

Details, see bug #393039.

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'

Links

Personal tools
Namespaces

Variants
Actions
Gentoo Websites logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Navigation
Toolbox
Categories