voyage

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 9 Comments

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

A new and very useful “gadget”, a Peaktek 9024 Watt-Meter, is helping me to better understand why my electricity bill is so high!

watt meter energy meter

Peaktech 9024 Watt Meter

The last month my 3 year-old “recycled” AMD Linux home server (active 24 hours a day) burned about 100 KW/h of electricity.. 20  € per month (!!!).

It’s time to find out a smarter and less energy-hungry solution.

We are testing PC Engines Alix for IP PBX and firewall appliances.. why not installing an Alix as a small Linux Home Server?

For starting it should be configured for running:

  • Web server (Apache)
  • File / Printer sharing (Samba)
  • Bit Torrent Client with web interface (Rasterbar libraries and BTG web client)

The model chosen for this test is Alix 2D2, these are key specs:

- CPU: 500 MHz AMD Geode LX800

- Storage: CompactFlash socket, 44 pin IDE header

- Connectivity: 2 Ethernet channels (Via VT6105M 10/100)

- I/O: DB9 serial port, dual USB port

- NO VGA PORT

Power consumption with a Conpact Flash disk: about 5 Watts!!!

It means: 5 (Watts per hour) x 24 (hours a day) x 30 (days) = 3,6 KWh per month!

This is the kit list:

  • Alix 2D2 board
  • Case (Enclosure) for Alix 2
  • AC adapter 18V 0.8 A with EU plug
  • 4 GB standard Compact Flash card

.. in less than 8 months i’ll will pay back the cost of the appliance only with the saving on the electricity bill.. :)

In the next post i will describe how to install a Debian Linux (“Lenny”) on the CF with a kernel optimized for Alix (Voyage Linux).

Tags: , , , , , , , , , ,

Tuesday, August 11th, 2009 Debian Lenny, Home server, Linux, Voyage Linux 77 Comments
 

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: