Raspberry Pi running gentoo

by Gregor Uhlenheuer on November 11, 2012

After having tried the ubuntu and archlinux distributions on my Raspberry Pi I came back to my favorite linux distribution gentoo. You can find a short walkthrough of my installation steps below.

Get files

First you have to download the files necessary for the installation:

You can get the latest Raspberry Pi kernel from github:

Preparing the SD card

Now that we have all necessary files you can insert your SD card. In the following steps I am using /dev/mmcblk0 to identify the SD card. This identifier may vary on other systems - you can check with dmesg after inserting your card.

Create the partitions

I chose to create a FAT32 boot partition of 32 MB, a swap partition with 512 MB and the rest for the root EXT4 partition.

Create file systems

Installing gentoo

The SD card is formatted and ready to be used for gentoo installation.

Mounting partitions

I am using the directory /tmp/mnt/gentoo for the installation directory. You are free to substitute this to your liking.

Extract files

Next we can extract portage and the stage3 image on the mounted SD card:

Install kernel and modules

Next we have to copy the kernel and its modules from the cloned github repository:

Configuration

Before being able to use the new installation we have to adjust a few configuration files.

Edit fstab

Next you have to edit your fstab to match your partition scheme:

My fstab looks like this:

/dev/mmcblk0p1	/boot	auto	noauto,noatime	1 2
/dev/mmcblk0p2	none	swap	sw		0 0
/dev/mmcblk0p3	/	ext4	noatime		0 1

Set boot options

After that you have to create a cmdline.txt file to pass the required boot parameters:

Edit make.conf

After that you may want to edit your make.conf file to set your desired make parameters like CFLAGS and set some default USE flags.

Set timezone

Next you will want to set your current timezone. Find a list of available timezones like this:

Set your desired timezone by copying the zoneinfo to the new file /etc/localtime. In my case I chose the Europe/Berlin timezone:

Reset root password

As we don’t want to chroot into the newly created gentoo installation we just reset the root password by editing the /tmp/mnt/gentoo/etc/shadow file to the following:

root::10770:0:::::

Boot your Raspberry Pi

Before booting your Raspberry Pi you first have to unmount the SD card:

Post boot installation steps

After inserting your SD card into your Raspberry Pi and turning on the power you should see a gentoo startup sequence and a login prompt.

Set root password

After logging into root without a password you should immediately set a new password for root:

Networking

In order to activate networking on boot you can add an entry via rc-update:

Configuring inittab

In case you get error messages like INIT Id "s0" respawning too fast on boot you may want to comment the first two serial console entries in /etc/inittab:

After editing the mentioned entries should look like this:

# SERIAL CONSOLES
#s0:12345:respawn:/sbin/agetty 9600 ttyS0 vt100
#s1:12345:respawn:/sbin/agetty 9600 ttyS1 vt100

Clock

The Raspberry Pi does not have a hardware clock so you need to disable the hwclock service and enable swclock instead:

Optionally you may want to emerge ntp and synchronize the clock on startup:

SSH

You probably want to ssh into your Raspberry Pi from time to time:

Update system

After all necessary installation steps are passed you can update your system and start using gentoo on your Raspberry Pi:

References

This post is tagged with linux, gentoo and raspberrypi