View on GitHub

1.4 Gentoo - Post Boot Setup

Download this project as a .zip file Download this project as a tar.gz file

1.4 Gentoo - Post Boot Setup


At this point we should now be booted into the new gentoo system
I've included some final steps here I've done for the setup

Config Changes

Setting the Clock

The first thing to do is to setup the clock, since this can mess up installs with emerge. If the clock is set to something in the past like 1970

date --set="26 Jun 2015 16:10:00"


If you want to leave installs / updated unattended over ssh, installing tmux might be an idea

emerge tmux

New user

Lets setup a new non root user

useradd -g users -G lp,wheel,audio,cdrom,portage,cron -m newuser
passwd newuser

Mirrorselect / Makeopts

Next we're going to select a mirror for portage, and setup the make options
The RPi2 is a quad core so I'm using -j5 for the make options to use all the cores

First lets install mirrorselect

emerge mirrorselect

Next the sync setting has been moved out of make.conf to /etc/portage/repos.conf/gentoo.conf so lets set that up

mkdir /etc/portage/repos.conf
cp /usr/share/portage/config/repos.conf /etc/portage/repos.conf/gentoo.conf

The gentoo mirrors setting is still stored within /etc/portage/make.conf, this statement should update it with the fastest mirrors it can find

mirrorselect -s3 -b10 -D

Lets set the make options for -j5 to use all 4 cores during compile

echo 'MAKEOPTS="-j5"' >> /etc/portage/make.conf

Setup useflags tool

The next app to install is ufed for managing use flags. I'd recomend finishing off this section first for emerging the system, before setting up any additional use flags. As soon as you start to turn use flags on it can be very easy to pull in a lot of packages as part of an update

emerge ufed

Setup 02locale file

nano -w /etc/env.d/02locale

For British locales


Setup 02locale file

nano -w /etc/locale.gen

For British locales

en_GB ISO-8859-1
en_GB.UTF-8 UTF-8

Regenerate locale


Package Setup

Install of additional tools

Lets install some additional tools for package management
layman is useful for overlays, and gentoolkit is usefull for revdep-rebuild usbbutils is for lsusb

emerge layman
emerge gentoolkit
emerge usbutils

Updating the Packages

Next lets do some updates and rebuilds
Some of this is probably optional, but I've included for info

Lets do some world updates

emerge -vpuD --newuse world
emerge -vuD --newuse world
emerge --update --newuse --deep --with-bdeps=y @world

Remerge libtool to avoid further potential problems

emerge --oneshot libtool

Lets do some cleaning for perl

perl-cleaner --all

Lets run python updater


Lets remerge the system just to be safe

emerge system

Now lets do a depclean
Note on my system because nano wasn't recorded in the world file
This uninstalled nano, so you may want to re-install it afterwards if it's removed

emerge -p --depclean
emerge --depclean

Next a revdep-rebuild

revdep-rebuild -p

Let's make sure package.accept_keywords is a directory

mkdir /etc/portage/package.accept_keywords
echo "" >/etc/portage/package.accept_keywords/default.keywords

Re-compiling everything

If you happen to change your cflags for any reason within make.conf
The recompiling everything should optimise everything with the latest cflgas
(but will also take a long time to do)

emerge -e system && emerge -e world

Aditional Setup / Tools

Testing the Hard disk speed

In order to check the speed of the hard disk

emerge hdparm
hdparm -tT /dev/sda

Setup Software Clock

Next the rpi doesn't have a hardware clock, so we need to enable the software clock instead

rc-update add swclock boot
rc-update del hwclock boot

To install ntp for syncing the time over the network

emerge ntp
/etc/init.d/ntp-client start
rc-update add ntp-client default

One of the problems I've had is with ntp-client starting before wlan can finish starting. As a quick fix, first create a new file

nano -w /etc/local.d/10_ntp-client.start

Put the following in it

sleep 10s && /etc/init.d/ntp-client restart

Make the file executable

chmod 744 /etc/local.d/10_ntp-client.start

There's some more details here on setting up a dispatcher with ntp Link

CPU Power Scaling

To enable CPU Power Scaling

emerge --autounmask-write sys-power/cpupower
emerge sys-power/cpupower
/etc/init.d/cpupower start
rc-update add cpupower default

To set the scaling options

nano -w /etc/conf.d/cpupower

START_OPTS="--governor ondemand"
STOP_OPTS="--governor performance"

To check the current mode

cpupower frequency-info

GPU Memory

We can optionally set the amount of memory used by the gpu within /boot/config.txt

nano /boot/config.txt



Kernel Modules

One of next things to setup is a list of kernel modules to auto load at boot

nano -w /etc/conf.d/modules

# RPI GPIO Access
modules="${modules} i2c_bcm2708 spi_bcm2708 spi_bcm2835 w1-gpio "

# WatchDog / Random Number Generator
modules="${modules} bcm2708-rng bcm2708_wdog "

# ALSA / Audio Support
modules="${modules} snd_bcm2835 "

# Video 4 Linux Rpi (Doesn't currently work)
#modules="${modules} bcm2835_v4l2 "

For some reason I've not managed to get the video 4 linux driver working just yet
It might be something to do with a difference between the rpi and the rpi2

Audio support

As a first step the best approach is to first enable the alsa and oss use flags under gentoo
Enabling both shouldn't hurt, oss used to be depreciated (v3) but there is now a V4 alternative to alsa

To emerge some needed tools

emerge alsa-utils
emerge alsa-plugins

Next to edit the alsa config

nano -w /etc/modprobe.d/alsa.conf

alias snd-card-0 snd_bcm2835
alias sound-slot-0 snd-card-0

Next lets add the alsa service to the boot run level and start

rc-update add alsasound boot
/etc/init.d/alsasound start

To test the speaker output

speaker-test -t wav -c 2

To change the volume


Lists available devices

aplay -L
aplay --list-devices

To show the current selected ouput (0=auto, 1=analog, 2=HDMI)

amixer cget numid=3

To force the output to hdmi (auto works okay as well)

amixer cset numid=3 2

To play some mp3s

emerge mpg123
wget --content-disposition ""
mpg123 "Ronald Jenkees - Guitar Sound.mp3"

Additional Links / Sources of information