I am interested in building embedded computers. The boards I use are the Alix boards over at mini-box.com. That site is a good resource for researching and building very small form factor computers. Previously, I had built one of these computers as a home router running embcop, an embedded modification of the ipcop distribution. Instead of using the pre-build image, I wanted to roll my own using my favorite distribution: Debian.
I started the same way any good project does these days by googling for debian alix2c3 or something to that effect. I was introduced to this website which pretty much outlines the steps required to get it working. I had to make some small modifications to this process, but overall I followed this howto and was successful. Many thanks to Mates.
I keep notes on all of my projects so I won't forget the tricks I learned. My production box is a Ubuntu 8.04 desktop machine with only one hard drive. The main hard drive on the machine is /dev/sda and for the project I used a 1 GB compact flash card (~$10) which is henceforth referred to as /dev/sdb. The concept of the project is plain:
- Format
- Base install
- Kernel install
- Boot loader install
- ???
- Profit! (Profit valid for small values of profit)
My compact flash card showed up as /dev/sdb in my Ubuntu system, which I used to accomplish this project. Check your own device settings and be sure about which disk you are addressing, otherwise you may cause damage to your system disk.
First, set partitions on the CF card.
My CF configuration:
$ sudo fdisk -l
Disk /dev/sdb: 1024 MB, 1024450560 bytes
32 heads, 62 sectors/track, 1008 cylinders
Units = cylinders of 1984 * 512 = 1015808 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 24 23777 83 Linux
/dev/sdb2 25 1008 976128 83 Linux
Accomplish this how you wish, using the fdisk utility.
## Format the partitions to ext2.
$ mkfs.ext2 /dev/sdb1## Install the necessary utilities
$ mkfs.ext2 /dev/sdb2
$ aptitude install debootstrap binutils## Mount up and install
$ mount /dev/sdb2 /mnt## If you haven't used debootstrap before (I hadn't) you are in for a treat.
$ mkdir /mnt/boot
$ mount /dev/sdb1 /mnt/boot
## This little program is magic. This step will take some time depending on
## the interwebs.
$ debootstrap --verbose --arch i386 etch /mnt http://ftp.us.debian.org/debian## chroot into the new system and install a kernel
$ chroot /mnt /bin/bash## Configure the menu.lst file in /boot/grub. What you use here for console
# aptitude update
# aptitude install linux-image-2.6-486 openssh-server grub
# mkdir /boot/grub
# cp /usr/lib/grub/i386-pc/* /boot/grub
## settings may be dependent on the terminal software used.
serial --speed=38400## Configure /etc/inittab to use the serial line.
terminal serial
timeout 1
default 0
title Debian router
root (hd0,0)
kernel /vmlinuz-2.6.18-6-486 root=/dev/hda2 console=ttyS0,38400n8
initrd /initrd.img-2.6.18-6-486
## Comment out any lines that look like this:
*:*:respawn:/sbin/getty 38400 tty*
## There should be six or so of them.
## Uncomment this line and modify to suit your setup.
T0:23:respawn:/sbin/getty -L ttyS0 38400
## Edit /etc/fstab. I used hda and not sda for my CF card.
## Exit the chrooted environment and install grub to the CF card.
proc /proc proc defaults 0 0
/dev/hda2 / ext2 noatime,errors=remount-ro 0 1
/dev/hda1 /boot ext2 defaults 0 1
# exit## Unmount everything and install the card into your Alix board.
$ aptitude install grub
$ touch /mnt/boot/grub/device.map
$ echo '(hd0) /dev/sdb' > /mnt/boot/grub/device.map
$ grub-install --root-directory=/mnt /dev/sdb
$ umount /mnt/boot## When your board is up and working, modify /etc/network/interfaces
$ umount /mnt
## Here is an example:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.10.1
network 192.168.10.0
netmask 255.255.255.0