Difference between revisions of "Install The 2007 PPC Gentoo"

From NAS-Central Buffalo - The Linkstation Wiki
Jump to: navigation, search
(Install EM mode utilities)
(No difference)

Revision as of 02:09, 5 November 2007

Current Kurobox Gentoo Image Date: 2007/11/04

Using this method, you can install an entire Gentoo image complete with portage and overlay in about 15 minutes (actually with downloading and unpacking I think it might be more like 30 - 45 minutes). The image was created immediately following a deep world update by russK. There is only one version of the gentoo image (previous image had two versions). The image supports ppc kuroboxes and linkstations. The only requirement is that your box must have uboot that boots a 2.6 kernel. The 1.2 uboot that supports a dtb is preferred, and in fact the image includes a 2.6.22 kernel and dtb file, generated from gentoo-sources.

Preparing for Install


The steps for installing uboot will not be detailed here. It is recommended that you have uboot installed prior to installing the gentoo image. This gentoo image is not very useful for testing the RAM build and flashing the ROM build unfortunately because the binaries in the image are linked with glibc 2.6 (and therefore will not run under a 2.4 kernel). The instructions for installing UBoot 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 1.2 uboot pre-built and ready to flash in the downloads section. That's what I did.

The rest of these instructions assume you have a working 1.2 uboot.

Download needed files

You will need to download the gentoo image, the EM mode utilities, and the latest portage tree.

Install EM mode utilities

Switch the box to EM mode (see the Frequently Asked Questions for details on how to do this). Note, uboot 1.2 typically is set up to boot to EM mode by hitting "s <return>", and then entering "run emboot" at the prompt.

After it boots to EM mode, use any FTP client to upload EM_mode_binaries.tar.gz to /tmp on the Kuro (hint: Windows may change the extension of the file when you download it from the internet).

then login to kuro using a telnet client.

Kroutoshikou KURO-BOX (IETSUNA) 
kernel 2.4.17-kuro-box on ppc 
KURO-BOX-EM login: root 
Password: kuro (kuroadmin on HG)

Change to the root and untar the binaries.

# cd / 
# tar xvzf /tmp/EM_mode_binaries.tar.gz 

Check and set the date.

# date 
Fri Feb 1 12:37:03 JST 2006 
# date 02032238 
Thu Feb 3 22:38:00 JST 2006

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 kurobox 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).

# fdisk /dev/hda
(to match the fstab supplied in the image, you will need to create 3 partitions, 1=~10G, 2=~512M, 3=rest-of-drive)

Once the partitions are created we format the partitions. Here we format the first partition on /dev/hda (the hard drive is /dev/hda).

# mke2fs -j /dev/hda1 
mke2fs 1.22, 22-Jun-2001 for EXT2 FS 0.5b, 95/08/09 
Filesystem label= 
OS type: Linux 
Block size=4096 (log=2) 
Fragment size=4096 (log=2) 
1251712 inodes, 2502115 blocks 
125105 blocks (5.00%) reserved for the super user 
First data block=0 
77 block groups 
32768 blocks per group, 32768 fragments per group 
16256 inodes per group 
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 

Writing inode tables: done 
Creating journal (8192 blocks): done 
Writing superblocks and filesystem accounting information: done 

This filesystem will be automatically checked every 29 mounts or 
180 days, whichever comes first. Use tune2fs -c or -i to override.

We do this for all of the partitions we plan to use.

# mke2fs -j /dev/hda3 
Next we create the swap space
# mkswap /dev/hda2 
Setting up swapspace version 1, size = 518184960 bytes 

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)

Extracting the Image

Use your FTP client to upload the gentoo image (gentoo-20071104-uboot.tar.bz2) to the /gentoo 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 gentoo-20071104-uboot.tar.bz2

Once the image is untarred, we can delete the image from /gentoo

# rm 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 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/portage-latest.tar.bz2

Once the snapshot is untarred, we can delete it from /gentoo

# cd /gentoo
# rm portage-latest.tar.bz2

Configure Network

Next we configure the network.


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

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


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

# 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 if DHCP fails


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:


You may want to get a kernel now

The gentoo image provides a kernel and dtb files in /boot. If you want to use a different kernel, you should place it in /boot now and configure uboot appropriately.

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

Linux gmyth 2.6.22-gentoo-r5 #1 Tue Oct 16 03:22:32 EDT 2007 ppc 82xx Linkstation I/Kurobox(HG) GNU/Linux

The contents of the /boot directory supplied in the image are:

-rw-r--r-- 1 root root  653994 Oct 16 22:09 System.map
lrwxrwxrwx 1 root root       1 Oct  2 23:42 boot -> .
-rw-r--r-- 1 root root   37690 Oct 16 22:09 config
-rw-r--r-- 1 root root    2180 Oct 16 22:10 kuroboxHD.dtb
-rw-r--r-- 1 root root    3338 Oct 16 22:08 kuroboxHD.dts
-rw-r--r-- 1 root root    2196 Oct 16 22:10 kuroboxHG.dtb
-rw-r--r-- 1 root root    3369 Oct 16 22:08 kuroboxHG.dts
-rw-r--r-- 1 root root 1588842 Oct 16 22:08 vmlinux.UBoot

Clean up and Reboot

Unmount everything

# cd /
# # (umount any partitions you may have mounted if you departed from the provided fstab)
# umount /gentoo 

Set the box to boot to the new system. By the way, that device is FL3 in lowercase. (This step is optional nowadays with uboot).

# echo -n "OKOK" > /dev/fl3 

and then restart the system

# shutdown -r now 

Wait a few minutes and then log onto your kuro/LS with putty or ssh. The first time the system boots it will take about 3 minutes as it needs to generate the certificates used by sshd.

Login as root with the password: kuroadmin.

What if it doesn't seem to boot? Give it plenty of time -- it might be doing a fsck. If you still cannot connect, see #Troubleshooting.

Post Installation Tasks

First we set the root password and create a new user who is a member of wheel so they can su to root.

kurobox ~ # cd /
kurobox # passwd 
New UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully 
kurobox # useradd dtaylor -m -G users,wheel -s /bin/bash 
kurobox # passwd dtaylor 
New UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully 
kurobox #

Now would be a good time to update everything. Let's sync the overlay with the svn server:

# layman -S

Since we used the latest portage snapshot, you can probably skip this step, but to be sure you have the latest portage tree, you can do this:

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


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:

# cd /etc
# rm localtime
# ln -s ../usr/share/zoneinfo/<your-desired-timezone-here> localtime

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.


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


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:



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 of the power or start a reset. The following code is in the /etc/conf.d/local.stop file:

#AVR_DEVICE should come from /etc/rc.conf
[ -z "${AVR_DEVICE}" ] && AVR_DEVICE=/dev/ttyS0

# on halt
[ "${RUNLEVEL}X" = "0X" ] && echo -n "EEEE" > ${AVR_DEVICE}

# on reboot
[ "${RUNLEVEL}X" = "6X" ] && echo -n "CCCC" > ${AVR_DEVICE}

Note the avr_evtd package does this when the power button on the front panel is pushed (once long to halt or twice quick to reboot), and it seems ok to have it done twice when using the power button.


The image as delivered has just a few packages emerged beyond the basic system. The contents of the world file are:


list of all emerged packages

# equery list
[ Searching for all packages in all categories among: ]
 * installed packages
[I--] [  ] app-admin/apache-tools-2.2.6 (0)
[I--] [  ] app-admin/eselect-1.0.10 (0)
[I--] [  ] app-admin/eselect-vi-1.1.4 (0)
[I--] [  ] app-admin/perl-cleaner-1.04.3 (0)
[I--] [  ] app-admin/python-updater-0.2 (0)
[I--] [  ] app-admin/showconsole-1.08 (0)
[I--] [  ] app-arch/bzip2-1.0.4 (0)
[I--] [  ] app-arch/cpio-2.9-r1 (0)
[I--] [  ] app-arch/gzip-1.3.12 (0)
[I--] [  ] app-arch/tar-1.18-r2 (0)
[I--] [  ] app-crypt/hashalot-0.3-r2 (0)
[I--] [  ] app-editors/nano-2.0.6 (0)
[I--] [  ] app-editors/vim-7.1.042 (0)
[I--] [  ] app-editors/vim-core-7.1.042 (0)
[I--] [  ] app-misc/ca-certificates-20070303-r1 (0)
[I--] [  ] app-misc/mime-types-7 (0)
[I--] [  ] app-misc/pax-utils-0.1.16 (0)
[I--] [  ] app-portage/gentoolkit-0.2.3-r1 (0)
[I--] [  ] app-portage/layman-1.1.1 (0)
[I--] [  ] app-shells/bash-3.2_p17 (0)
[I--] [  ] app-vim/gentoo-syntax-20070506 (0)
[I--] [  ] dev-lang/perl-5.8.8-r2 (0)
[I--] [  ] dev-lang/python-2.4.4-r6 (2.4)
[I--] [  ] dev-libs/apr-1.2.8 (1)
[I--] [  ] dev-libs/apr-util-1.2.8 (1)
[I--] [  ] dev-libs/expat-2.0.1 (0)
[I--] [  ] dev-libs/libpcre-7.3-r1 (3)
[I--] [  ] dev-libs/libusb-0.1.12-r1 (0)
[I--] [  ] dev-libs/libxml2-2.6.28 (2)
[I--] [ -] dev-libs/openssl-0.9.8f (0)
[I--] [  ] dev-libs/popt-1.10.7 (0)
[I--] [  ] dev-perl/Locale-gettext-1.05 (0)
[I--] [  ] dev-python/pycrypto-2.0.1-r6 (0)
[I--] [  ] dev-python/python-fchksum-1.7.1 (0)
[I--] [  ] dev-util/ctags-5.5.4-r2 (0)
[I--] [  ] dev-util/pkgconfig-0.21-r1 (0)
[I--] [  ] dev-util/subversion-1.3.2-r4 (0)
[I--] [  ] dev-util/unifdef-1.20 (0)
[I--] [  ] net-misc/dhcpcd-3.1.5-r1 (0)
[I--] [  ] net-misc/iputils-20070202 (0)
[I--] [  ] net-misc/neon-0.26.3 (0)
[I--] [  ] net-misc/openssh-4.7_p1-r1 (0)
[I--] [  ] net-misc/rsync-2.6.9-r3 (0)
[I--] [  ] net-misc/wget-1.10.2 (0)
[I--] [  ] perl-core/PodParser-1.35 (0)
[I--] [  ] perl-core/Test-Harness-2.64 (0)
[I--] [  ] sys-apps/acl-2.2.45 (0)
[I--] [  ] sys-apps/attr-2.4.39 (0)
[I--] [  ] sys-apps/avr_evtd-1.7.2 (0)
[I--] [  ] sys-apps/baselayout-1.12.9-r2 (0)
[I--] [  ] sys-apps/busybox-1.5.1 (0)
[I--] [  ] sys-apps/coreutils-6.9-r1 (0)
[I--] [  ] sys-apps/debianutils-2.17.5 (0)
[I--] [  ] sys-apps/diffutils-2.8.7-r2 (0)
[I--] [  ] sys-apps/file-4.21-r1 (0)
[I--] [  ] sys-apps/findutils-4.3.8-r1 (0)
[I--] [  ] sys-apps/gawk-3.1.5-r5 (0)
[I--] [  ] sys-apps/grep-2.5.1a-r1 (0)
[I--] [  ] sys-apps/groff-1.19.2-r1 (0)
[I--] [  ] sys-apps/hdparm-7.7 (0)
[I--] [  ] sys-apps/help2man-1.36.4 (0)
[I--] [  ] sys-apps/hotplug-20040923-r2 (0)
[I--] [  ] sys-apps/hotplug-base-20040401 (0)
[I--] [  ] sys-apps/less-406 (0)
[I--] [  ] sys-apps/man-1.6e-r3 (0)
[I--] [  ] sys-apps/man-pages-2.66 (0)
[I--] [  ] sys-apps/mktemp-1.5 (0)
[I--] [  ] sys-apps/module-init-tools-3.2.2-r3 (0)
[I--] [  ] sys-apps/net-tools-1.60-r13 (0)
[I--] [  ] sys-apps/pciutils-2.2.4-r3 (0)
[I--] [  ] sys-apps/portage- (0)
[I--] [  ] sys-apps/sandbox- (0)
[I--] [  ] sys-apps/sed-4.1.5 (0)
[I--] [ -] sys-apps/setarch-2.0 (0)
[I--] [  ] sys-apps/shadow- (0)
[I--] [  ] sys-apps/sysvinit-2.86-r13 (0)
[I--] [  ] sys-apps/tcp-wrappers-7.6-r8 (0)
[I--] [  ] sys-apps/texinfo-4.8-r5 (0)
[I--] [  ] sys-apps/usbutils-0.72-r4 (0)
[I--] [  ] sys-apps/util-linux-2.12r-r8 (0)
[I--] [  ] sys-apps/which-2.16 (0)
[I--] [  ] sys-devel/autoconf-2.61-r1 (2.5)
[I--] [  ] sys-devel/autoconf-wrapper-4-r3 (0)
[I--] [  ] sys-devel/automake-1.10 (1.10)
[I--] [  ] sys-devel/automake-wrapper-3-r1 (0)
[I--] [  ] sys-devel/binutils-2.18-r1 (0)
[I--] [  ] sys-devel/binutils-config-1.9-r4 (0)
[I--] [  ] sys-devel/bison-2.3 (0)
[I--] [  ] sys-devel/flex-2.5.33-r3 (0)
[I--] [ -] sys-devel/gcc-4.1.2 (4.1)
[I--] [  ] sys-devel/gcc-config-1.3.16 (0)
[I--] [  ] sys-devel/gettext-0.16.1-r1 (0)
[I--] [  ] sys-devel/gnuconfig-20070118 (0)
[I--] [  ] sys-devel/libperl-5.8.8-r1 (1)
[I--] [  ] sys-devel/libtool-1.5.24 (1.5)
[I--] [  ] sys-devel/m4-1.4.10 (0)
[I--] [  ] sys-devel/make-3.81 (0)
[I--] [  ] sys-devel/patch-2.5.9 (0)
[I--] [  ] sys-fs/e2fsprogs-1.39-r2 (0)
[I--] [  ] sys-fs/udev-115-r1 (0)
[I--] [ -] sys-kernel/linux-headers-2.6.21 (0)
[I--] [  ] sys-libs/com_err-1.39 (0)
[I--] [  ] sys-libs/cracklib-2.8.10 (0)
[I--] [  ] sys-libs/db-4.5.20_p2 (4.5)
[I--] [  ] sys-libs/gdbm-1.8.3-r3 (0)
[I--] [  ] sys-libs/glibc-2.6.1 (2.2)
[I--] [  ] sys-libs/gpm-1.20.1-r5 (0)
[I--] [  ] sys-libs/ncurses-5.6-r1 (5)
[I--] [  ] sys-libs/readline-5.2_p7 (0)
[I--] [  ] sys-libs/ss-1.39 (0)
[I--] [  ] sys-libs/timezone-data-2007g (0)
[I--] [  ] sys-libs/zlib-1.2.3-r1 (0)
[I--] [  ] sys-process/procps-3.2.7 (0)
[I--] [  ] sys-process/psmisc-22.5-r2 (0)
[I--] [  ] virtual/editor-0 (0)
[I--] [  ] virtual/init-0 (0)
[I--] [  ] virtual/libiconv-0 (0)
[I--] [  ] virtual/libintl-0 (0)
[I--] [  ] www-servers/apache-2.2.6 (2)


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:

# emerge gentoo-sources
# cp /boot/config /usr/src/linux
# cd /usr/src/linux
# make oldconfig
# make menuconfig
# make uImage && make modules && make modules_install

Then copy the uImage file to /boot/vmlinux.UBoot or the appropriate name for your uboot.


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 emerge's. See this howto to set it up.


If you cannot find the box on the network, try the fallback IP address Set your PC to to try the connection. If you have a linux PC, use a command like "ifconfig eth0:EM".

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 are still having trouble, post a message to the forums at forum.nas-central.org.