Apr 11
Installing Debian GNU/Linux on a Alix board
The next step after having acquired my Alix 2C3 was to install Debian. Here’s the installation procedure in case you want to setup your own one:
Partition your CF card
Get yourself a CF card reader, plug in the CF card and determine what the device special file for the CF card is, for me it was /dev/sdb and create a partition for Linux. I’ve put Linux into the second partition, /dev/sdb2, so the rest of the installation procedure assumes this.
$ fdisk /dev/sdb
fdisk> p
... remove factory-default partition
fdisk> d 1
... create partition for Linux
fdisk> c 2
... don't forget to mark it as bootable
fdkis> a 2
fdisk> w
Install MBR on CF card.
$ install-mbr /dev/sdb
Create filesystem
$ mkfs.ext2 /dev/sdb2
Bootstrap debian
I’ve used debootstrap to set up a debian base system on the CF card:
$ apt-get install debootstrap
$ mount /dev/sdb2 /mnt
$ debootstrap --arch i386 sid /mnt http://ftp.sk.debian.org/debian
To install additional packages, just chroot into the fresh Debian system and run apt-get.
$ mount /dev/sdb2 /mnt
$ chroot /mnt /bin/bash
chroot> apt-get install sl
For the base system to work, it needs to be configured a bit. Most notably, it has to be told to run a console on the serial line. Edit /etc/inittab on the CF card. Remove (or comment-out) all lines of the form:
... /sbin/getty ... ttyN
Those lines tell init to spawn consoles and display a login prompt on virtual terminals 1 - 6. Add the following line instead:
T0:23:respawn:/sbin/getty -L ttyS0 38400
Install kernel
You could just chroot into the Linux partirion and run apt-get install linux-image-2.6-486 but this procedure tries to install a lot of unnecessary dependencies. Another option is to download the Debian kernel package on the development machine, unpack it, an setup it manually on the CF card:
# Download kernel package on devel machine
$ apt-get -d install linux-image-2.6.24-1-486
$ mkdir /tmp/kern
$ dpkg --extract \
/var/cache/apt/archives/linux-image-2.6.24-1-486_*.deb \
/tmp/kern
# Mount CF partion into /mnt
$ cp /tmp/kern/boot/* /mnt/boot
$ cp -R /tmp/kern/lib/modules/2.6.24-1-486 /mnt/lib/modules
$ chroot /mnt /bin/bash
chroot> depmod -a 2.6.24-1-486
chroot> exit
Next, you need an initramfs image for the installed kernel. You can create one using mkinitramfs:
$ cp -R /etc/initramfs-tools /tmp
# Now, you can tune the settings in /tmp/initramfs-tools
# Mount Linux partition on CF card into /mnt
$ ln -s /mnt/lib/modules/2.6.24-1-486 /lib/modules/2.6.24-1-486
$ mkinitramfs -d /tmp/initramfs-tools -o /mnt/boot/initramfs-2.6.24-1-486 \
2.6.24-1-486
$ rm /lib/modules/2.6.24-1-486
Install grub
To make the CF card bootable, grub is needed. Start by installing the grub package on the fresh Linux system:
# Mount linux partioon on CF card int /mnt
$ chroot /mnt /bin/bash
chroot> apt-get install grub
chroot> mkdir /boot/grub
chroot> cp /usr/lib/grub/i386-pc/* /boot/grub
chroot> exit
Then, setup grub on the CF card. Assume your CF card corresponds to device /dev/sdb. Create a file, /tmp/device-map with the following content, that tells grub that (hd0) should be mapped to /dev/sdb:
(hd0) /dev/sdb
Then, start grub from the command line and continue the installation:
$ grub --device-map /tmp/device-map
grub> root (hd0,1)
grub> setup (hd0,1)
And finally you have to create a boot menu for grub on the CF card, /boot/grub/menu.lst:
serial --speed=38400
terminal serial
timeout 5
default 0
title 2.6.24-1-486
root (hd0,1)
kernel /boot/vmlinuz-2.6.24-1-486 root=/dev/hda2 console=ttyS0,38400n8
initrd /boot/initramfs-2.6.24-1-486
Edit: Someone has pointed out, that the above procedure of installing grub did not work for him. Instead, he did the following on his development machine:
$ echo '(hd0) /dev/sdb' > /mnt/boot/grub/device.map
$ grub-install --root-directory=/mnt /dev/sdb
Boot the board
At this point you should be able to boot the Alix board from the CF card. Network and USB worked for me out of the box.
Edit: An user reported the following problem during booting:
resume: libgcrypt version: 1.2.3
resume: Could not stat the resume device file.
Please type in the file name to try again
or press ENTER to boot
The fix was to remove the initramfs-tools config file /tmp/initramfs-tools/conf.d/resume and to add the option noresume to the kernel commandline.
Goodie: install LED driver
Debian includes a source package for the led driver, alix-leds-source. You can build the driver on your development machine:
# Need headers for kernel on alix
devel> apt-get install linux-headers-2.6.24-1-486
# Get driver source
devel> module-assistant get leds-alix-source
# Build package for target kernel
devel> module-assistant -l 2.6.24-1-486 leds-alix
Voila! There is now a deb leds-alix-modules… in /usr/src. Just install it on the CF card. And don’t forget to put leds-alix into your /etc/modules on the alix board.
4 Comments so far
[…] linux thread on alix LED control on gmaneInstalling Debian GNU/LINUX on a Alix board by Peter […]
[…] voyage linux, peter molnar, gmane.org Tags: alix Category: Drivers, Hardware, Installation Procedures, Miscancellous, System […]
Браво, мне кажется, это великолепная фраза…
Инженер-эколог Partition your CF card
Get yourself a CF card reader, plug in the CF card and determine what the device special file for the CF card is, for me it […….
[…] little overhead. I found these guides to be helpful, even if not completely up to date or correct: Guide 1, Guide 2. But careful! Don’t mount the ALIX board in its enclosure until you’re sure […]