====== Cf-Install ======
Hier wird Beschrieben wie ein Router auf einem Alix-Board mit Ubuntu und Iptables installiert wird.
Das Alix-Board ist ein 2d13. die Anleitung erfolgt in 2 Schritten. Dies ist der Erste, welcher das Vorbereiten der CF-Karte und die Installation des Grundsystems beschreibt.
Der zweite Schritt wird [[linux:alix-router:cf-system|hier]] beschrieben.
Diese Anleitung ist zweckmäßig oft auf meine Bedürfnisse ausgelegt und beinhaltet nicht immer eine Beschreibung dessen was gerade gemacht wird.
Es werden daher div. Grundkenntnisse mit Linux vorausgesetzt.
===== CF-Vorbereiten =====
Eine große Partition auf der CF-Karte erstellen, bootfähig und mit Typ 83.
cfdisk -z /dev/sdb
Partition formatieren; Da ext2 die Journalingfunktion nicht hat werden damit die Schreibzugriffe auf die CF minimiert
mke2fs -L root /dev/sdb1
===== Mount und Bootstrap =====
CF einbinden mit
mkdir /mnt/alix
mount /dev/sdb1 /mnt/alix
System auf die CF installieren (Hier Lucid Lynx)
Evtl noch debootstrap auf dem Notebook installieren (apt-get install debootstrap)
debootstrap --arch i386 lucid /mnt/alix http://de.archive.ubuntu.com/ubuntu
===== Chroot =====
In das System chrooten
mount -o bind /dev /mnt/alix/dev
mount -o bind /dev/pts /mnt/dev/pts
mount -t sysfs /sys /mnt/alix/sys
mount -t proc /proc /mnt/alix/proc
chroot /mnt/alix /bin/bash
==== Hostname ====
Hostname und Domain vergeben
echo router > /etc/hostname
vi /etc/hosts
Inhalt:
127.0.0.1 localhost.localdomain localhost
127.0.1.1 router. router
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
==== Nameserver ====
Nameserver eintragen
vi /etc/resolv.conf
Inhalt:
nameserver
nameserver
==== FSTAB ====
Fstab erstellen.
Die Option noatime beim Root-Dateisystem verhindert, dass jeder Dateizugriff (also auch lesende Zugriffe) das sogenannte atime Attribut (Zeitstempel des letzten Zugriffes) aktualisiert. Das schont die CF-Karte.
vi /etc/fstab
Inhalt:
# /etc/fstab: static file system information.
#
#
proc /proc proc defaults 0 0
# /dev/sda1
LABEL=root / ext2 noatime,errors=remount-ro 0 1
tmpfs /tmp tmpfs defaults,noatime 0 0
tmpfs /var/tmp tmpfs defaults,noatime 0 0
Zeit für zeitversetzte Schreibzugriffe verlängern
vi /etc/sysctl.conf
Inhalt einfach unten einfügen:
#Zeit für zeitversetzte Schreibzugriffe verlängern
vm.dirty_writeback_centisecs = 1500
Gewisse spezielle Laufzeit-Verzeichnisse in einer RAM-Disk verwaltet
vi /etc/default/rcS
Inhalt einfach unten einfügen:
RAMRUN=yes
RAMLOCK=yes
==== Netzwerkkarte ====
Netzwerkkarte konfigurieren
vi /etc/network/interfaces
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth1
iface eth1 inet static
address 192.168.0.1
netmask 255.255.0.0
broadcast 192.168.255.255
# gateway 192.168.0.1
# emergency fallback addresses
# post-up ip addr add 169.254.19.65/16 dev eth0
# pre-down ip addr del 169.254.19.65/16 dev eth0
==== Apt-Sources ====
Apt-Sources festlegen
vi /etc/apt/sources.list
Inhalt:
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
## Primary distribution source
deb http://de.archive.ubuntu.com/ubuntu/ lucid main universe
#deb-src http://de.archive.ubuntu.com/ubuntu/ lucid main universe
## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ lucid-updates main universe
#deb-src http://de.archive.ubuntu.com/ubuntu/ lucid-updates main universe
## Security updates
deb http://security.ubuntu.com/ubuntu lucid-security main universe
#deb-src http://security.ubuntu.com/ubuntu lucid-security main universe
Apt nur die notwendigen Abhängigkeiten installieren lassen
vi /etc/apt/apt.conf.d/00onlydepends
Inhalt:
APT::Install-Recommends "0";
APT::Install-Suggests "0";
==== DSL ====
Für DSL installieren damit nach erstem Boot eingewählt werden kann
apt-get -y install pppoeconf
==== sonstige Einstellungen ====
Regionale Einstellungen
localedef -i de_DE -c -f UTF-8 de_DE.UTF-8
dpkg-reconfigure console-setup
==== Grub ====
Bootmanager installieren
apt-get -y install grub-pc
Im Dialog unbedingt die richtige HDD (CF-Karte) auswählen.
Grub Konfiguration erstellen
vi /etc/default/grub
Inhalt:
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT="3"
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="verbose console=ttyS0,38400n8 reboot=bios"
GRUB_CMDLINE_LINUX=""
# Konfiguration der seriellen Schnittstelle der Alix-Boards:
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=38400"
GRUB_TERMINAL=serial
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entrys
#GRUB_DISABLE_LINUX_RECOVERY="true"
Devices anpassen.
vi /boot/grub/devices.map
Inhalt:
(hd0) /dev/sdb
grub-install /dev/sdb
update-grub
Devices so anpassen, damit Grub beim ersten Booten die richtigen Pfade findet.
vi /boot/grub/devices.map
(hd0) /dev/sda
==== Kernel ====
Kernel-Installations-Konfigurationsdatei anlegen
vi /etc/kernel-img.conf
Inhalt:
# 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
postinst_hook = update-grub
postrm_hook = update-grub
Kernel installieren
apt-get -y install linux-image-386
==== Root Password ====
Root Passwort erstellen
passwd root
==== serielle Konsole ====
Serielle Konsole konfigurieren
rm /etc/init/tty?.conf
vi /etc/init/ttyS0.conf
Inhalt:
# ttyS0 - getty
#
# This service maintains a getty on tty1 from the point the system is
# started until it is shut down again.
start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]
respawn
exec /sbin/getty -8 38400 -L ttyS0
==== sonstige Software ====
Zeitzone festlegen
dpkg-reconfigure tzdata
SSH Server installieren
apt-get -y install openssh-server
Vim installieren
apt-get -y install vim
==== Kernelmodule ====
Zusätzlich geladene Module
vi /etc/modules
Inhalt:
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Alix Specific:
natsemi
lm90
scx200_acb base=0x810,0x820
leds-alix
ledtrig-default-on
ledtrig-heartbeat
ledtrig-gpio
ledtrig-timer
==== Beep ====
BEEP installieren
apt-get -y install beep tcl
vi /etc/modules
Inhalt einfach unten einfügen:
pcspkr
vi /etc/modprobe.d/blacklist.conf
Diese Zeile einkommentieren
blacklist pcspkr
mkdir /root/bin
vi /root/bin/beep.sh
Inhalt:
#! /usr/bin/env tclsh
# nokia2beeps.tcl - Play an RTTL ringtone file as beeps
# Usage: ./nokia2beeps.tcl ringtone_file
set default_octave 4
set default_duration 4
set default_beat 100
set base_time 200000
array set scale {
C0 16.35 C#0 17.32 Db0 17.32 D0 18.35 D#0 19.45 Eb0 19.45
E0 20.60 F0 21.83 F#0 23.12 Gb0 23.12 G0 24.50 G#0 25.96
Ab0 25.96 A0 27.50 A#0 29.14 Bb0 29.14 B0 30.87 C1 32.70
C#1 34.65 Db1 34.65 D1 36.71 D#1 38.89 Eb1 38.89 E1 41.20
F1 43.65 F#1 46.25 Gb1 46.25 G1 49.00 G#1 51.91 Ab1 51.91
A1 55.00 A#1 58.27 Bb1 58.27 B1 61.74 C2 65.41 C#2 69.30
Db2 69.30 D2 73.42 D#2 77.78 Eb2 77.78 E2 82.41 F2 87.31
F#2 92.50 Gb2 92.50 G2 98.00 G#2 103.83 Ab2 103.83 A2 110.00
A#2 116.54 Bb2 116.54 B2 123.47 C3 130.81 C#3 138.59 Db3 138.59
D3 146.83 D#3 155.56 Eb3 155.56 E3 164.81 F3 174.61 F#3 185.00
Gb3 185.00 G3 196.00 G#3 207.65 Ab3 207.65 A3 220.00 A#3 233.08
Bb3 233.08 B3 246.94 C4 261.63 C#4 277.18 Db4 277.18 D4 293.66
D#4 311.13 Eb4 311.13 E4 329.63 F4 349.23 F#4 369.99 Gb4 369.99
G4 392.00 G#4 415.30 Ab4 415.30 A4 440.00 A#4 466.16 Bb4 466.16
B4 493.88 C5 523.25 C#5 554.37 Db5 554.37 D5 587.33 D#5 622.25
Eb5 622.25 E5 659.26 F5 698.46 F#5 739.99 Gb5 739.99 G5 783.99
G#5 830.61 Ab5 830.61 A5 880.00 A#5 932.33 Bb5 932.33 B5 987.77
C6 1046.50 C#6 1108.73 Db6 1108.73 D6 1174.66 D#6 1244.51 Eb6 1244.51
E6 1318.51 F6 1396.91 F#6 1479.98 Gb6 1479.98 G6 1567.98 G#6 1661.22
Ab6 1661.22 A6 1760.00 A#6 1864.66 Bb6 1864.66 B6 1975.53 C7 2093.00
C#7 2217.46 Db7 2217.46 D7 2349.32 D#7 2489.02 Eb7 2489.02 E7 2637.02
F7 2793.83 F#7 2959.96 Gb7 2959.96 G7 3135.96 G#7 3322.44 Ab7 3322.44
A7 3520.00 A#7 3729.31 Bb7 3729.31 B7 3951.07 C8 4186.01 C#8 4434.92
Db8 4434.92 D8 4698.64 D#8 4978.03 Eb8 4978.03
}
proc nokia2scale {note} {
global default_octave
set note [string toupper [regexp -inline {[a-gA-GpP].*} $note]]
if {$note != "P" && ![regexp {\d$} $note]} {
append note $default_octave
}
set note [string map {. ""} $note]
return $note
}
proc nokia2length {note} {
global default_duration default_beat base_time
set duration [regexp -inline {^\d+} $note]
if {$duration == ""} {
set duration $default_duration
}
return [expr {$base_time/$default_beat/$duration}]
}
proc playnote {note} {
global scale
set note [string trim $note]
if {$note == ""} return
puts -nonewline "$note "
flush stdout
set delay [nokia2length $note]
set note [nokia2scale $note]
if {$note == "P"} {
after $delay
} else {
exec beep -f $scale($note) -l $delay
}
}
proc playRTTL {str} {
global default_octave default_beat default_duration
foreach x [regexp -inline -all {[dob]=\d+} $str] {
regexp {(\w)=(\d+)} $x -> param value
switch $param {
d {set default_duration $value}
o {set default_octave $value}
b {set default_beat $value}
}
}
regexp {\:([^\:]+)$} $str -> str
puts "beat: $default_beat"
foreach x [split $str ,] {
playnote $x
}
puts done.
}
set f [open [lindex $argv 0]]
set data [read $f]
close $f
playRTTL $data
Script noch ausführbar machen.
chmod a+x /root/bin/beep.sh
Ringtone erstellen
vi /root/bin/itchy
Inhalt:
Itchy:d=4,o=5,b=160:8c6,8a,p,8c6,8a6,p,8c6,8a,8c6,8a,8c6,8a6,p,8p,8c6,8d6,8e6,8p,8e6,8f6,8g6,p,8d6,8c6,d6,8f6,a#6,a6,2c7
Script beim Booten starten lassen durch die //rc.local//
vi /etc/rc.local
Inhalt unten vor "exit0" einfügen:
/root/bin/beep.sh /root/bin/itchy
==== Installation abschliessen ====
Installation abschliessen und CF-Karte aushängen
exit
umount /mnt/alix/proc
umount /mnt/alix/sys
umount /mnt/alix/dev
umount /mnt/alix
===== Erster Bootvorgang =====
CF im Router starten und Aktualisierung und Softwareinstallation
apt-get update
apt-get upgrade
===== Screenrc =====
apt-get -y install ubuntu-standard screen
vi /etc/screenrc
Inhalt:
# $Id: screenrc,v 1.15 2003/10/08 11:39:03 zal Exp $
#
# /etc/screenrc
#
# This is the system wide screenrc.
#
# You can use this file to change the default behavior of screen system wide
# or copy it to ~/.screenrc and use it as a starting point for your own
# settings.
#
# Commands in this file are used to set options, bind screen functions to
# keys, redefine terminal capabilities, and to automatically establish one or
# more windows at the beginning of your screen session.
#
# This is not a comprehensive list of options, look at the screen manual for
# details on everything that you can put in this file.
#
# ------------------------------------------------------------------------------
# SCREEN SETTINGS
# ------------------------------------------------------------------------------
startup_message off
#nethack on
#defflow on # will force screen to process ^S/^Q
deflogin on
#autodetach off
# turn visual bell on
# vbell on
# vbell_msg " Wuff ---- Wuff!! "
# define a bigger scrollback, default is 100 lines
defscrollback 10240
# ------------------------------------------------------------------------------
# SCREEN KEYBINDINGS
# ------------------------------------------------------------------------------
# Remove some stupid / dangerous key bindings
bind ^k
#bind L
bind ^
# Make them better
bind \\ quit
bind K kill
bind I login on
bind O login off
bind } history
# An example of a "screen scraper" which will launch urlview on the current
# screen window
#
#bind ^B eval "hardcopy_append off" "hardcopy -h $HOME/.screen-urlview" "screen urlview $HOME/.screen-urlview"
# ------------------------------------------------------------------------------
# TERMINAL SETTINGS
# ------------------------------------------------------------------------------
# The vt100 description does not mention "dl". *sigh*
termcapinfo vt100 dl=5\E[M
# turn sending of screen messages to hardstatus off
hardstatus off
# Set the hardstatus prop on gui terms to set the titlebar/icon title
termcapinfo xterm*|rxvt*|kterm*|Eterm* hs:ts=\E]0;:fs=\007:ds=\E]0;\007
# use this for the hard status string
hardstatus string "%h%? users: %u%?"
# An alternative hardstatus to display a bar at the bottom listing the
# windownames and highlighting the current windowname in blue. (This is only
# enabled if there is no hardstatus setting for your terminal)
#
#hardstatus lastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"
# set these terminals up to be 'optimal' instead of vt100
termcapinfo xterm*|linux*|rxvt*|Eterm* OP
# Change the xterm initialization string from is2=\E[!p\E[?3;4l\E[4l\E>
# (This fixes the "Aborted because of window size change" konsole symptoms found
# in bug #134198)
termcapinfo xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'
# To get screen to add lines to xterm's scrollback buffer, uncomment the
# following termcapinfo line which tells xterm to use the normal screen buffer
# (which has scrollback), not the alternate screen buffer.
#
#termcapinfo xterm|xterms|xs|rxvt ti@:te@
# Enable non-blocking mode to better cope with flaky ssh connections.
defnonblock 5
# ------------------------------------------------------------------------------
# STARTUP SCREENS
# ------------------------------------------------------------------------------
# Example of automatically running some programs in windows on screen startup.
#
# The following will open top in the first window, an ssh session to monkey
# in the next window, and then open mutt and tail in windows 8 and 9
# respectively.
#
# screen top
# screen -t monkey ssh monkey
# screen -t mail 8 mutt
# screen -t daemon 9 tail -f /var/log/daemon.log
hardstatus alwayslastline "%{kw} %{b}%H%{K} < %-w%{Wb} %n %t %{-}%+w >"
# This lets work all functions keys in midnight commander
termcapinfo xterm 'k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~'
===== LEDs =====
Ansteuerung der LEDs
cd /usr/src
apt-get -y install build-essential
apt-get -y install leds-alix-source
apt-get -y install linux-headers-$(uname -r)
tar -xvjf leds-alix.tar.bz2
cd modules/leds-alix//root/bin/
make
make install
rm -rf /usr/src/modules
cd /
apt-get --yes --purge remove linux-headers-$(uname -r)
apt-get --yes --purge remove leds-alix-source
apt-get --yes --purge remove build-essential
apt-get --yes --purge autoremove
apt-get clean
vi /etc/modules
Inhalt einfach unten einfügen:
leds-alix
ledtrig-default-on
ledtrig-heartbeat
ledtrig-gpio
ledtrig-timer
Zum testen der Module eingeben
sudo modprobe leds-alix
sudo modprobe ledtrig-default-on
sudo modprobe ledtrig-heartbeat
sudo modprobe ledtrig-gpio
sudo modprobe ledtrig-timer
Manuelle LED Ansteuerung nachdem die module geladen sind
LED1 einschalten:
sudo echo 1 > /sys/class/leds/alix\:1/brightness
LED1 ausschalten:
sudo echo 0 > /sys/class/leds/alix\:1/brightness
LED1 als Systemauslastungsanzeige - je mehr Systemauslastung, je schneller schlägt das Herz:
sudo echo heartbeat > /sys/class/leds/alix\:1/trigger
LED1 als Platten-Aktivitätsanzeige:
sudo echo ide-disk > /sys/class/leds/alix\:1/trigger
LED1 mit zeitgesteuertes Blinken - 1 Sekunde an, 5 Sekunden aus:
sudo echo timer > /sys/class/leds/alix\:3/trigger
sudo echo 1000 > /sys/class/leds/alix\:3/delay_on
sudo echo 5000 > /sys/class/leds/alix\:3/delay_off
vi /etc/init/watchdog-led.conf
Inhalt:
# WatchDog LED Configuration for Alix-Boards
#
# This task configures the watchdog led to resemble the status
# of the system
description "Configuration of the first alix led (Watchdog led)"
author "Leo Moll "
start on runlevel [0123456]
stop on runlevel [!$RUNLEVEL]
export RUNLEVEL
export PREVLEVEL
task
script
case $RUNLEVEL in
1|6) echo timer > /sys/class/leds/alix\:1/trigger
echo 100 > /sys/class/leds/alix\:1/delay_on
echo 100 > /sys/class/leds/alix\:1/delay_off
;;
0) echo 0 > /sys/class/leds/alix\:1/brightness
echo none > /sys/class/leds/alix\:1/trigger
;;
2|3|4|5) echo heartbeat > /sys/class/leds/alix\:1/trigger
;;
*) echo timer > /sys/class/leds/alix\:1/trigger
echo 100 > /sys/class/leds/alix\:1/delay_on
echo 300 > /sys/class/leds/alix\:1/delay_off
;;
esac
end script
Basierend auf dem entsprechenden Run Level verhält sich nun die erste LED folgendermaßen:
*Normaler Betrieb: Herzschlag (Heartbeat)
*Reboot: Schnelles blinken
*System heruntergefahren: LED aus
*Beim Starten: LED an
*System gestartet in Run Level 1: schnelles blinken
*Anderer Runlevel: Kurzes blinken
LEDs nach Bootvorgang aktivieren
vi /etc/rc.local
Inhatl einfach unten vor "exit0" einfügen:
echo gpio > /sys/class/leds/alix\:3/trigger
echo phy0rx > /sys/class/leds/alix\:2/trigger