Install The 2007 PPC Gentoo

What is Gentoo Linux? Gentoo Linux is a distribution of Linux that emphasizes customization. Read more about Gentoo at gentoo.org.[1]

Using this method you can install an entire Gentoo image on your PowerPC-based (PPC) Linkstation or Kurobox, complete with Portage and overlay, in about 15 minutes (actually with downloading and unpacking I think it might be more like 30 - 45 minutes).

These instructions are admittedly Kurobox centric, however PPC linkstations should work with the image as well. Please add to or correct these instructions to make them work for both platforms if you find anything missing or confusing.

The image was created immediately following a deep world update, and is the only version of the Gentoo image now required (the previous install image had two versions). The only requirement is that your box must have a U-Boot that boots to a 2.6 kernel and supports dtb, e.g., U-Boot 1.2 (see below). The new image includes a 2.6.22 kernel and dtb file, generated from gentoo-sources.

Origins of the Gentoo Image

A Little History

(please fill in missing info, I don't mean to leave anyone out)

This Gentoo image has its roots in the kurobox.com forums, probably dating back to 2005 or so. jgmdean kicked off the project and TGL and others in the forums made valuable contributions. With the advent of U-Boot for the Kurobox and Linkstation from linuxnotincluded, the submission of the Linkstation patches to kernel.org by lyakh, and the 2.4.33.3 firmimg.bin for EM mode by mindbender, the Gentoo image is now thriving again with support for both PPC Linkstations and Kuroboxes.

Preparing for Install

U-Boot 1.2

It is recommended that you have U-Boot 1.2 installed prior to installing the Gentoo image due to the dtb requirement. The instructions for installing U-Boot 1.2 are here on the wiki. You don't have to build the kernel as it shows in the instructions if you don't want to since there is a kernel supplied in the Gentoo image. Also, you may be able to find a U-Boot 1.2 pre-built and ready to flash in the downloads section (for the HG: here). Please be careful doing this upgrade.

The rest of these instructions assume you have a working U-Boot 1.2.

Download needed files

You will need to download the Gentoo image, the EM mode utilities, and the latest Portage tree.

Install EM mode utilities

Now we need to switch the box to EM mode[2]. There are a variety of ways to do this two of which are described below:

1: From the U-Boot 1.2 boot menu type 'run emboot', or if using foonas-em 'run fooflboot', then wait for the box to boot.

2: Turn on your box, wait a few seconds, then press the Power button three times (you should now see the Disk Full LED start to repeat a three flash pattern). This is EM mode. Now wait for the box to boot. A YouTube video showing this method is here.

For Linkstations with Kernel 2.4.17 or 2.4.20 (Stock firmimg.bin)

You need to install the 2.4.33.3 firmimg.bin which features telnet/ftp like the Kurobox one does. Look to Uboot_firmimg.bin_ppc for installation instructions.

For boxes with 2.4.33.3 firmimg.bin (Kurobox/KuroboxHG/LS1/HG/HS)

The binaries from EM_mode_binaries.tar.gz should already be included but it was reported that bzip2 was missing. This means you'll need to install the EM_mode_binaries and set the date as described below.

Partitioning & Formating the HDD

Note: The /etc/fstab file that comes with the Gentoo image is configured to work with a simple hard drive partitioning scheme. If you want to use a different partitioning scheme you must edit /etc/fstab accordingly. The flash contains the standard visual editor, vi. Instructions for using vi are available at http://www.cs.colostate.edu/helpdocs/vi.html.

Note: the image is prepared for use with an instream 2.6 kernel, which uses the PATA driver, or /dev/sda, for the hard drive. When running under a 2.4 kernel or a legacy 2.6 kernel with out-of-stream patches, the drive is /dev/hda. Keep that in mind when creating the partitions and editing the fstab file.

Run fdisk and create partitions. The image uses three partitions: sda1 for /, sda2 for the swap space, sda3 for /datafiles. This section from the Gentoo Handbook explains how to prepare your hard disk (create partitions). For most users, 10gb for / on sda1 and is adequate (the image consumes around 1.4G when freshly installed). 512mb is good for a swap space on sda2 and use the remainder for /datafiles on sda3. However, you can decide which way you want to break up your hard disk. Remember you need to mount all of the drives (except the swap and /datafiles) before you untar the image (More on that later).

Install Gentoo Image

Mount new partitions

This will allow us to create the Gentoo system on the hard drive instead of in the flash ram disk. We will create the directoy /gentoo and mount /dev/hda1 there.

# mkdir /gentoo
# mount -t ext3 /dev/hda1 /gentoo
(if you created any other partitions to be mounted under /, you should mkdir and mount them now)

Create a directory for uploading the tarballs through ftp:

# mkdir /gentoo/tarballs
# chmod ugo+wx /gentoo/tarballs

Extracting the Image

Use your FTP client to upload the Gentoo image (gentoo-20071104-uboot.tar.bz2) to the /gentoo/tarballs directory on the Kuro/LS.

Then, back at the EM-mode prompt, change directories to /gentoo and untar the image in what will be our root directory:

# cd /gentoo
# tar xvjf tarballs/gentoo-20071104-uboot.tar.bz2

Extracting the portage snapshot

Again, use your ftp client to upload the Portage snapshot (portage-latest.tar.bz2) to the /gentoo/tarballs directory on the kuro/LS

Then, back at the EM-mode prompt, untar the snapshot into the usr directory:

# cd /gentoo/usr
# tar xvjf /gentoo/tarballs/portage-latest.tar.bz2

Once the snapshot is untarred, we are finished with the tarballs so we can remove them from the disk:

# cd /gentoo
# rm -r tarballs

Configure Network

Next we configure the network:

/etc/conf.d/hostname

If you want to change the hostname now, edit this file:

# vi /gentoo/etc/conf.d/hostname

/etc/conf.d/net

If you want to use DHCP you can skip this step as the image is configured for DHCP. Note that if DHCP fails the box will fallback to the well-known IP address of 192.168.11.150.

# vi /gentoo/etc/conf.d/net

The Gentoo Handbook Section 4 explains how to configure the settings for various options. The /etc/conf.d/net file supplied in the image looks like this:

# This configuration will use DHCP for eth0 but fallback to the
# well-known 192.168.11.150 if DHCP fails
config_eth0=(
"dhcp"
)
fallback_eth0=(
"192.168.11.150/24"
)

/etc/resolv.conf

You may have to configure your DNS servers in resolv.conf file according to your network. If you stick to DHCP you generally don't have to edit the file, as it will be generated by dhcpcd upon bootup.

# vi /gentoo/etc/resolv.conf

The file supplied in the image looks like this:

nameserver 127.0.0.1

Configure Settings for the Kernel

If you want to use the kernel supplied in the image, you can skip this section as long as your U-Boot is configured to load the kernel "boot/vmlinux.UBoot", and the appropriate dtb file as shown below. If you want to use a different kernel you should place it in gentoo/boot now and configure U-Boot accordingly. Note, the kernel supplied with the image disables the AVR watchdog at bootup and sets up the AVR device at /dev/ttyS0. The legacy kernels (kernels from baulub, javascout, and nowadays available through andre's webinstaller) typically have the AVR device at /dev/ttyS1 and do not disable the AVR watchdog. The AVR_watch-dog_daemon for Linkstation package (avr_evtd from the overlay) is present in the image however, which sends a keepalive signal to the watchdog, so you should not have to worry about resets (but you should move the daemon from the default runlevel to the boot runlevel). If you use a legacy kernel you must adjust a few things to account for the AVR device and also for the PATA vs. IDE driver.

These items must be changed if you use a legacy kernel:

/etc/fstab: change /dev/sda to /dev/hda

/etc/inittab: change ttyS1 to ttyS0

/etc/conf.d/avr_evtd: change ttyS0 to ttyS1 and /dev/sda to /dev/hda

/etc/conf.d/rc: change ttyS0 to ttyS1

/etc/conf.d/local.stop: change ttyS0 to ttyS1

The kernel supplied in the image was built from gentoo-sources. The uname -a looks like:

Now would be a good time to update everything. Let's sync the overlay with the svn server. First, I suggest optionally backing up the installed overlay:

# cd /usr/local/portage/layman
# cp -r ls-wiki ../ls-wiki.bak

Then sync the overlay with the subversion server:

# layman -S

Since we used the latest portage snapshot you can probably skip this next step, but to be sure you have the latest Portage tree you can sync it now with this command:

# emerge --sync

Then you should check what packages are out of date with a command like this:

# emerge --pretend --update --deep world

This will show you what packages are out-of-date since the image was created. I always like to do --pretend to see what it's going to do before doing it for real (some people may prefer to use --ask instead of --pretend to avoid waiting if the update is chosen). To really update everything, use this command:

# emerge --update --deep world

Last, if anything was updated and portage says we need to update our config files we run etc-update. Don't do this blindly as you can easily break your brand new system. You need to understand what the configuration files mean and choose what lines you want to edit. On the other hand, the box is plain vanilla at this point so the configuration files supplied with the updated packages are probably ok to accept.

# etc-update

That's it. You're done. If you are new to Gentoo, check out the Gentoo Handbook "Where to go from here?". Also, you should consider going to the Administrate Your Gentoo System page and installing some system utilities (note, the last time I checked, that page on the wiki was woefully obsolete - there are no bin packages available for this image so don't bother with the PORTAGE_BINHOST setting).

Notes on initial configuration

/etc/localtime

The timezone in the image is set for New York, or EST/EDT. If you live in a different timezone, you should change this link. Look for your timezone in /usr/share/zoneinfo/ and then create a link to your desired timezone:

Check your setting with the 'date' command. Also if you need to change the clock, use the 'hwclock' command. You also may want to emerge the ntp package to set your clock in sync with Internet time servers.

/etc/conf.d/clock

There is a timezone setting in this file as well. You can set the timezone to the same one as the link above.

# vi /etc/conf.d/clock
(set the TIMEZONE to something like TIMEZONE="America/New_York")

/etc/rc.conf

This file contains a setting for the AVR device. Since the image contains a kernel that uses /dev/ttyS0 for the AVR device, the file contains a line like this:

AVR_DEVICE=/dev/ttyS0

/etc/conf.d/local.stop

This file is run whenever the box is shutting down for halt or reboot. There is a little bit of code in this file such that if "shutdown -r now" or "shutdown -h now" is run from the command line, the AVR is told to turn off the power or start a reset. The following code is in the /etc/conf.d/local.stop file:

layman

The image is taking advantage of the noteworthy layman package for managing the overlay. This provides the ability to download updates from the nas-central/linkstationwiki subversion server at sourceforge. This is a very powerful utility, but perhaps should not be trusted blindly. I suggest making a backup of the /usr/local/portage/layman/ls-wiki directory tree after the first install and each time before using the "layman -S" command. Also, check occasionally in the forums at nas-central.org (in Software Development (ppc)) and kurobox.com (under the gentoo project [these two forums should eventually merge into one at nas-central]) for announcements regarding new packages that may be added to the overlay.

kernel

The kernel provided in the image was built from gentoo-sources. Then, to keep the image size smaller, the gentoo-sources package was unmerged and removed after the kernel was built. If you want to build a new kernel for some reason, you can do something like the following:

shutdown/reboot 5-minute delay

The box takes 5 minutes to perform a shutdown (power off) or reboot. This
seems to be a feature with the AVR (if anyone knows how to improve this,
let us know - the stock implementation did not seem to take this long). I
believe it in fact does not take half this time to actually complete shutting
down, so if you are really impatient, you can probably just cycle the
power after about 3 minutes and be ok. Note, if you have installed a lot
of services the shutdown process could take longer so beware.

distcc

Running Gentoo on the LS/Kurobox works great, but compiling is slow. If you have a x86 or other more capable CPU running linux, it can help significantly to run distcc on the more capable CPU and enable the LS/Kurobox to offload some of the work for big emerges. See this howto to set it up.

Troubleshooting

U-Boot Output on netcat

To see the U-Boot output through netcat, your PC should have an IP address on the same subnet as the uboot setup. If you went with the typical setup, you should set your PC to 192.168.11.149. See the wiki page on netcat and uboot: NetCat-A UBoot-Friendly Network Utility. If you have a linux PC, use a command like "ifconfig eth0:EM 192.168.11.149". This will give you a second IP address for your ethernet interface. If you have a Windows PC, you will have to set the IP address through the properties on the network interface. Then use the nc command like this:

nc -u -p 6666 -v -v 192.168.11.150 6666

You should see something like the following in the nc window during bootup. Note it says it is loading the kernel file "Loading 0:1:boot/vmlinux.UBoot". Also note it says it uncompresses the kernel ok and that it is loading the flat device tree:

boot.msg

If you cannot find the box on the network, try the fallback IP address 192.168.11.150.

If you still cannot find the box on the network, try to shutdown the box by holding the power button for about 3 seconds. The Power LED should start blinking to indicate the box is going to shut down. If the Power LED does not start blinking, you will probably have to pull the power cord. Go back to EM mode and mount the /dev/hda1 partition. Look in the var/log directory for a file called boot.msg. This file is created during the boot process. It may give you some clues as to what is going on. Note, this file is created because /etc/conf.d/rc has RC_BOOTLOG="yes" and the image has emerged app-admin/showconsole. If you don't have a file called boot.msg, look harder at the netcat output, perhaps the kernel is not successfully booting.