Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Guide]Installing Gentoo onto a Soekris 4826
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
bugg_tb
Apprentice
Apprentice


Joined: 19 Nov 2004
Posts: 282
Location: Leeds, UK

PostPosted: Sun Oct 29, 2006 9:30 pm    Post subject: [Guide]Installing Gentoo onto a Soekris 4826 Reply with quote

Installing a Gentoo Installation onto a Soekris Net4826

I have written this tutorial because of a lack of complete information for supporting linux on a Soekris 4826 board and the bits I can find are all over the place. So in an effort to combine it all together I have created this monster. There are plenty of tutorials explaining how to install your operating system of choice onto a compact flash card then booting off that, but what if your computer has 64mb of flash built into it, but no CF reader or ide adaptor. How do you copy your operating system from your workstation to one of these machine easily??

Now I don't proclaim to be an expert and I'm sure there's plenty I've missed which can be added at a later date, but for a bit of a guide with most of the major steps intact here goes.

P.S Cheers to all the other guides, you've really helped me.
http://gentoo-wiki.com/TinyGentoo
http://www.bulah.com/embeddedgentoo.html

Software Configuration

There are many ways to setup an embedded gentoo system, I had looked at tinygentoo, but in the end I decided to sort of follow the instructions for the Gentoo Embedded X86 Guide. So here goes...

You can unpack the system anywhere but for ease of use I followed the guides example and put it in /opt.

Preparing the installation directory

So to prepare the installation directory,
Code:
 su
[passwd]
cd /opt


You should now be the root user and have moved to the /opt directory.

Next we will create the directories required to put the gentoo distro in.

Code:
mkdir -p /opt/i586-gentoo-uclibc-linux/usr/portage


Download and unpack Stage 1 tarball

Next we get a copy of the Stage 1 embedded tarball. You can use stage 2 or 3 but as I wanted to optimise it for a production box I decided to get stage 1.
So next you perform,
Code:
wget ftp://mirrors.blueyonder.co.uk/mirrors/gentoo/experimental/x86/embedded/stages/stage1-x86-uclibc-2006.1.tar.bz2


This will download a copy of the tar ball to the directory you are currently in(probably /opt).

Next we need to unpack the stage to the working directory so..

Code:
tar -xvjpf stage1-x86-uclibc-2006.1.tar.bz2 -C /opt/i586-gentoo-uclibc-linux/


You should see the tar ball unzipping in your terminal and after a short while your system should be unpacked and ready to start working on.

Mount proc and portage inside installation directories

To make life easier there are a couple of directories that need mounting inside your installation directory. These are /proc and portage.

So to mount these type,

Code:
mount --bind /proc /opt/i586-gentoo-uclibc-linux/proc/
mount --bind /usr/portage /opt/i586-gentoo-uclibc-linux/usr/portage
mount --bind /dev /opt/i586-gentoo-uclibc-linux/dev


Setting up the dns information

Next we copy the dns information from your workstation to the installation directory, so type,

Code:
cp /etc/resolv.conf /opt/i586-gentoo-uclibc-linux/etc/resolv.conf



Chroot into the new system

Now to start working on the system we need to chroot into its environment so..

Code:
chroot /opt/i586-gentoo-uclibc-linux /bin/bash --login


You will now be inside your new gentoo installation environment.
Next you need to,
Code:
env-update
source /etc/profile


This will load the new environment and put the variables into its memory.

Editing Make.conf and defining the profile


Next we need to edit the variables in /etc/make.conf

So in your chroot'ed environment type,

Code:
 nano /etc/make.conf


And edit the tags according to your preferences.

Mine looked like,
Quote:
CFLAGS="-march=i586 -Os -pipe -fomit-frame-pointer"
CHOST="i386-gentoo-linux-uclibc"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-z,relro"
USE="bitmap-fonts minimal truetype-fonts"
FEATURES="buildpkg"
UCLIBC_CPU="586"


But this is dependant on what you want, so check out the information in the Gentoo Installation Manual.

Next we have to set it to use the 2.6 kernel, it should be configured to do this but no harm in double checking.

Code:
cd /etc/
unlink make.profile
ln -s ../usr/portage/profiles/uclibc/x86/2005.1 make.profile


Setting up the bootstrap and installing the base system

Now we have to configure the bootstrap script. Luckily there is a handy feature that makes life an awful lot easier,

Code:
cd /usr/portage/scripts
./bootstrap.sh -p -v
./bootstrap.sh


If you have problems when it script is executed saying it cannot locate or run gcc try,
Code:
gcc-config 1
source /etc/profile
./bootstrap.sh


Sit back and wait a while as it compiles all the stuff.

Next we install the system basics,

Code:
emerge -e system

Again if you have problems with it emerging and python then try,

Code:
emerge python
emerge -e system


Next up we create the directory where we want to setup our final system..

Code:
mkdir /embedded_rootfs


Next you need to emerge the baselayout into that directory,

Quote:
cd /usr/portage/sys-apps/baselayout-lite/
ROOT=/embedded_rootfs emerge baselayout-lite-1.0_pre1.ebuild


Next emerge uclibc into the embedded_root directory

Code:
ROOT=/embedded_rootfs emerge -K uclibc


Then we emerge busybox:

Code:
emerge busybox
ROOT=/embedded_rootfs emerge -K busybox


And create the required symlinks:

Code:
mkdir /embedded_rootfs/proc
mount -o bind /proc/ /embedded_rootfs/proc/
chroot /embedded_rootfs /bin/busybox --install -s
umount /embedded_rootfs/proc


Configuring the timezone

Then set your timezone:
Code:
nano -w /embedded_rootfs/etc/TZ


Installing a bootloader

We need a bootloader for when its finally copied across so I emerged grub, you could use lilo if you prefer:
Code:
emerge grub
ROOT=/embedded_rootfs emerge -K grub
cp -R /boot/grub /embedded_rootfs/boot/

Then edit grub.conf
Code:
nano /embedded_rootfs/boot/grub/grub.conf


Mine looks like:
Quote:
default 0
timeout 5
serial --unit=0 --speed=19200 --word=8 --parity=no --stop=1
terminal --timeout=15 serial

title=Linux
root (hd0,0)
kernel /boot/vmlinuz root=/dev/hda1 console=ttyS0


The serial line tells it how to configure the serial port and console=ttyS0 outputs the boot sequence to the serial port, if you have more than one you may need to adjust those lines.

Setting up root user and fstab

Now we set up a root user password:

Code:
chroot /embedded_rootfs /bin/sh
passwd
exit
rm /embedded_rootfs/etc/passwd-


And then its time for fstab:
Code:
nano -w /embedded_rootfs/etc/fstab


An example fstab:
Quote:
/dev/hda1 ext2 defaults 0 0
none/proc proc defaults 0 0
none/sys sysfs defaults 0 0
none/dev/shm tmpfs defaults 0 0


If your installing onto Compact Flash make sure you dont use a journalling filesystem else your flash wont last very long.


Cleaning up

Next we clean up the stuff we installed with..

Code:
rm -R /embedded_rootfs/var/db/pkg/*
rm -R /embedded_rootfs/var/lib/portage/


And then build whatever you want to put on your system..
Code:
emerge foo*
ROOT=/embedded_rootfs emerge -K foo*


Installing a kernel

Lastly we install a kernel

So..
Code:
emerge vanilla-sources
cd /usr/src/
cd linux
make menuconfig


As advised on another howto, I compiled everything directly into the kernel and left nothing as a module, this isn't a written rule but it does make life easier.[/quote]

Once the kernel is configured run..

Code:
make
make INSTALL_MOD_PATH=/embedded_rootfs modules_install
cp /usr/src/linux/arch/i386/boot/bzImage /embedded_rootfs/boot/vmlinuz


My .config would be too long to post for this already huge howto but the basics include, compile in
    Configure standard kernel features

    Optimize for size

    Processor family=GeodeGX1

    PCI Support - NatSemi SCx200 Support

    ATA/ATAPI/MFM/RLL Support - National SCx200 chipset support(if you dont compile in this you aint going anywhere)

    Nat Semi DP8381x PCI Ethernet

    USB OHCI support if you want to use the usb header on JP6


There is obviously more for things like the watchdog and GPIO but these are some of the more important ones.


Preparing the system for deployment

There are many different way to get your system onto the target computer I used tar and then copied it to my webserver and downloaded it, easier than nfs I thought, so thats what I'll show you,

Code:
cd /embedded_rootfs
tar cvf embeddedlinux.tar *
cp embeddedlinux.tar /var/www/localhost/htdocs (or the path to your webserver's files)



Server Setup

Now that our base system is ready it is time to configure your server to boot the Soekris over your local network.

NOTE This is all done outside your chroot environment!!


Firstly you need to adjust your dhcp settings.
I use dnsmasq as I find it easier for a basic network setup all I had to do was add ..

Code:
dhcp-boot=/pxelinux.0,SERVERNAME,SERVERIP


to the bottom of my /etc/dnsmasq.conf file
If you use dhcp then there are plenty of places on the net to find out how to adjust you dhcp configuration, sorry I've never used it so I wont post something that may be completely wrong.

Next we emerge a tftp server..

Code:
emerge tftp.hpa


Once it is installed I adjusted my /etc/conf.d/in.tftpd to read:
Quote:

# /etc/init.d/in.tftpd

# Path to server files from
INTFTPD_PATH="/tftpboot"
INTFTPD_USER="nobody"

# For more options, see tftpd(8)
INTFTPD_OPTS="-u ${INTFTPD_USER} -l -vvvvvv -p -c -s ${INTFTPD_PATH}"


Next create a directory called tftpboot:
Code:
mkdir /tftpboot


Then start tftp

Code:
/etc/init.d/in.tftpd start


Now there are plenty of different ways to get your soekris board to boot off the network but to make life easy I used the [url http://leaf.sourceforge.net]LEAF[/url] distribution.

On their website find the pxeinstall.tgz file, I wont link to it as its in the cvs and may change, so find it yourselves :o

Then unpack it into /tftpboot:
Code:
tar xvfz pxelinux.tgz -C /tftpboot


Next copy the net4501 file to default
Code:
cp /tftpboot/pxelinux.cfg/net4501 /tftpboot/pxelinux.cfg/default


Next we have to configure the default file so:
Code:
nano /tftpboot/pxelinux.cfg/default


All you should need to change is the ip address to the ip address of your server. You may have different baud rate settings so adjust them as needed.

Next we need to be able to see the console output of the soekris, you can use minicom but I find it a bit over the top so I use cu
Code:
emerge taylor-uucp


Then plug your soekris into your serial port and type

Code:
cu -l /dev/ttyS0 (or whatever your serial port is)


Plug it into the network and switch on the soekris and watch the output, it should show you a bios prompt, if you just see a load of silly characters then your baud rate is set wrong, adjust the speed with cu with the -s switch.

Copying The System To The Target

When its booting hit Ctl-P and it will drop you into a command line, and type
Code:
boot f0


This will tell the soekris to boot off the network adaptor

It will then try and load pxelinux, if it says file not found then there is something wrong with your setup, I find Wireshark and excellent application to solve problems like these.

On my machine it has a bit of an issue with PXELinux and takes 10 minutes to load it, but once loaded LEAF boots in no time.(If anyone has a solution to this please let me know)

Once LEAF has booted and you had a login, just type 'root' to login.

We now need to prepare the harddrive so type:

Code:
mkfs.ext2 /dev/hda1


This will then create the filesystem on your embedded flash disk.
The mount it with:
Code:
mkdir /mnt/hdd
mount /dev/hda1 /mnt/hdd


Next we have to get our embedded system off the server so:

Code:
wget SERVERIP/embeddedlinux.tar


The untar it onto our flash disk:
Code:
tar xvf embeddedgentoo.tar -C /mnt/hdd


Next we have to create a /etc/mtab file so we can play with mounting things, so,
Code:
mount -t proc proc /mnt/hdd/proc
chroot /mnt/hdd /bin/ash
ln -s /proc/mounts /etc/mtab


Grub
To install the bootloader still inside the chroot environment type:
Code:
grub

then it should drop you into the grub shell.
Within this shell type:
Code:
root (hd0,0)
setup (hd0)
quit

That should install grub for you, although check for error messages.

Reboot
That should be about it, just type
Code:
exit

to exit the chroot environment then
Code:
cd /
umount /mnt/hdd/proc
umount /mnt/hdd
reboot


And that should be that.


I know this has been a long tutorial, but I have been so frustrated not finding all the information in the same place that I decided to create it, there will be errors and typos so if anyone spots any please let me know.

I hope this helps people with embedded diskless machines.

Tom

Oh and if anyone finds this remotely useful, please can you let me know and i'll keep on working on it
Back to top
View user's profile Send private message
exklusve
Apprentice
Apprentice


Joined: 23 Aug 2002
Posts: 270
Location: currently ~/

PostPosted: Wed Mar 19, 2008 3:58 pm    Post subject: Reply with quote

I just got two of the net4826's and installed OpenBSD on one.

I'd love to get Gentoo going on the other.

How much space did your install take?

My 4826 has 256MB of flash memory.

Thanks in advance and thanks for the great guide!! :D
_________________
eXklusve

You do know that no one gives a shit about your system spec's right?
Back to top
View user's profile Send private message
bugg_tb
Apprentice
Apprentice


Joined: 19 Nov 2004
Posts: 282
Location: Leeds, UK

PostPosted: Wed Mar 19, 2008 5:17 pm    Post subject: Reply with quote

nice to see you've found it useful as you can see I wrote it ages ago, but as far as I know, my onboard flash was either 64mb or 128mb so you should do just fine.

Tom
_________________
Remember, even at a Mensa convention someone is the dumbest person in the room!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum