LEX NEO – A fanless CF-Boot Setup

This tutorial tries to show you how to setup a wonderful quiet fanless system.
I’ve bought a LEX NEO, a terribly nice Mini-ITX fanless barebone which includes an onboard bootable CF-card slot.
Thomas Bocek (nope.ch) helped me out with the following configuration.
The idea was:

  • The harddisk should only run when used
  • The whole system should be stored on a CF-card
  • We don’t want to stress our CF-card. Directories with a lot of access like /var/log should be run in RAM

We decided to install Debian Linux by USB-install, using a USB-stick instead of running some PXE network install which seems to be far more complicated.
Here’s a short HOWTO (for more detailed instructions, please check Debian USB memory stick booting:
Download boot.img.gz (7.9 MB). Also, download the official netinst image (108 MB). If you can’t find it, check http://www.debian.org/CD/netinst/ and download the stable i386 version.

Now, prepare the USB-stick:

$> dd if=boot.img of=/dev/sda
$> mount -t vfat /dev/sda /mnt/
$> cp debian-31r0a-i386-netinst.iso /mnt/

Boot from your USB-stick and install Debian Linux on your CF-card. If it won’t recognize your CF-card, you might want to disable DMA (”ide=nodma” as boot parameter). My CF-card, a SanDisk Ultra II 1GB, did not support DMA.

As soon as your system is set up, configure it to run directories with a lot of write-access completely in RAM.
Let’s create /sbin/preinit:

#!/bin/bash
 
echo "creating tmpfs in /var/log"
mount -n -t tmpfs tmpfs /var/log
echo "copy /var/log"
cp -a /var/log_persistent/* /var/log
echo "set dma on for hdd"
hdparm -d1 /dev/hdd
hdparm -B0 -S18 /dev/hdd
echo "done, resume normal operations..."
exec /sbin/init

This will copy all data from /var/log_persistant to /var/log which is located in RAM as tmpfs on boot-up. Also, it sets the harddrive’s APM to extremely aggressive (-B0) and standby/spindown timeout to 1:30 minutes (-S18).
Make sure, this runs before the default init.d scripts. We managed this by specifying the init parameter in GRUB, /boot/grub/menu.lst:

title           Debian GNU/Linux, kernel 2.6.8-2-386
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.8-2-386 root=/dev/hdc1 ro init=/sbin/preinit ide=nodma
initrd          /boot/initrd.img-2.6.8-2-386
savedefault
boot

Next, set up /etc/fstab:

proc            /proc           proc    defaults        0       0
/dev/hdc1       /               ext2    defaults,errors=remount-ro 0       1
/dev/hdd1       /myharddisk     ext3    defaults,errors=remount-ro 0       1
tmpfs           /var/run        tmpfs   defaults        0       0
tmpfs           /var/lock       tmpfs   defaults        0       0
tmpfs           /var/log        tmpfs   defaults        0       0
tmpfs           /tmp            tmpfs   defaults        0       0

/dev/hdc represents the CF-card on Secondary Master, /dev/hdd is the harddisk on Secondary Slave.

As you see, we’re now running the following directories in RAM:
/var/log, /var/run, /var/lock, /var/log, /tmp
All we need to do now, is synchronizing back the /var/log data to our CF-card every hour and on a shutdown
/etc/cron.hourly/backup-var:

#!/bin/bash
rsync -ax --delete --temp-dir=/tmp /var/log/* /var/log_persistent

Create /etc/init.d/commit:

#!/bin/sh
 
case "$1" in
start)  echo -n "n/a"
echo "."
;;
stop)   echo -n "Comitting changes and backup"
/etc/cron.hourly/backup-var
echo "."
;;
restart) echo -n "n/a"
echo "."
;;
reload|force-reload) echo -n "n/a"
echo "."
;;
*)      echo "Usage: /etc/init.d/commit start|stop|restart|reload|force-reload"
exit 1
;;
esac
exit 0

Add the commit script to all necessary runlevels:

$> cd /etc/init.d
$> update-rc.d commit defaults

That’s it! Enjoy your slick silent baby!

5 Comments so far »

  1. Marc said

    am June 28 2007 @ 5:19 pm

    Hello,

    Note that with debian etch, you can install the flashybrid package which automatically does more or less the same thing.

    Marc

  2. Henrique Brancher Gravina said

    am January 12 2008 @ 3:18 am

    Nice! this instructions works very well to me. Ubuntu Server 7.10, Thanks.

    Only the chmod +x commands are not in the text.

  3. Thomas Verchow said

    am February 27 2008 @ 12:02 am

    Add the mount option “noatime” to your grub/menu.lst to avoid updating the access time. This is something you really want to do :-)

    Regards!

  4. My Home NAS, Part 4 « In Defiance of Titles said

    am November 10 2008 @ 6:44 am

    [...] that could cause extremely frequent write access, and it’d be nice to avoid this.  Based on some useful instructions from another blog, I decided to mount a few areas of the filesystem in RAM rather than on the CF card itself.  To do [...]

  5. Ppaul said

    am December 17 2008 @ 10:38 pm

    I am trying to install Monowall or Pfsense firewall on a Lex Light PC but it does not have CF card, I have only one 20GB HDD.

    How can I do it? Because the disk is on Secondary Mater.

Comment RSS · TrackBack URI

Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment: