Personal tools
You are here: Home Hacking Gentoo Linux Gentoo on Strato

Gentoo on Strato

Eine Anleitung zur installation von Gentoo Linux (2004.3) mit Kernel 2.6.x/udev auf einem Strato RootServer

Booten des Strato Nofall-Systems

Die Installation wird über das Notfall-System gestartet, das über den Kundenservicebereich gebootet werden kann. Dannach auf dem Notfall-System per SSH einloggen:

  login as: root
  Sent username "root"
  root@h76xxx.serverkompetenz.net's password: 

  BusyBox v0.60.5 (2003.04.02-10:03+0000) Built-in shell (ash)
  Enter 'help' for a list of built-in commands.

Paritionierung überprüfen

Die Installation des Systems habe ich mit folgender Festplattenaufteilung vorgenommen (das bootable Flag muss für /dev/hda1 unbedingt gesetzt sein):

  # fdisk /dev/hda

  The number of cylinders for this disk is set to 7476.
  There is nothing wrong with that, but this is larger than 1024,
  and could in certain setups cause problems with:
  1) software that runs at boot time (e.g., old versions of LILO)
  2) booting and partitioning software from other OSs
     (e.g., DOS FDISK, OS/2 FDISK)

  Command (m for help): p

  Disk /dev/hda: 255 heads, 63 sectors, 7476 cylinders
  Units = cylinders of 16065 * 512 bytes

     Device Boot    Start       End    Blocks   Id  System
  /dev/hda1   *         1         7     56196   83  Linux
  /dev/hda2             8        71    514080   82  Linux swap
  /dev/hda3            72      7476  59480662+  83  Linux

Dateisysteme und Swap vorbereiten

Dateisysteme und Swap werden neu angelegt, um die SuSE-Installation zu löschen.

Zunächst den Swap-Bereich anlegen:

  # mkswap /dev/hda2
  Setting up swapspace version 1, size = 526413824 bytes

Die Boot-Partition formatieren:

  # mke2fs /dev/hda1
  ...
  Writing superblocks and filesystem accounting information: done

  This filesystem will be automatically checked every 35 mounts or
  180 days, whichever comes first.  Use tune2fs -c or -i to override.

Das Journal einschalten und reguläre Filesystemchecks ausschalten:

  # tune2fs -j -c 0 -i 0 /dev/hda1
  tune2fs 1.27 (8-Mar-2002)
  Setting maximal mount count to -1
  Setting interval between check 0 seconds
  Creating journal inode: done
  This filesystem will be automatically checked every -1 mounts or
  0 days, whichever comes first.  Use tune2fs -c or -i to override.

Das Root-Filesystem formatieren:

  # mke2fs /dev/hda3
  ..
  Writing superblocks and filesystem accounting information: done

  This filesystem will be automatically checked every 35 mounts or
  180 days, whichever comes first.  Use tune2fs -c or -i to override

Auch hier das Journal einschalten und reguläre Filesystemchecks ausschalten:

  # tune2fs -j -c 0 -i 0 /dev/hda3
  tune2fs 1.27 (8-Mar-2002)
  Setting maximal mount count to -1
  Setting interval between check 0 seconds
  Creating journal inode: done
  This filesystem will be automatically checked every -1 mounts or
  0 days, whichever comes first.  Use tune2fs -c or -i to override.  

Mountpoints anlegen und mounten:

  # mkdir /mnt/
  # mount /dev/hda3 /mnt
  # mkdir /mnt/boot 
  # mount /dev/hda1 /mnt/boot

Gentoo Linux Stagefile installieren

In BusyBox ist leider das Kompressionsprogramm bzip2 nicht enthalten. Im folgenden wird eine statische binary von bzip2 unter /tmp abgelegt:

   # cd /tmp
   # wget ftp://sources.redhat.com/pub/bzip2/v102/bzip2-102-x86-linux24
   # chmod a+x /tmp/bzip2-102-x86-linux24

BusyBox tar kann leider keine Pfade > 100 Zeichen verarbeiten, deshalb kompilieren wir auf einem einen anderen Linux-System eine statische Binary von GNU tar:

   bash-2.05b$ wget -q  ftp://ftp.cs.tu-berlin.de/pub/gnu/tar/tar-1.15.tar.gz
   bash-2.05b$ tar xzf tar-1.15.tar.gz -C /tmp/
   bash-2.05b$ cd /tmp/tar-1.15/
   bash-2.05b$ LDFLAGS=-static ./configure
   ...
   bash-2.05b$ make

Diese Binary auf den Rootserver kopieren:

   bash-2.05b$ scp src/tar root@h76xxx.serverkompetenz.net:/tmp/    

Und dort ausführbar machen:

   # chmod a+x /tmp/tar   

Das Gentoo Stagefile nach /mnt installieren:

   # cd /mnt
   # wget http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/releases/x86/2004.3/stages/x86/stage3-x86-2004.3.tar.bz2 -O -|/tmp/bzip2-102-x86-linux24 -d |/tmp/tar xf -

dev Dateisystem mounten:

  # mount -o bind /dev /mnt/dev

proc Dateisystem mounten:

  # mount -t proc none /mnt/proc/

Nameserverkonfiguration übernehmen und chroot in das Gentoo Rootverzeichnis:

  # cp /etc/resolv.conf /mnt/etc/
  # chroot /mnt /bin/bash

Zeitzone setzen:

  # ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime

Root Passwort setzen:

  # passwd
  New UNIX password: 
  Retype new UNIX password: 

Portage Tree Update durchführen, portage auf den neusten Stand bringen und benötigte Pakete installieren:

  # emerge sync
  ...
  # emerge portage
  ...
  # emerge udev
  ...
  # emerge dhcpcd

Kernelkonfiguration

Linux Sourcen installieren und mit lspci vorhandene Hardware untersuchen:

  # emerge gentoo-dev-sources
  # emerge pciutils
  # lspci

Kernelkonfiguration vornehmen:

  # cd /usr/src/linux
  # make menuconfig

Folgende Kerneloptionen müssen unbedingt beachtet werden (manche Server haben eine 100MBit, andere eine Gigabit Karte):

  • CONFIG_EEPRO100=y
  • CONFIG_E1000=y
  • CONFIG_DEVFS_FS is not set
  • CONFIG_SERIAL_CORE=y
  • CONFIG_SERIAL_CORE_CONSOLE=y
  • CONFIG_SERIAL_8250=y
  • CONFIG_SERIAL_8250_CONSOLE=y

Kernel, Module kompilieren und installieren:

  # make
  ...
  # make modules && make modules_install
  ...
  # cp arch/i386/boot/bzImage /boot/
  # cp System.map /boot/

/etc/fstab editieren:

  /dev/hda1               /boot           ext3            noatime   1 1
  /dev/hda3               /               ext3            defaults  0 0
  /dev/hda2               none            swap            sw        0 0
  none                    /proc           proc            defaults  0 0
  none                    /dev/shm        tmpfs           defaults  0 0

Netzwerkkonfiguration

net.eth0 und sshd zum default runlevel hinzufügen:

  # rc-update add net.eth0 default
  ...
  # rc-update add sshd default

/etc/conf.d/net editieren:

  iface_eth0="dhcp"
  dhcpcd_eth0="-HD"

Grub Installieren und Konfigurieren

ebuild installieren:

   # emerge grub

und für Boot von Festplatte konfigurieren:

  # grub
  grub> root (hd0,0)
  grub> setup (hd0)

/boot/grub/grub.conf editieren:

  timeout 5
  default 0
  serial --unit=0 --speed=57600 --word=8 --parity=no --stop=1
  terminal serial

  title  GNU/Linux
  root (hd0,0)
  kernel /bzImage root=/dev/hda3 console=tty0 console=ttyS0,57600

Konfiguration der seriellen Login-Console

Strato bietet einen Zugang zur seriellen Console per SSH an. Der Bootvorgang ist nun über Grub steuerbar. Damit eine Login auch bei fehlerhafter Netzwerk-Konfiguration möglich ist, sollte man die serielle Console konfigurieren. Folgende Zeile muss in /etc/inittab eingetragen werden:

  # serial console
  s0:123457:respawn:/sbin/agetty 57600 /dev/ttyS0

Das PAM-Modul pam_securetty erlaubt kein root-Login, falls die serielle Console nicht in /etc/securetty eingeragen ist. Also noch folgende Zeile in /etc/securetty hinzufügen:

 tts/0

Das System booten

Nicht vergessen über den Kundenservicebereich das System für einen normalen reboot zu konfigurieren. Viel Glück:

  # reboot

Kritik und Anregungen

Diese Anleitung enstand aus einem Putty-Logfile, das ich während der Installation erstellt habe. Es können durchaus noch einige Fehler enthalten sein. Feedback bitte an gentoo@hoetzel.info

TODOs für diese Anleitung

  • Verwendung von e2label
Document Actions