Setting up a Linux home server based on a low cost and low power hardware (Pc Engines Alix) – Part1

Now it’s time to have some fun!

This guide was taken from this great site http://www.stefanolaguardia.eu (thanks Stefano for your excellent work).

First of all I want to prepare the Compact Flash for the installation of a minimal Debian OS.

A 4 GB CF is large enough to fit the OS and many applications, but any “personal” data will be stored in an external USB disk.

Remember that, also for Industrial-use CF, the number of write cycles is limited: if the OS is not configured to minimize write access to the CF, the card will be damaged as sooner as you think.

We need to format the Compact Flash and to prepare a Linux Bootable partition.
We will need a Compact Flash reader (for example USB) and a Debian GNU/Linux machine (or Ubuntu).
I use a Debian Lenny virtual machine (running on Vmware) and the USB Card Reader is “mounted” by Vmware as a Physical HD device.

Now let’s insert the card into the reader and let’s check which special device letter is assigned by Debian to the CF with the command “dmesg

debiandev:~# dmesg | less

[    5.681117] sd 0:0:0:0: [sda] Attached SCSI disk
[    5.681117] sd 0:0:1:0: [sdb] 7880544 512-byte hardware sectors (4035 MB)
[    5.681117] sd 0:0:1:0: [sdb] Write Protect is off
[    5.681117] sd 0:0:1:0: [sdb] Mode Sense: 5d 00 00 00
[    5.681117] sd 0:0:1:0: [sdb] Cache data unavailable
[    5.681117] sd 0:0:1:0: [sdb] Assuming drive cache: write through
[    5.681307] sd 0:0:1:0: [sdb] 7880544 512-byte hardware sectors (4035 MB)
[    5.681487] sd 0:0:1:0: [sdb] Write Protect is off
[    5.681498] sd 0:0:1:0: [sdb] Mode Sense: 5d 00 00 00
[    5.681618] sd 0:0:1:0: [sdb] Cache data unavailable
[    5.681625] sd 0:0:1:0: [sdb] Assuming drive cache: write through
[    5.681805]  sdb: sdb4
[    5.685113]  sdb4: <bsd: sdb5 sdb6bad subpartition – ignored
[    5.685113]  >
[    5.685113] sd 0:0:1:0: [sdb] Attached SCSI disk

In my case the special device assigned to the CF card is /dev/sdb

Now with the command fdisk i can create the partition that I need to install the base system.

debiandev:~# fdisk /dev/sdb
Command (m for help): d 1 —> Delete Any existing partition (with the command p you can see partition table)
Command (m for help): n —> Create a new partition
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-490, default 1): –> Press return for default value
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-490, default 490): –> Press return for default value
Using default value 490
Command (m for help): a —> Toggle the bootable flag for partition 1
Partition number (1-4): 1

Now let’s check if the partition table is as we want and write it!

Command (m for help): p —> Print to screen the partition table

Disk /dev/sdb: 4034 MB, 4034838528 bytes
255 heads, 63 sectors/track, 490 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×90909090

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 490 3935924+ 83 Linux

Command (m for help): w      —> If you see a bootable Linux partition, write changes and quit!
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

If you see a warning like this “WARNING: Re-reading the partition table failed with error 16..”, don’t worry and continue.
Now we will return to shell prompt: we have to install MBR (Master Boot Record) in the CF and create the filesystem for the new partition.
It’s better a non-journaled filesystem like ext2 for preserving the life of the CF.

debiandev:~# install-mbr /dev/sdb
debiandev:~# mkfs.ext2 /dev/sdb1

If you don’t have the mbr package installed, get it with the command “apt-get install mbr”
Now the card is ready for the installation of the operating system. First we will need some tools on the “development machine”.

debiandev:~# apt-get install debootstrap binutils

Now we can mount the partition of the CF and with the chroot environment and debootstrap we can install the OS into the CF.

debiandev:~# mount /dev/sdb1 /mnt/cf
debiandev:~# debootstrap –verbose –arch=i386 lenny /mnt/cf http://ftp.us.debian.org/debian

We will see the download of a lot of packages and the unzip into the CF.
When debootstrap has finished his job we can continue working in chroot in the new Linux environment and installing kernel and modules:

debiandev:/mnt/cf# mount –bind /proc /mnt/cf/proc
debiandev:/mnt/cf# mount –bind /sys /mnt/cf/sys
debiandev:/mnt/cf# chroot /mnt/cf /bin/bash

We are now working in chroot in the CF e we will install a kernel optimized for Alix boards: Voyage GNU/Linux, a distribution derived from Debian and engineered for x86 embedded platforms.
Let’s add the following lines to the file /etc/apt/sources.list:

deb-src http://ftp.it.debian.org/debian lenny main
deb http://www.voyage.hk/dists/experimental ./

Next we have to add the GPG Key of the new repository of Voyage:

debiandev:/# wget http://www.voyage.hk/dists/experimental/archive.key -O – | apt-key add -

We have to create the file /etc/kernel-img.conf to allow local option for handling some aspects of the installation of the kernel, overriding the defaults.
Put the following contento in the newly created /etc/kernel-img.conf:

# Kernel image management overrides
# See kernel-img.conf(5) for details
do_symlinks = yes
relative_links = yes
do_bootloader = no
do_bootfloppy = no
do_initrd = yes
link_in_boot = no

We are now ready for installing the new kernel and some base packages:

debiandev:/# apt-get update
debiandev:/# apt-cache search 486-voyage
..
linux-image-2.6.30-486-voyage – Linux kernel binary image for version 2.6.30-486-voyage
..
debiandev:/# apt-get install linux-image-2.6.30-486-voyage openssh-server grub locales

We have to configure locales. For example for Italy you have to select value it_IT@euro ISO-8859-15.

debiandev:/# export LC_ALL=C
debiandev:/# dpkg-reconfigure locales

For loading kernel modules (for Alix board) at boot time, create the file /etc/modules with the following content:

natsemi
lm90
w83627hf
scx200_acb base=0×810,0×820
geodewdt
leds-alix

Now we have finished the installation of the kernel e we have to install the boot loader: GRUB.

debiandev:/# mkdir /boot/grub
debiandev:/# cp /usr/lib/grub/i386-pc/* /boot/grub

At this time we have to modify grub’s configuration file and enable the console on the serial port.
With the editor nano open the file /boot/grub/menu.lst and add the following content:

serial –speed=38400
terminal serial
timeout 1
default 0
title Home-Debian-Server
root (hd0,0)
kernel /vmlinuz root=/dev/hda1 console=ttyS0,38400n8
initrd /initrd.img

We have now to modify the inittab file for enabling console on serial port. Edit the file /etc/inittab with nano, and first comment with a “#” all rows reffered to TTY respawn:

#1:2345:respawn:/sbin/getty 38400 tty1
#2:23:respawn:/sbin/getty 38400 tty2
#3:23:respawn:/sbin/getty 38400 tty3
#4:23:respawn:/sbin/getty 38400 tty4
#5:23:respawn:/sbin/getty 38400 tty5
#6:23:respawn:/sbin/getty 38400 tty6

and a few lines downward insert the following row:

T0:23:respawn:/sbin/getty -L ttyS0 38400

Now we have to configure the filesystem at boot time, open the file /etc/fstab adding the following rows:

proc /proc proc defaults 0 0
/dev/hda1 / ext2 noatime,errors=remount-ro 0 1
tmpfs /tmp tmpfs defaults,noatime 0 0
tmpfs /var/tmp tmpfs defaults,noatime 0 0
tmpfs /var/run tmpfs defaults 0 0
tmpfs /var/log tmpfs defaults 0 0
tmpfs /var/lock tmpfs defaults 0 0

Before quitting chroot env, it’s useful to configure also network adapter for managing the new server via SSH since the first boot. With nano edit the file /etc/network/interfaces and add the following lines:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.99
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

Obviously this is an example: insert your custom network parameters.

Now let’s exit from chroot environment with the command “exit” and install Grub in the CF:

debiandev:~# echo ‘(hd0) /dev/sdb’ > /mnt/cf/boot/grub/device.map
debiandev:~# grub-install –root-directory=/mnt/cf/ /dev/sdb

You may get an error like this:
“/usr/sbin/grub-install: line 374: [: =: unary operator expected”
It seems to be generated by a bug in a lenny library, ignore it since grub is working correctly.

Congratulations!!!

Now you have the operating system installed in the CF, you simply have to plug it into the Alix board and power it on!

Tags: , , , , , , , , ,

Thursday, August 13th, 2009 Debian Lenny, Home server, Linux, Voyage Linux

7 Comments to Setting up a Linux home server based on a low cost and low power hardware (Pc Engines Alix) – Part1

  1. [...] You can download and try a ready Compact Flash image for PC Engines Alix 2D2 created following the guide described in our previous posts. [...]

  2. Debian Lenny CF Image file for Pc Engines Alix 2D2 available for download | NetworkSoul.net on August 17th, 2009
  3. [...] First of all, let’s power on our disk and plug it into a free USB port. Now we need to identify the special device assigned to the new disk, partition and format: follow instructions in the first part of this howto. [...]

  4. Setting up a Linux home server based on a low cost and low power hardware (Pc Engines Alix) – External USB disk mounted at boot – Part3 | NetworkSoul.net on August 18th, 2009
  5. thanks a lot, grazie mille, merci beaucoup. I am no expert, and everything I tried until yours failed. So thanks.

    I had (not knowing why) to e2fsck the created filesystem in order to make it work

  6. lloxe on October 24th, 2009
  7. Hi all,

    Great howto just a word of warning if your using debian squeeze or ubuntu 9.10 they have grub2 installed so the

    grub-install –root-directory=/mnt/cf/ /dev/sdb

    Looks like it works but it doesn’t

    Hope that saves you many wasted hours :)

  8. Ric_ on December 1st, 2009
  9. Hi, I was not able to find linux-image-2.6.30-486-voyage, so I choose linux-image-2.6.30-voyage which was the one that seemed close to it. Would that be ok ?

    I am asking because I am not currently successful loading the OS on my Alix 2d3. It stalls after GRUB loading, please wait…

  10. Pierre Bourgault on January 23rd, 2010
  11. Need some help!

    I did the same as you, Pierre B and I too end up at GRUB loading. I’m trying to modify the last lines with different dev’s. Yes, i’m i newbe to this. I’m not sure what I do in the two last lines.

    Should sdx in “(hd0) /dev/sdx” be pointing to my ‘installation CF device’ id (=sde) or should it point to the device in which ALIX will mount the CF (= maybe sdb)?

    I have the same Q also for the last line “grub-install –root-directory=/mnt/cf/ /dev/sdx”, should it be my installation CF (= sde) or the ALIX startup device and maybe as describe in the text (sdb).

    I have no clue what device name my CF will have when I have it installed in the ALIX2D3 and when it starts up.

    Maybe there is other command which have to be changed, like format sde and ‘mount /dev/sde1 …’, because my ‘preparation system’ uses /dev/sde as the name of my CF. I have no clue what the dev. name of my CF will be when (if) I get the ALIX to boot into Debian.

    When it stops at GRUB bootloader, I assume it fails because some pointer points to wrong physical dev. or logical path-name to the CF disk.

    Best Regards
    - Per Håkansson

  12. Per Håkansson on February 20th, 2010
  13. – So close but not all the way :(

    Hello and thanks for the great step by step instruction, even I could follow it :) . But I still have problem to boot my ALIX2D3/32GB CF after done all the step. I use a Ubuntu 9.10 VMware machine to prepare the CF. My CF ends up as /dev/sde and maybe thats why it does not work. As I did say, all the steps works great. I had to change a few to get it right for my setup, but maybe my changes did break to GRUB bootloader for the ALIX2D3. This is all command I use in my setup (Ubuntu VMware with CF at /dev/sde) to install the Debian onto the CF.

    Please, can someone give me a clue or tell me why the GRUB seems to stop loading. I add the serial output to this post too.

    Here is all command (I’v cut out the fdisk followup questions)
    ————————————————–
    sudo su -
    dmesg -> Gives: [sde] 62537328 512-byte logical blocks: (32.0 GB/29.8 GiB)
    umount /dev/sde1 -> because Ubuntu autoinstalls the CF
    fdisk /dev/sde -> when finished, p shows: /dev/sde1 * 1 3877 31264096+ 83 Linux
    apt-get update
    apt-get install mbr
    install-mbr /dev/sde
    mkfs.ext2 /dev/sde1
    apt-get install debootstrap binutils
    mkdir /mnt/cf -> To have a mount-point
    mount /dev/sde1 /mnt/cf
    debootstrap –verbose –arch=i386 lenny /mnt/cf http://ftp.us.debian.org/debian
    mount –bind /proc /mnt/cf/proc
    mount –bind /sys /mnt/cf/sys
    chroot /mnt/cf /bin/bash
    nano /etc/apt/sources.list -> Add the following lines:
    -> deb-src http://ftp.it.debian.org/debian lenny main
    -> deb http://www.voyage.hk/dists/experimental ./
    wget http://www.voyage.hk/dists/experimental/archive.key
    apt-key add archive.key
    nano /etc/kernel-img.conf -> Add the following lines:
    -> # Kernel image management overrides
    -> # See kernel-img.conf(5) for details
    -> do_symlinks = yes
    -> relative_links = yes
    -> do_bootloader = no
    -> do_bootfloppy = no
    -> do_initrd = yes
    -> link_in_boot = no
    apt-get update
    apt-cache search linux-image
    apt-get install linux-image-2.6.30-voyage openssh-server grub locales -> Not the same linux-image as in the article
    export LC_ALL=C
    dpkg-reconfigure locales -> Choose swedish
    nano /etc/modules -> Add the following lines:
    -> natsemi
    -> lm90
    -> w83627hf
    -> scx200_acb base=0×810,0×820
    -> geodewdt
    -> leds-alix
    mkdir /boot/grub
    cp /usr/lib/grub/i386-pc/* /boot/grub
    nano /boot/grub/menu.lst -> Add the following lines:
    -> serial –speed=38400
    -> terminal serial
    -> timeout 1
    -> default 0
    -> title PROBE00000019
    -> root (hd0,0)
    -> kernel /vmlinuz root=/dev/hda1 console=ttyS0,38400n8
    -> initrd /initrd.img
    nano /etc/inittab -> Commented out the following lines:
    -> # 1:2345:respawn:/sbin/getty 38400 tty1
    -> # 2:23:respawn:/sbin/getty 38400 tty2
    -> # 3:23:respawn:/sbin/getty 38400 tty3
    -> # 4:23:respawn:/sbin/getty 38400 tty4
    -> # 5:23:respawn:/sbin/getty 38400 tty5
    -> # 6:23:respawn:/sbin/getty 38400 tty6
    nano /etc/inittab -> Add the following lines:
    -> T0:23:respawn:/sbin/getty -L ttyS0 38400
    nano /etc/fstab -> Add the following lines:
    -> proc /proc proc defaults 0 0
    -> /dev/hda1 / ext2 noatime,errors=remount-ro 0 1
    -> tmpfs /tmp tmpfs defaults,noatime 0 0
    -> tmpfs /var/tmp tmpfs defaults,noatime 0 0
    -> tmpfs /var/run tmpfs defaults 0 0
    -> tmpfs /var/log tmpfs defaults 0 0
    -> tmpfs /var/lock tmpfs defaults 0 0
    nano /etc/network/interfaces -> Add the following lines:
    -> auto lo
    -> iface lo inet loopback
    -> auto eth0
    -> iface eth0 inet dhcp
    exit
    echo ‘(hd0) /dev/sde’ > /mnt/cf/boot/grub/device.map
    grub-install –root-directory=/mnt/cf/ /dev/sde

    The last two lines might be where I have done wrong, but if I try in any other way, I get an error when I issue the last command telling me that it cant find the device or that it cant figure out the device format (depending on which [sde] I change).

    Here is how the bootup runs :(
    ————————————————–
    PC Engines ALIX.2 v0.99
    640 KB Base Memory
    261120 KB Extended Memory

    01F0 Master 044A ELITE PRO CF CARD 32GB
    Phys C/H/S 62041/16/63 Log C/H/S 3892/255/63 LBA
    GRUB loading.

    [Cursor ends here]
    ————————————————–

    Please, please please. Im a newbe to Linux and I don’t understand all commands. But I know that there is a couple of step from BIOS, mbr and bootloader and then the OS (maybe I missed some step). I can understand that if something points ‘wrong’ in this process, ALIX will for sure stop. Maybe I should change some sde/sdb/sda somewhere or maybe there is as easy that this Debian will not work on a 32GB CF?? I’m stuck with my ALIX and that sad . . .

    Best Regards
    - Per Håkansson

  14. Per Håkansson on February 21st, 2010

Leave a comment

 

Categories

AskoziaPBX

Create your full features PBX IP with voicemail and Automated Attendant with alix2d3 or alix2d2 system board.

You can find the PBX IP preconfigured image here:


And obtain all support information "how to" here: