The Gentoo team have been working on some basic stage 3 tarballs for Gentoo and have gotten them working pretty well in my opinion. I'm currently running a kernel I generated with OpenEmbedded and I'm using no initramfs or initrd. I'm simply booting the kernel and pointing to my SD card where the root is.

For this tutorial, I've followed my instructions here to get my Micro2440 to boot from the SD card.

Obtaining The Stage3 Tarball

Have a look here:

http://distfiles.gentoo.org/releases/arm/autobuilds/current-stage3/armv4tl-softfloat-linux-gnueabi/

This is where the ARMV4TL stage3 tarballs are located. Download the latest one and save it to your HD.

Preparing the SD Card

If you followed my directions above for booting from SD, your SD card should be in 3 partitions. Your rootfs partition should be /dev/mmcblk0p3 and should be empty.

Create an ext3 filesystem on the 3rd partition like so:

sparky: /> mkfs.ext3 /dev/mmcblk0p3

I would recommend an ext2 filesystem over ext3 for this, but my kernel currently doesn't support ext2. If you compile that in to yours, please use that instead. It's much less harsh on the NAND on your SD Card.

Now mount your SD card's 3rd partition and extract the stage3 tarball to it and umount it.

sparky: /> mount /dev/mmcblk0p3 /mnt
sparky: /> tar xzvfop /path/to/downloaded/stage3.tar.gz -C /mnt
...
...
sparky: /> umount /dev/mmcblk0p3

Be sure to use the "p" command line option with tar to preserve permissions when extracting the tarball.

Now your SD card is setup. Again this assumes you followed my directions from the SD boot HOWTO and have a kernel on /dev/mmcblk0p2 ... if not, make sure you put your uImage there.

Configuring U-Boot bootargs

You'll need to temporarily modify your bootargs. So on your mini2440 or micro2440 at the u-boot prompt do this:

MINI2440# setenv bootargs  console=ttySAC0,115200 mini2440=1tb init=/bin/bash \
rootfstype=ext3 root=/dev/mmcblk0p3 rw rootwait
MINI2440# saveenv

Now boot your device with the SD card in the slot and assuming it works as it should, you should see a bash prompt on your display or console. PLease make sure you've added a rootwait at the end otherwise the kernel might boot and try to find the SD card before the device is visible to the kernel.

Changing The Root Password

You needed to pass the init option to the kernel because the stage3 tarball password is unknown so you need to change it. Now that you're at the prompt you can issue the command to change the passwword.

bash (unknown)# passwd root

Now you can remove the init option from the bootargs in U-Boot.

Configuring Your Network

The gentoo stage3 tarball, for whatever reason, doesn't include a dhcp client so you'll need to configure your network manually.

localhost.unknown.domain: ~/> export IP_ADDR=192.168.1.50
localhost.unknown.domain: ~/> export BROADCAST=192.168.1.255
localhost.unknown.domain: ~/> export NETMASK=255.255.255.0
localhost.unknown.domain: ~/> export GATEWAY=192.168.1.1
localhost.unknown.domain: ~/> export DNS1=192.168.1.1
localhost.unknown.domain: ~/> export DNS2=192.168.1.2
localhost.unknown.domain: ~/> ifconfig eth0 $(IP_ADDR) broadcast $(BROADCAST) netmask $(NETMASK) up
localhost.unknown.domain: ~/> route add default gw $(GATEWAY)
localhost.unknown.domain: ~/> echo nameserver $(DNS1) > /etc/resolv.conf
localhost.unknown.domain: ~/> echo nameserver $(DNS2) >> /etc/resolv.conf

The above sets the IP, broadcast IP, netmask, Gateway and DNS servers as variables, and then runs ifconfig to setup the interface and route to add the route to the gateway. We then create a resolv.conf so you access the nameserver. Change the above to match whatever your network configuration is.

Syncing Portage

Now that your network is setup and you can access the net (try pinging google). Now you can sync up portage. This will take probably an hour or more.

localhost.unknown.domain: ~/> emerge --sync
...
...

By the time your 4 year old has graduated college and you're old and gray, this should be done.

Recommended First Emerges

I recommend emerging Dropbear SSH server and dhcpcd before doing anything else. When you emerge dropbear, be sure to run:

rc-update add dropbear default

This will ensure that dropbear starts during your next boot. Dhcpcd doesnt need any special configuration unless you plan to use wireless or some other stuff. By default, if eth0 isn't configured, it'll try to run whatever dhcp client is available.

++Final Thoughts++

This is a proof of concept situation. Running Gentoo on this very very slow device isn't seriously practical. Compiling anything at all, no matter how small, will takes forever. My advice would be that if you intend to do this, that you read about distcc and use another machine as the compiling machine over the network. But you'll need to read up on that yourself. That goes way way beyond the scope of this tutorial.

I hope this tutorial has helped you in some way. Please be sure to let me know of any successes or failures you might have and also if you have any suggestions for improving this. I'm always open to new ideas.

//Bill Sargent

Questions? Comments? Please visit my forum here and ask.