Neben den anderen, geschäftlichen Projekten poste ich hier nun auch einfach mal ein privates Just-For-Fun Projekt:
Vor kurzem schaffte ich mir eines dieser ALIX Boards an (kleiner Einplatinencomputer). Nachdem ich ein Image von IPFire (empfehlenswertes Projekt - aber das ist ein anderes Thema) erfolgreich installiert hatte reizte es mich, ein "Linux von der Stange" selbst zu installieren.
Da es hierzu im Internet schon einige Tips und Anleitungen gab entschloss ich mich für Debian.
Die hier von mir veröffentlichte Anleitung entstand zu Beginn nur als Notiz für mich. Da ich wärend des Vorhabens teilweise sehr lange damit beschäftigt war, kleinere Fallstricke zu lösen dachte ich mir, dass die Notizen auch für andere nützlich sein könnten. Darum schrieb ich den Text dann auch in Englisch weiter.
Wenn jemand Anregungen/Ideen/Vorschläge/Kritik anbringen möchte freue ich mich über eine Mail an die Adresse unter "Kontakt". / If somebody wants to share his/her thoughts on that topic with me he/she can find my mailadress through the link here.
Preface
After getting my hands on one of these ALIX boards first I installed IpFire on that board by just downloading an image and copying it to the 4GB Compact Flash which was pretty much all there was to do.
After that I decided to try to install a more common linux system on that box – partially for the sake of doing it – and partially because I wanted to have the possibility to configure everything like I wanted it to be.
There are some articles already available in the internet on that topic and they helped me a lot in succeeding with the installation but I had to cross – check several articles and it still did not work just out of the box. Obviously that was also the case because some linux tools had changed since the articles had been written.
This article tries to outline the whole process of installing a Debian system with a customized linux kernel on an ALIX board.
My sources were:
http://eko.one.pl/index.php?page=alix-debian
(I can’t speak Russian but the list of kernel configuration items on that site was very helpful)
http://wiki.ubuntuusers.de/Baustelle/Ubuntu_9.10_Installation_auf_Alix
(this one is in german and focuses on Ubuntu – but I got some general understanding from that source)
http://peter.molnar.cc/2008/04/11/installing-debian-gnulinux-on-a-alix-board
(this covered most of the steps I had to do – however I was not able to get the system up and running with the out of the box default Debian kernel)
Prerequisites
a) A card reader for Compact Flash cards
I got myself one of these USB multi card readers which turned out to be very useful.
b) A Debian VMWare inside VMWare Player which will serve as your development machine. After setting it up and configuring it you want to make a backup copy of the whole thing ;-)
You also want to make sure to have enough free disk space inside the VMWare (10GB will be ok) – because you want to be able to make a backup copy of the whole compact flash card when it is ready. Oh – and your VMware – Debian needs to have access to the internet.
Configuring the development machine and CF card
a) On the development machine you need some additional packages. Just run:
apt-get install debootstrap
apt-get install mbr
which installs the 2 packages on your development machine.
b) Next you want to have a mount point (empty directory) in which you will set up the whole new installation. I created an empty dir /alix (as root).
mkdir /alix
c) The next thing is to attach the card reader to your physical machine, put in the CF card and tell VMWare Player to use that device inside the VM (just click on devices in the menu bar).
d) Now you need to check what under what device name your CF card shows up on your development machine (the VM). Chances are good that it is /dev/sdb but you want to be sure – so check /var/log/messages and see if the system recognized the card:
tail /var/log/messages
should show something like:
e) This disk can now be partitioned and formatted with a suitable file system:
You can do the partitioning using fdisk. I created one primary partition that uses the whole card (4GB). That partition in my case is /dev/sdb1 so whenever I refer to it in the future make sure to put in whatever partition you created! Don’t forget to mark the partition as bootable.
f) The partition needs to have a master boot record so run:
install-mbr /dev/sdb1
g) Now you can create a file system on the partition. I choose to create a ext2 partition which is recommended because it has no journal (like ext3) leading to fewer I/O s on the card resulting in the card living longer. I guess as always there are people who believe in the opposite but it sounded reasonable to me… Creating an ext2 caused some problems later on but that’s a different story and I’ll get to that later.
Run:
mkfs –t ext2 /dev/sdb1
tune2fs –c 0 –i 0 /dev/sdb1
The tune2fs command will result in the disk not being force checked after n mounts or m days. I had some trouble with my first IPFire installation where the system hung during boot in a forced check waiting for a key to be pressed so I decided do not have the force check enabled – but you can leave it enabled if you want.
h) Now you want to create 2 helper scripts that take care of mounting and unmounting that disk and some other file systems that are needed during the configuration of the target Debian system. Put the scripts in roots home on the development machine or wherever you want them to be. Again /dev/sdb1 and /alix might need to be adjusted to point to your files.
mount-alix.sh
#!/bin/bash
mount /dev/sdb1 /alix
mount –o bind /dev /alix/dev
mount –o bind /sys /alix/sys
mount –o bind /proc /alix/proc
and
umount-alix.sh
#!/bin/bash
umount /alix/dev
umount /alix/proc
umount /alix/sys
umount /alix
Make sure to have execute permissions on these scripts:
chmod u+x *.sh
i) That’s it for preparing your development box and CF card. Maybe now is a good time to shut down the development box and make a backup copy of it?
Preparing the environment on the CF card
a) Ok – first you want to mount the file system on the card to your /alix directory. Just run the formerly created script in whatever directory you created it – it will tell you that there are not mount points for everything except /alix itself which is OK. We are going to create the other mount points soon :
./mount-alix.sh
b) Now let debootstrap install all the basic directories and files (including executables like commands and tools) in the /alix directory – this step takes a couple of minutes:
debootstrap --arch i386 sid /alix http://ftp.de.debian.org/debian
c) This part is very important: We are now going to chroot into the new environment. That means that after chroot all commands that affect the system no longer affect your development system but the debian environment on the CS card mounted to /alix. If you (after chroot) enter cd / you are in / of your alix system which in fact is /alix on your development box. Make sure to always be sure where you execute what or you will screw up your development installation in no time – believe me I did it – and that’s why we created the backup copy minutes ago.
You can exit the chroot environment and get back to your development system by typing:
exit
It is like the command su – in case you are familiar with it. Ok? Got it? Really got it? Then run:
chroot /alix /bin/bash
d) Ok now we are in the new filesystem on the card. Look around using ls and step into a couple of directories to see what we already have in place.
We need some software in here:
apt-get install grub-legacy
this is the “old” version of grub – we will get to that later.
apt-get install ncurses-dev
this is needed for the kernel config tool (later…)
Now we need to install the kernel sources for the kernel we are going to compile on the file system on the card (that’s why we chroot’ed) – so run (this probably takes some minutes):
apt-get install linux-source-2.6.32
if you want to install another version just go ahead. If you want to see what is available just run:
aptitude search linux-source
and flip up through the results (
e) When that is done you need to configure the kernel before you compile it. That means you simply need to choose what features you want your new kernel to have. For the first installation I left most of the features like they were configured, got rid of some that were obviously not needed (like Macintosh support) and added the ones from that russian site that are needed in order for the board to function properly.
What I did not recognize was that ext2 support is not included per default resulting in my kernel not being able to mount the file system on the CF card. Bad thing. Took me a whole day to figure out…
In order to configure the kernel go to the directory where the kernel source have been downloaded:
cd /usr/src
unzip the source file that is located here as a result of the apt-get executed earlier:
tar –xvjf linux-source-2.6.32.tar.bz2
-x tells to extract, -v is verbose (so you get more infos printed out), -j is needed for the bz2 archives (if you have a .gz archive you need –z instead), -f is followed by the zipped file.
The whole source then gets extracted to where you currently are (/usr/src).
f) After that step into the newly created directory:
cd linux-source-2.6.32
In here run the command:
make menuconfig
This command start a ascii graphics kernel configuration tool . It shows a list with entries. Some have subentries and some of the entries in there have more subentries ;-)
You can search by pressing / and entering a keyword.
You can either have a functionality compiled directly into the kernel (when selected press y) or compile it as a loadable module (press m when selected). The latter leads to smaller kernels but sometimes it is better (or your only option) to compile it into the kernel.
When you are done a file ‘.config’ with all your settings is created in the current directory. You can save that afterwards somewhere else.
Ok – here are the kernel configuration items you want to have (either y or m):
CONFIG_MGEODE_LX=y
CONFIG_GEODE_MFGPT_TIMER=y
CONFIG_HW_RANDOM_GEODE=m
CONFIG_GEODE_WDT=m
CONFIG_CRYPTO_DEV_GEODE=m
CONFIG_SCx200=y
CONFIG_SCx200HR_TIMER=y
CONFIG_SCx200_GPIO=m
CONFIG_SCx200_ACB=m
CONFIG_VIA_RHINE=m
CONFIG_VIA_RHINE_MMIO=y
CONFIG_VIA_RHINE_NAPI=y
CONFIG_USB_OHCI_HCD=m
CONFIG_EXT2_FS <- that’s the one I missed when compiling the first kernel…
I remember one of them was not available at all but that seemed to be ok…
g) Now you can start the compilation. Just run:
make all
Watch the screen for about 1 minute and look for error messages informing you about not existing packages. You might need to install certain tools using apt-get install 'toolname'.
If everything looks fine make yourself a coffee. This can take a couple of minutes.
h) When it is finished and looks ok run:
make install
which copies the ready compiled kernel image to /boot
and then run
make modules_install
which copies the modules to /lib/modules/
i) Ok – now we need to make an initial ram disk. That is an image file which contains all the modules the kernel needs at early boot time (at a time where the file system with all the other modules is not yet ready).
cd /boot
mkinitramfs –o initrd.img-2.6.32 2.6.32
instead of 2.6.32 you want to put your kernel version number. As a reference type ls in /boot and look for a file called vmlinuz-2.6.32 (which is your kernel). You want to have the same number at the end of your initrd filename – and if there is a -4-486 or something like that you want that as well…
If you don’t have the tool run: apt-get install initramfs-tools
j) Next you want to edit /etc/inittab
Scroll down a bit and look for lines like that:
1:2345:respawn:/sbin/getty 38400 tty1
you will probably find 6 of them. Place # in front of the lines to comment them out.
Instead add a line after these lines:
T0:23:respawn:/sbin/getty –L ttyS0 38400
Important: Capital S in ttyS0
k) Also in /etc/fstab we need to add something (the file should be initially empty)
Add:
proc /proc proc defaults 0 0
/dev/sda1 / ext2 noatime,errors=remount-ro 0 0
tmpfs /tmp tmpfs defaults,noatime 0 0
tmpfs /var/tmp tmpfs defaults,noatime 0 0
Note the sda1! This will be the CF card as the ALIX board will see it. It will most likely be sda. If you created a partition number 1 it will be sda1 versus sdb1 on your development machine.
The noatime setting leads to less write operations on the CF card. I put a 0 in the end in the /dev/sda1 line which means: Do not check this partition at boot time. But I am not sure about this one. Maybe it is better to check it.
l) The last step is somewhat tricky: You have to install grub (grand unified boot loader) on the card. There are other bootloaders available so you might want to choose another (smaller) one but grub is standard for most out of the box linux systems.
First you want to create grubs directory:
mkdir /boot/grub
Then you need to copy the basic grub files:
cp /usr/lib/grub/i386-pc/* /boot/grub
That being done use your favorite editor to create grubs start menu file – named ‘menu.lst’:
vi /boot/grub/menu.lst
and make it look like that:
serial --speed=38400
terminal serial
timeout 5
default 0
title 2.6.36-ALIX
root (hd0,0)
kernel /boot/vmlinuz-2.6.32 root=/dev/sda1 console=ttyS0,38400n8
initrd /boot/initrd.img-2.6.32
Needless to say your kernel and initrd names (paths) need to match your actual names. As for the title line: put after ‘title’ whatever you want to have grubs start menu when the machine boots up.
Now edit the file /boot/grub/devices.map. If it is not there create it. Make it look like that (just 1 line):
(hd0) /dev/sdb
This time sdb needs to be whatever the CF card is recognized as on your development machine. If you make a mistake here you might end up with a screwed up grub on your development machine – but hey, we have backup, right?
Before you can run the grub-install you need to make sure /dev /proc and /sys are mounted. So exit the chroot environment:
exit
unmount /alix with your script
./umount-alix.sh
and re mount it:
./mount-alix.sh
and chroot again into the /alix dir:
chroot /alix /bin/bash
OK – now run:
grub-install /dev/sdb
Again that line needs to match what you just put in the devices.map file.
If it succeeds change the /boot/grub/devices.map to point to whatever the ALIX board will recognize the card as. (Most likely sda):
(hd0) /dev/sda
Ok – grub should be set up by now.
m) Another thing we need is a password for root. Just run:
passwd root
and enter a new password twice. Remember we are still in the chroot environment operating on the card – not in your development environment.
n) To lessen the write operations on the card even a bit more you can add the following line to /etc/sysctrl.conf:
vm.dirty_writeback_centisecs = 1500
o) If you want to change the ALIX boards machine name you can run:
echo yourfancynamegoeshere > /etc/hostname
add that as well to /etc/hosts:
127.0.0.1 localhost
127.0.1.1 yourfancynamegoeshere.example.com yourfancynamegoeshere
That's it
Type exit to leave the chroot environment:
exit
then run you unmount script from whatever directory you created it in:
./umount-alix.sh
Put the card out of the card reader, plug it into the ALIX board and give the whole thing a try: Connect the serial cable to your windows machine. Start hyperterminal and power on the board. You should see memory being counted, and grub should appear with a boot menu. If you select your kernel or just wait the system should boot up and present you with a login within less than 1 minute.

