User:RussK/Create 2007 kurobox Gentoo

From NAS-Central Buffalo - The Linkstation Wiki
Jump to: navigation, search

Note, this is for the original kurobox or kurobox HG, however it should in theory support the ppc LS boxes too. I'm going to document the steps I'm taking to create a new gentoo 15-minute image. That way someone else can duplicate the steps. It also helps to redo the steps quickly if something goes wrong somewhere along the way.

Nuvola apps important.png 
WARNING!

This is a work in progress. Following these steps might be a waste of time or leave you with an unusable system. I will remove this warning once the steps are proven.


Contents

Create chroot area

I am creating a chroot area and starting with the previous 15-minute image.

# cd /datafiles/chroots
# mkdir gentoo-20071104-uboot
# cd gentoo-20071104-uboot
# tar xjf ../gentoo-20060907-uboot.tar.bz2

Enter the chroot environment

# cd /
# cp /etc/resolv.conf /datafiles/chroots/gentoo-20071104-uboot/etc/resolv.conf
# mount -t proc none /datafiles/chroots/gentoo-20071104-uboot/proc
# chroot /datafiles/chroots/gentoo-20071104-uboot /bin/bash
# env-update
# source /etc/profile
# export PS1="(chroot) $PS1"

update the portage tree and portage

# emerge --sync
# emerge portage
# etc-update  # to update config files, just accept all changes

Copy the previous overlay area to a new area for modifying

# cd /usr/local/portage/
# mkdir kuro-2007-11-04
# cd kuro-2006-08-26
# find . -depth -print | cpio -pdmuv ../kuro-2007-11-04

Copy the previous profile to a new profile

# cd /usr/local/portage/kuro-2007-11-04/profiles/kurobox-uboot
# mkdir 2007.0
# find . -type f -print | cpio -pdmuv 2007.0

Change the parent profile to a newer base

# cd 2007.0
# nano parent
# change the line to: ../../../../../../portage/profiles/default-linux/ppc/ppc32/2007.0

Edit the packages file

# nano packages
# remove the second group of lines that pin us to certain versions of packages like baselayout etc

Resulting packages file looks like:

-*sys-apps/eject
-*sys-apps/fbset
-*sys-apps/kbd
-*sys-fs/hfsutils
-*sys-fs/hfsplusutils
-*sys-fs/mac-fdisk
-*virtual/bootloader
-*virtual/dev-manager
-*virtual/os-headers

Edit the virtuals file

I'm not exactly sure what the file is for but I know the kurobox-sources thing does not exist.

# nano virtuals
# comment out the virtual line with a '#' sign

Resulting file:

#virtual/linux-sources   sys-kernel/kurobox-sources

Switch to the newly created profile

# cd /etc
# rm -f make.profile
# ln -s ../usr/local/portage/kuro-2007-11-04/profiles/kurobox-uboot/2007.0 make.profile

Edit the make.conf file for new changes

Change the overlay directory, remove bogus USE flags, remove excludes directive

# nano make.conf

Resulting file:

# Kurobox make.conf

CFLAGS="-O2 -mcpu=603e -fno-strict-aliasing -pipe -fsigned-char"
CXXFLAGS="${CFLAGS}"

PORTDIR_OVERLAY="/usr/local/portage/kuro-2007-11-04"

USE="-X -gtk -gtk2 -gnome -qt -kde -opengl -motif -xmms -arts -alsa -oss -ipv6 samba cups usb"

Begin updates

Update dhcpcd first

dhcpcd is blocking the baselayout update. This is probably related to the fact that baselayout was pinned in the old profile.

# emerge --update dhcpcd

Update glibc

# emerge --update glibc


Run etc-update after glibc

# etc-update

Accept change for nscd


Completely rebuild everything

# emerge --emptytree system && emerge --emptytree world

This takes a long long time


Update config files with etc-update

# etc-update
( I selected -3 to automerge and overwrote all files)

emerge Update Deep world

# emerge --update --deep world

Fix udev rule for rtc so 'hwclock' command will work

# cd /etc/udev/rules.d/
# echo 'KERNEL="rtc0",SYMLINK="rtc"' > rtc.rules

Choose a timezone so uname -a will look right

# cd /etc
# rm -f localtime
# ln -s ../usr/share/zoneinfo/America/New_York localtime


Build a gentoo-sources kernel

git

# emerge dev-util/git
(might want to remove this later, it's big)

unzip

# emerge unzip

uboot

# cd /usr/src
# git clone git://www.jdl.com/software/u-boot-86xx.git u-boot-86xx
# wget http://www.kurobox.com/revolution/downloads/contest/patches.zip
# unzip patches.zip
# perl -pi -e 's/\r//' u-boot*.patch
# cd u-boot-86xx
# patch -p1 <../u-boot-kurobox.patch
# patch -p1 <../u-boot-kurobox-fdt.patch

(Follow the instruction for configuring and building u-boot on [1])

# cp /usr/src/u-boot-86xx/tools/mkimage /usr/local/bin

And now, since I've decided the 15-minute image will not include u-boot, remove the u-boot stuff. It can be gotten from other sources, or the user can follow the instructions for building it himself. At least this step was useful for getting the mkimage tool which is necessary for building uImage kernels.

# cd /usr/src
# rm -rf u-boot-*
# rm patches.zip
# rm kurobox_powerpc-20061105_target.gitdiff

dtc

# cd /usr/src
# git clone git://www.jdl.com/software/dtc.git dtc
# cd /usr/src/dtc
# make
# make DESTDIR=/usr/local PREFIX="" install
(errors on install for fdt.h and libfdt.h are ok for our purposes)
# which dtc
(should print /usr/local/bin/dtc)

gentoo-sources

# emerge gentoo-sources

build the kernel

# cd /usr/src/linux
# cp arch/powerpc/configs/linkstation_defconfig .config
# make menuconfig
# make uImage && make modules && make modules_install
# cp arch/powerpc/boot/uImage /boot/vmlinux.UBoot
# cp arch/powerpc/boot/dts/kurobox*.dts /boot/
# cp .config /boot/config
# cp System.map /boot
# cd /boot
# dtc -f -I dts -O dtb -o kuroboxHG.dtb -V 16 kuroboxHG.dts
# dtc -f -I dts -O dtb -o kuroboxHD.dtb -V 16 kuroboxHD.dts

Package Cleanup

remove git

(Trying to get the image size down)

# emerge --unmerge dev-util/git

emerge vim

[I hate nano, and as image creator, it's my prerogative to install my favorite editor ;-) ]

# emerge vim

emerge gentoolkit

(Necessary for revdep-rebuild step coming up soon)

# emerge gentookit

unmerge gcc-3.4.4-r1

(I don't expect anyone will need this, and it takes up space. They can emerge a gcc-3 compiler if they need one)

# emerge --unmerge =sys-devel/gcc-3.4.4-r1

depclean

(Clean out unneeded dependencies)

# emerge --depclean

revdep-rebuild

(Fix any broken dependencies)

# revdep-rebuild

remove gentoo-sources

(It's a shame it's so big - 359M)

# emerge --ummerge gentoo-sources
# cd /usr/src
# rm -rf linux linux-2.6.22-gentoo-r5


remove tmp files

# cd /var/tmp
# rm -rf *
# cd /tmp
# rm -rf *
# cd /usr/portage/distfiles
# rm -f *

Configure Startup

avr_evtd

An ebuild for avr_evtd has been prepared. Place it in /usr/local/portage/kuro-2007-11-04/sys-apps with associated files. (I did this by tarring in the tarfile from outside the chroot environment)

# emerge avr_evtd
# rc-update add avr_evtd default

kuro-avr-init

This is leftover from the old profile and won't be needed with modern kernels.

# rc-update del kuro-avr-init boot
# cd /etc/init.d
# rm kuro-avr-init

fstab

Since the image is targeted at in-stream kernels, need to change hda to sda. Also, since the kuro/LS is a NAS, it seems like three partitions is fine: one for root, one for swap, and one for datafiles. Users can change this to their liking at install time.

# vi /etc/fstab
(change hda to sda throughout)
(delete /dev/sda for /var)
(change /dev/sda4 to /dev/sda3 for /datafiles)

Important lines from resulting file:

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
/dev/sda1       /               ext3            defaults                0 1
/dev/sda2       none            swap            sw                      0 0
/dev/sda3       /datafiles      ext3            defaults                0 2

# NOTE: The next line is critical for boot!
none            /proc           proc            defaults                0 0

inittab

Since the instream kernel uses ttyS0 for the AVR, need to update the inittab to start getty on ttyS1 instead of ttyS0.

# vi /etc/inittab
(change ttyS0 to ttyS1 throughout)

Resulting important line in inittab:

c0:12345:respawn:/sbin/agetty 57600 ttyS1 vt100

/etc/conf.d/net

I noticed that if dhcp fails, the box is not on the network. This is not a good situation for a headless box. Change the net file to have a fallback IP.

# vi /etc/conf.d/net
(change the file to look as below)
# 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"
)

Other Fixups

re-emerge dhcpcd

I guess the depclean removed it - whoops.

# emerge dhcpcd

Move overlay to layman

This is a really cool way to maintain the overlay and distribute new ebuilds to people running gentoo on the LS/kurobox. I put the overlay on the SVN server at sourceforge.

emerge subversion

layman needs subversion but it's not an explicit a dependency, so emerge it explicitly. This pulls in 8 additional packages including apache. I think the apache dependency could be squashed with the right USE flags for subversion but maybe a lot of people will want apache anyway.

# emerge subversion

emerge layman

# emerge layman

/etc/layman/layman.cfg

We're going to put the storage in /usr/local/portage/layman and use a list from there called layman-local.txt.

# vi /etc/layman/layman.cfg
(change storage setting to be:  storage    : /usr/local/portage/layman)
(add a line to the overlays setting : file://%(storage)s/layman-local.txt)

The /etc/layman/layman.cfg file will look like this when modified:

[MAIN]

#-----------------------------------------------------------
# Path to the config directory

config_dir: /etc/layman

#-----------------------------------------------------------
# Defines the directory where overlays should be installed

storage   : /usr/local/portage/layman

#-----------------------------------------------------------
# Remote overlay lists will be stored here
# layman will append _md5(url).xml to each filename

cache     : %(storage)s/cache

#-----------------------------------------------------------
# The list of locally installed overlays

local_list: %(storage)s/overlays.xml

#-----------------------------------------------------------
# Path to the make.conf file that should be modified by
# layman

make_conf : %(storage)s/make.conf

#-----------------------------------------------------------
# URLs of the remote lists of overlays (one per line) or
# local overlay definitions
#
#overlays  : http://www.gentoo.org/proj/en/overlays/layman-global.txt
#            http://dev.gentoo.org/~wrobel/layman/global-overlays.xml
#            http://mydomain.org/my-layman-list.xml
#            file:///usr/portage/local/layman/my-list.xml

overlays  : http://www.gentoo.org/proj/en/overlays/layman-global.txt
            file://%(storage)s/layman-local.txt

#-----------------------------------------------------------
# Proxy support
#
#proxy  : http://www.my-proxy.org:3128

#-----------------------------------------------------------
# Strict checking of overlay definitions
#
# Set either to "yes" or "no". If "no" layman will issue
# warnings if an overlay definition is missing either
# description or contact information.
#
nocheck  : no

/usr/local/portage/layman/layman-local.txt

This is the file that tells layman where to find the overlay on sourceforge and put it in the filesystem with name "ls-wiki".

<?xml version="1.0" ?>
<overlays>
  <overlay contact="http://linkstationwiki.sourceforge.net" name="ls-wiki"
  src="http://linkstationwiki.svn.sourceforge.net/svnroot/linkstationwiki/gentoo_ppc/overlay" status="official" type="svn">
    <description>
      The Linkstationwiki ppc overlay provides ebuilds adapted for running Gentoo on Buffalo PPC Linkstations and Kuroboxes.
    </description>
  </overlay>
</overlays>

Check the setup now with:

# layman -L | grep ls-wiki
* ls-wiki                   [Subversion] (source: http://linkstationwiki.svn...)

layman -a ls-wiki

Add the ls-wiki overlay with:

# layman -a ls-wiki

/etc/make.conf

Need to add a line to make.conf:

# echo "source /usr/local/portage/layman/make.conf" >> /etc/make.conf
# vi /etc/make.conf
(remove the old line with PORTDIR_OVERLAY="/usr/local/portage/kuro-2007-11-04")

The contents of the file is now:

# Kurobox make.conf

CFLAGS="-O2 -mcpu=603e -fno-strict-aliasing -pipe -fsigned-char"
CXXFLAGS="${CFLAGS}"

USE="-X -gtk -gtk2 -gnome -qt -kde -opengl -motif -xmms -arts -alsa -oss -ipv6 samba cups usb"

source /usr/local/portage/layman/make.conf

switch to the profile in the ls-wiki overlay

# cd /etc
# rm make.profile
# ln -s ../usr/local/portage/layman/ls-wiki/profiles/kurobox-uboot/2007.0/ make.profile

emerge --info

Check that everything is ok with:

# emerge --info

emerge --sync, emerge --update

# emerge --sync
# emerge --update --deep world

remove old overlays now that layman is working

# cd /usr/local/portage
# rm -rf kuro-*

Create tarfile

We're going to create the tarfile without the portage tree since it goes stale quickly. The instructions will say to download the latest portage snapshot.

# exit # (leave the chroot environment)
# umount /datafiles/chroots/gentoo-20071104-uboot/proc
# cd /datafiles/chroots/gentoo-20071104-uboot
# tar cjf ../gentoo-20071104-uboot.tar.bz2 \
   --exclude "./usr/portage/*" --exclude "./proc/*" --exclude "./tmp/*" --exclude "./root/*" .