Sysadmin > NetBSD > NetBSDonAlixWithCf

ALIX2 with Solidstate CF

Howto install NetBSD on a ALIX2-board with Compact-Flash (CF)

The ALIX-Board from Pascal Dornier is a ideal home server, because it is silent, small and very energie efficient. The ALIX-Board ist fast enough for most normal server usage and also interesting for appliances. Depending von the size and speed of your CF you can make it a very fast machine with enough space.

If you like to install NetBSD on a CF exactly as on a harddisk, you are finished.

But with flash memory you cannot write every block unlimited times. Modern flash has a very high limit so that it is likely that you will never reach that limit, but we like to have a perfectly optimizes NetBSD for our CF. We will tune NetBSD in a way that we have absolutely no write access on our CF.

Therefor we make the CF only readable and put all writeable directories (var and dev) as mfs into the RAM.

Installation

Put CF via IDE2CF-Adapter in a normal PC and boot form a installation floppy or cdrom. Start the installation as usual. Make one MBR of the hole CF. Make one big root-partition ( / ) without swap or seperated tmp or whatever. In the bootblock selection choose serial for com0 with 38400 baud. Install as usual and do not reboot!

Put the CF into the ALIX-Board and boot into singel user mode (stop the automatic boot process and type boot -s).

Konfiguration

Type following commands:
# cd /
# mount -uw /
here we mount the CF in read-write mode
mv /tmp/* /tmp/.* /var/tmp/
move eventually existing files from /tmp to /var/tmp
rmdir /tmp
ln -s var/tmp /tmp
remove the original /tmp -directory and create a symlink
tar cvfzp var-image.tgz var
archive and compress the hole /var -directory

Now we create a script that mounts a /var -directory into RAM and creates all necessary files in that directory during boot process.
cd /etc/rc.d
cat - > mount_mfs_fs

#!/bin/sh
#
# mount_mfs_fs: mount memory file system /var and /dev
# by roby, 23 jun 2003
 
# PROVIDE: mount_mfs_fs
# REQUIRE: root
 
. /etc/rc.subr
 
name="mount_mfs_fs"
start_cmd="mount_mfs_fs_start"
stop_cmd=":"
 
mount_mfs_fs_start()
{
 
   echo -n "Mounting memory file system: "
   # /dev will automatically created during boot by the kernel
   # Mount /dev fs
   # mount_mfs none /dev
   # build device files
   cd /dev
   # /etc/MAKEDEV all
   /etc/MAKEDEV pty0
   /etc/MAKEDEV ptm
 
   # Mount /var fs
   echo -n "/var "
   # mount /var with a size of 70 MB
   mount_mfs -s 70m none /var
   # build dir/files in var
   tar -xzpf /var-image.tgz -C /
   # tar -xzpf /pkg-image.tgz -C /
   echo "Done"
   sleep 5
}
 
 
load_rc_config $name
run_rc_command "$1"
^D
This script mounts a RAM-disk and puts all necessary into it. We set the size of /var to 70MB here, because we need some space to install some bigger packages later. But after installation some software you can reduce the size.
chmod 555 mount_mfs_fs
Now we need an editor (vi)
TERM=vt100
export TERM
change /etc/rc.d/mountcritlocal so that
PROVIDE: mountcritlocal
REQUIRE: root
to
PROVIDE: mountcritlocal
REQUIRE: mount_mfs_fs
check with cd /etc/rc.d; rcorder * | less
cp -p /dev/MAKE* /etc
cp -p /dev/MAKE* /sbin
To be sure i copy MAKEDEV in both dirs because some scripts search in one or the other dir.
cat - >> /etc/rc.conf
no_swap=YES
hostname=foo.rz.uni-konstanz.de
^D
Here we disable swap and give a hostname.
# cat /etc/fstab
# NetBSD /etc/fstab
# See /usr/share/examples/fstab/ for more examples.
/dev/wd0a               /       ffs     rw,noatime               1 1
kernfs          /kern   kernfs  rw
procfs          /proc   procfs  rw,noauto
swap            /var    mfs     rw              0 0
here we configure /var . /dev is not needed, because the kernel setup /dev during boottime.
cd /
rm -rf /var/*
mv /dev /dev-old; mkdir /dev
Some cleanup.

Here we are ready and just have to reboot

If you like to be perfect, you can configure NetBSD to not write anything on the flash

Just change the /-entry from rw to ro and change in /etc/rc.d/root
   umount -a >/dev/null 2>&1
   mount /
to
   umount -a
   mount -r /
If you lockin next time and want to modify somthing, you have to mount -uw / first.

Add some packages

pkg_add -v ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD-4.0/i386/shells/standalone-tcsh-6.15.00nb1.tgz
pkg_add -v ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD-4.0/i386/lang/perl-5.10.0nb6.tgz
pkg_add -v ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD-4.0/i386/sysutils/lsof-4.78.4.0nb2.tgz

You have to look for the exact file name in ftp://ftp.netbsd.org/pub/NetBSD/packages/4.0/i386/ because they will be updated from day to day. After installation you should tar the package-index with tar cvfzp /pkg-image.tgz /var/db/pkg /var/db/pkg.refcount, so that pkg_info shown all installed packages (and uncommend the appropiate line in mount_mfs_fs).

Some helpfull links: