Debian Squeeze auf einem Alix 2D13

Aus DebianforumWiki
(Weitergeleitet von Benutzer:Duese/Alix)
Zur Navigation springen Zur Suche springen
Wiki ‹ Notebooks und spezielle Geräte ‹ Debian Squeeze auf einem Alix 2D13


Dieser Artikel beschreibt die Installation von Debian Squeeze auf einer CF-Karte für ein Alix 2D13 ohne VGA-Anschluss.

Zugriff über die serielle Schnittstelle

Herausfinden, welche serielle Schnittstelle man braucht:

dmesg | grep -i "tty"

Ausgabe:

[    0.000000] console [tty0] enabled
[    1.951162] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    1.953707] 00:0a: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

PC mit Alix-Board via Null-Modem-Kabel verbinden. Eine Screen-Session starten um die Ausgaben vom Alix-Board zu empfangen:

user@debian:~$ screen -h 5000 -c /dev/null /dev/ttyS0 38400 8n1

Alix-Board, wie in der Doku zum Board beschrieben, anschließen. (Netzteilstecker in die Steckdose zuletzt) Während des kurzen und schnellen Memorytests S drücken, um ins BIOS-Setup zu gelangen.

Installation via PXE

Im Bios-Menü das PXE Booten aktivieren.

/srv/tftp/pxelinux.cfg/default

SERIAL 0 38400 0 
label alix
menu label squeeze_alix
menu default
kernel debian-installer/i386/linux
append vga=normal initrd=debian/squeeze/i386/initrd.gz console=ttyS0,38400n8 --

Zeile 1 sorgt dafür das die Ausgabe des Bootmenüs über die serielle Konsole erfolgen kann. In Zeile 6 sorgt der Abschnitt "console=..." dafür.

Installation via debootstrap

Zunächst CF-Karte mit einer großen ext2-Partition partitionieren.

Anschließend die Karte mounten und mit Debianpackage.png debootstrap das Basissystem auf die Karte spielen:

root@debian:~# mkdir -p /mnt/cfcard
root@debian:~# mount /dev/sdc1 /mnt/cfcard
root@debian:~# debootstrap --arch i386 squeeze /mnt/cfcard http://ftp2.de.debian.org/debian/

Jetzt in das System chrooten:

root@debian:~# mount proc /mnt/cfcard/proc -t proc
root@debian:~# mount sysfs /mnt/cfcard/sys -t sysfs
root@debian:~# mount -o bind /dev /mnt/cfcard/dev
root@debian:~# chroot /mnt/cfcard /bin/bash

Man kann das System nun konfigurieren und neue Pakete hinzufügen. Damit man aber bei der Installation neuer Pakete nicht immer mit der Warnung belästigt wird, das die locals fehlen, werden diese zuerst installiert. Wer es nicht mag, dass empfohlene Pakete mit installiert werden, der kann dies in aptitude (oder apt) entsprechend einstellen.

root@debian:~# aptitude install console-setup language-env locales
root@debian:~# dpkg-reconfigure locales

Für die korrekte Zeitzone:

root@debian:~# dpkg-reconfigure tzdata

Jedes Kind braucht einen Namen. Um dem System einen eigenen Namen zu geben muss die /etc/hostname angepasst werden:

root@debian:~# echo sinnvollername > /etc/hostname

Im System müssen jetzt einige Einstellungen getätigt werden: In der /etc/fstab müssen proc, sys, sowie das Root-Dateisystem hinterlegt werden, damit diese beim Systemstart gemountet werden. Es ist zu beachten, dass der Name der CF-Karte im Zielsystem nicht der gleiche wie unter dem Hostsystem sein muss. Wenn nur eine Karte ohne Festplatte im Zielsystem installiert wird, so ist die Wahrscheinlichkeit hoch, dass der Name sda1 lauten wird.

proc        /proc   proc    defaults                        0       0
sysfs       /sys    sysfs   defaults                        0       0
/dev/sda1   /       ext2    noatime,errors=remount-ro       0       1

In der /etc/inittab können die normalen Bildschirmkonsolen abgeschaltet und durch eine serielle Konsole ersetzt werden:

...
#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
...
T0:23:respawn:/sbin/getty -L ttyS0 38400
...


Vor der Installation des Kernels muss noch die /etc/kernel-img.conf erstellt werden:

# 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

Jetzt den Kernel installieren:

root@debian:~# aptitude install linux-image-486

Anschließend kann grub installiert werden:

root@debian:~# aptitude install grub-pc

Damit die Ausgaben von grub und des zu bootenden Kernels auf der seriellen Konsole landen müssen in der /etc/default/grub folgende Zeilen angepasst bzw. hinzugefügt werden:

GRUB_CMDLINE_LINUX_DEFAULT="verbose console=ttyS0,38400n8 reboot=bios"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=38400"
GRUB_TERMINAL=serial

Möglicherweise muss grub noch im MBR installiert werden, sofern dies während der Installation des Paketes nicht schon geschehen ist. Es sei Vorsicht bei den Namen geboten, um nicht grub im MBR des Hostsystems zu installieren.

root@debian:~# grub-install /dev/sdc
root@debian:~# update-grub

Möglicherweise muss die Datei /boot/grub/devices.map korrigiert werden, da sie die Werte des Hostsystems enthält. Sie sollte so erstellt werden, wie sie das Alixboard später sieht:

(hd0)   /dev/sda

Um sich später via root über SSH einloggen zu können, muss für root ein Passwort vergeben werden:

root@debian:~# passwd

Um die Namen der Netzwerkschnittstellen in eine geordnete Reihenfolge zu bringen (bei mir waren es eth1, eth2 und eth4), kann man die Datei /etc/udev/rules.d/70-persistent-net.rules editieren:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1f:c6:b6:0e:83", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Der rot hinterlegte Text ist die MAC-Adresse der NIC, der gelbe Text der Soll-Name der Netzwerkschnittstelle.

(Anm. eines Autors: Bei meinem System wurden in der Datei /etc/udev/rules.d/70-persistent-net.rules vier Netzwerkschnittstellen angegeben. Drei davon entsprachen den rückseitigen Anschlüssen des Alix-Boards und hatten direkt aufeinanderfolgende MAC-Adressen. Dabei war die mit der kleinsten MAC-Adresse die Schnittstelle, die direkt neben dem Anschluss für die Spannungsversorgung liegt. Ob dies bei anderen Boards ebenso ist, vermag ich nicht zu sagen. Vielleicht können andere ihre Erfahrungen hier ablegen. --Duese 14:17, 16. Sep. 2011 (CEST))

Damit man auf das Netzwerk zugreifen kann, brauchen wir eine /etc/network/interfaces:

# /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet dhcp

auto eth2
iface eth2 inet dhcp

Wenn man eine feste IP vergibt, kann man sich via SSH einloggen und braucht die serielle Schnittstelle nicht unbedingt.

LEDs ansteuern

Das Paket Debianpackage.png leds-alix-source muss zunächst kompiliert werden. Gegebenenfalls ist hierfür zuerst das Programm Debianpackage.png checkinstall zu installieren, dass aus den kompilierten sourcen automatisch ein Debianpaket baut und durch das Paketmanagement installiert (alternativ kann hier nach dem make, statt checkinstall, auch ein einfaches make install verwendet werden):

root@debian:~#  cd /usr/src
root@debian:~#  aptitude install build-essential leds-alix-source linux-headers-$(uname -r)
root@debian:~#  tar -xvjf leds-alix.tar.bz2
root@debian:~#  cd modules/leds-alix/
root@debian:~#  make
root@debian:~#  checkinstall
root@debian:~#  cd /usr/src
root@debian:~#  rm -rf /usr/src/modules
root@debian:~#  aptitude purge build-essential leds-alix-source linux-headers-$(uname -r)

Anschließend können die Kernelmodule geladen werden:

root@debian:~#  modprobe leds-alix
root@debian:~#  modprobe ledtrig-default-on
root@debian:~#  modprobe ledtrig-heartbeat
root@debian:~#  modprobe ledtrig-timer

Damit die LEDs dauerhaft angesteuert werden können, die oben genannten Module in /etc/modules einfügen.

Jetzt können die LEDs angesteuert werden:

# Anschalten der LEDs 1 bis 3
echo 1 > /sys/class/leds/alix\:1/brightness
echo 1 > /sys/class/leds/alix\:2/brightness
echo 1 > /sys/class/leds/alix\:3/brightness

# Ausschalten der LEDs 1 bis 3
echo 0 > /sys/class/leds/alix\:1/brightness
echo 0 > /sys/class/leds/alix\:2/brightness
echo 0 > /sys/class/leds/alix\:3/brightness

# LED als Heartbeat konfigurieren
# Je höher die Load desto schneller das blinken
echo heartbeat > /sys/class/leds/alix\:1/trigger

# Aktivität der IDE auf LED 2 anzeigen
echo ide-disk > /sys/class/leds/alix\:2/trigger

# LED 3 für eine Sekunde (1000 ms) einschalten,
# dann wieder für 5 Sekunden ausschalten.
echo timer > /sys/class/leds/alix\:3/trigger
echo 1000  > /sys/class/leds/alix\:3/delay_on
echo 5000  > /sys/class/leds/alix\:3/delay_off

# Alle Trigger deaktivieren
echo none > /sys/class/leds/alix\:1/trigger
echo none > /sys/class/leds/alix\:2/trigger
echo none > /sys/class/leds/alix\:3/trigger

# Die LED etwas morsen lassen
echo morse > /sys/class/leds/alix\:3/trigger
echo "DEBIAN" /sys/class/leds/alix\:3/message

(Quelle: [1]. Bei mir taten es das morsen nicht. --Duese 16:24, 22. Sep. 2011 (CEST))

Die gewünschten Anzeigen in /etc/rc.local einfügen.

System auf Read-Only umstellen

Um die Schreibzugriffe auf die CF-Karte zu minimieren und damit die Lebenszeit des Flash-Speichers zu erhöhen soll das System als Read-Only eingebunden werden.

root@debian:~#  aptitute install aufs-tools busybox
root@debian:~#  echo aufs >> /etc/initramfs-tools/modules

Das nachfolgende #Skript nach /etc/initramfs-tools/scripts/init-bottom/__rootaufs kopieren und ausführbar machen.

root@debian:~#  chmod 0755 /etc/initramfs-tools/scripts/init-bottom/

In der Datei /etc/fstab den Eintrag für das Root-Dateisystem auskommentieren:

proc        /proc   proc    defaults                        0       0
sysfs       /sys    sysfs   defaults                        0       0
#/dev/sda1   /       ext2    noatime,errors=remount-ro       0       1

In der Datei /etc/default/grub nachfolgende Zeile um "aufs=tmpfs" ergänzen.

GRUB_CMDLINE_LINUX_DEFAULT="verbose console=ttyS0,38400n8 reboot=bios aufs=tmpfs"

Jetzt grub updaten und ein neues InitRAM-Dateisystem erzeugen

root@debian:~#  update-grub
root@debian:~#  update-initramfs -u

Skript

Dieses Skript als /etc/initramfs-tools/scripts/init-bottom/__rootaufs ablegen.

#! /bin/sh

#  Copyright 2008 Nicholas A. Schembri State College PA USA
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see
#    <http://www.gnu.org/licenses/>.

# Thank you Voyage Linux for the idea, http://voyage.hk/ Great job on release 0.5
#
# Tested with 8.04.1
# tested with 9.10
# tested with debian live 6.0.1
# tested with debian squeeze
#
# ****************************************************************************************
#
#                                 Change log
#
# 2008.08.01  Added debugging comments in "drop to a shell" section. grub option aufs=tmpfs-debug will stop the init script.
#             reviewed *********** fix fstab on tmpfs ******************
#             rootaufs failed when system was booted with /dev/xxx and fstab had uuid= info.
#             BlaYO pointed out the best and simplest solution was to use grep -v. Grep replaces a sed one liner.
#             Add the comment block to fstab
#
# 2009.12.07 Corrected issue caused by Apparmor.
#            Name changed to __rootaufs.
#
# 2011.08.19 Changed if condition to avoid issue (sh: bad number) when $aufsdebug is not set.
#            Now checks exists apparmor before delete.
#
# 2011.08.20 For work correctly with Debian Live 6.0.1 (http://live.debian.net/) two lines must be removed from rc.local modification part:
#             'mount -f  /ro'
#             'echo aufs-tmpfs /rw tmpfs rw 0 0 >>/etc/mtab'
#            (already done in this version)
#

echo "********** SETTING UP READ ONLY MODE WITH AUFS ***********"

case $1 in
prereqs)
    exit 0
    ;;
esac

export aufs

for x in $(cat /proc/cmdline); do
    case $x in
    root=*)
        ROOTNAME=${x#root=}
        ;;
    aufs=*)
        aufs=${x#aufs=}
        aufsdebug=0       # changed by tf
        case $aufs in
        tmpfs-debug)
            aufs=tmpfs
            aufsdebug=1
            ;;
        esac
        ;;
    esac
done


if [ "$aufs" != "tmpfs" ]; then
    #not set in boot loader
    #I'm not loved. good bye
    exit 0
fi

# This is a simple overview of the steps needed to use aufs on the root file system and see the /rw and /ro  branches.
# initramfs init-botton script
# move the root file system to aufs/unionfs readonly /ro
# root is mounted on ${rootmnt}
# create tmpfs on /rw
# create a aufs using /ro and /rw
# put some files on the tmpfs to fix mtab and fstab
# move aufs to rootmnt to finish the init process.
# No changes to the root file system are made by this script.
#
#  Why!
#  This will allow you to use a usb flash drive and control what is written to the drive.
#  no need to rebuild the squashfs file just to add a program.
#  boot to single user mode.  The system works the way you expect. boot aufs=tmpfs and no changes are written to the flash.
#  run ubuntu on an eeePC .

# Install
# Install ubuntu 8.04 Hardy. Hardy has aufs installed by default
# apt-get update
# apt-get dist-upgrade
# apt-get install aufs-tools
# echo aufs >> /etc/initramfs-tools/modules
# put this file in /etc/initramfs-tools/scripts/init-bottom/rootaufs
# chmod 0755 rootaufs
# # clean up menu.lst
# update-grub
# update-initramfs -u
# vi /boot/grub/menu.lst
# add aufs=tmpfs to the default entry.
# do not add this line to single user mode.
# boot to single user mode in order to install software.
# note: if your home account is on the root file system, your files are in ram and not saved.
#

echo
echo "       root-aufs:  Setting up aufs on ${rootmnt} as root file system "
echo

modprobe -q --use-blacklist aufs
if [ $? -ne 0 ]; then
    echo    root-aufs error:      Failed to load aufs.ko
    exit 0
fi

#make the mount points on the init root file system
mkdir /aufs
mkdir /rw
mkdir /ro

# mount the temp file system and move real root out of the way
mount -t tmpfs aufs-tmpfs /rw
mount --move ${rootmnt} /ro
if [ $? -ne 0 ]; then
    echo    root-aufs error:    ${rootmnt}  failed to move to /ro
    exit 0
fi


mount -t aufs -o dirs=/rw:/ro=ro aufs /aufs
if [ $? -ne 0 ]; then
    echo    root-aufs error:      Failed to mount /aufs files system
    exit 0
fi

#test for mount points on aufs file system
[  -d /aufs/ro ] || mkdir /aufs/ro
[  -d /aufs/rw ] || mkdir /aufs/rw

# the real root file system is hidden on /ro of the init file system.  move it to /ro
mount --move /ro /aufs/ro
if [ $? -ne 0 ]; then
    echo    root-aufs error:      Failed to move /ro /aufs/ro
    exit 0
fi

# tmpfs file system is hidden on /rw
mount --move /rw /aufs/rw
if [ $? -ne 0 ]; then
    echo    root-aufs error:      Failed to move /rw /aufs/rw
    exit 0
fi

#*********** fix fstab on tmpfs ******************
# test for /dev/sdx
# this is not on the real file system.  This is created on the tmpfs each time the system boots.
# The init process will try to mount the root filesystem listed in fstab. / and swap must be removed.
# the root file system must be mounted on /ro not on /

if [ "0$aufsdebug" -eq 1 ]; then
    echo  "   root-aufs debug:    Remove the root file system and swap from fstab "
    echo
    echo
    echo  "         ROOTNAME $ROOTNAME "
    echo  "         resume   $resume   "
    echo
    echo  '     BlaYO pointed out that grep can be used to quickly remove '
    echo  '      the root file system from fstab. '
    echo
    echo  '     Thank you BlaYO for the debug info.'
    echo

fi
# old code
# I'm sure that sed can do this in one step but I want to correct on the rootname  not matching the root in fstab.
#cat /aufs/ro/etc/fstab|sed -e s/$ROOTNAME/\#$ROOTNAME/ -e s/$resume/\#$resume/ >/aufs/etc/fstab

#Add the comment block to fstab
cat <<EOF >/aufs/etc/fstab
#
#   RootAufs has mounted the root file system in ram
#
#  This fstab is in ram and the real fstab can be found /ro/etc/fstab
#  the root file system ' / ' has been removed.
#  All Swap files have been removed.
#

EOF

#remove root and swap from fstab
cat /aufs/ro/etc/fstab|grep -v ' / ' | grep -v swap >>/aufs/etc/fstab
if [ $? -ne 0 ]; then
    echo    root-aufs error:      Failed to create /aufs/etc/fstab
    #exit 0
fi

# add the read only file system to fstab
#ROOTTYPE=$(/lib/udev/vol_id -t ${ROOT})
ROOTTYPE=$(cat /proc/mounts|grep ${ROOT}|cut -d' ' -f3)
ROOTOPTIONS=$(cat /proc/mounts|grep ${ROOT}|cut -d' ' -f4)
echo ${ROOT} /ro $ROOTTYPE $ROOTOPTIONS 0 0 >>/aufs/etc/fstab


# S22mount on debian systems is not mounting  /ro correctly after boot
# add to rc.local to correct what you see from df
#replace last case of exit with #exit
cat /aufs/ro/etc/rc.local|sed 's/\(.*\)exit/\1\#exit/' >/aufs/etc/rc.local
#Debian specific#echo mount -f  /ro >>/aufs/etc/rc.local

# add back the root file system. mtab seems to be created by one of the init proceses.
echo "echo aufs / aufs rw,xino=/rw/.aufs.xino,br:/rw=rw:/ro=ro 0 0 >>/etc/mtab" >>/aufs/etc/rc.local
#Debian specific#echo "echo aufs-tmpfs /rw tmpfs rw 0 0 >>/etc/mtab" >>/aufs/etc/rc.local
echo exit 0 >>/aufs/etc/rc.local

#  Copyright 2008 Joaquín I. Bogado García
#fix para apparmor, se desactiva y listo ( From the lethe project. )
[ -e /scripts/init-bottom/_apparmor ] && rm /scripts/init-bottom/_apparmor
[ -e /aufs/etc/init.d/apparmor ] && rm /aufs/etc/init.d/apparmor


#build remountrw
echo \#!/bin/sh >/aufs/bin/remountrw
echo mount -o remount,rw ${ROOT} >>/aufs/bin/remountrw
chmod 0700 /aufs/bin/remountrw

#build remountro
echo \#!/bin/sh >/aufs/bin/remountro
echo mount -o remount,ro ${ROOT} >>/aufs/bin/remountro
chmod 0700 /aufs/bin/remountro

# This should drop to a shell. (rewrite)
if [ "0$aufsdebug" -eq 1 ]; then
    echo
    echo "   root-aufs debug:    mount --move /aufs ${rootmnt} "
    echo
    echo '   root-aufs debug:   init will stop here.   '
    echo
    exit 0
fi

mount --move /aufs ${rootmnt}

exit 0

Links