Rootserver mit Gentoo Linux installieren

Beispiel für die Installation eines Rootservers bei Hetzner mit Gentoo Linux

Gentoo.thumbnailFür jede Linux-Installation – und insbesondere für Gentoo – ist es wichtig die exakte Hardwarekonfiguration des Zielsystems inklusive aller Komponenten für die Treiber benötigt werden zu wissen. Die größte Schwierigkeit bei Installation eines Rootservers ist üblicherweise, dass man keinen Zugang zur Konsole hat und daher in manchen Situationen einen Umweg gehen muss. Beginnen sollte man jedoch jede Installation mit der Abfrage der Systemkomponenten. Dafür kann der Rootserver mit einem Rescue-System gestartet werden.

Hardware-Liste aus /var/log/dmesg des Rescue-Systems (Beispiel)

r8169 Gigabit Ethernet driver 2.2LK-NAPI loaded
eth0: RTL8168b/8111b at 0xffffc2000000e000, 00:1d:92:39:5a:08, IRQ 19
r8169: eth0: link down
r8169: eth0: link down
r8169: eth0: link up
r8169: eth0: link up

3ware Storage Controller device driver for Linux v1.26.02.002.
3ware 9000 Storage Controller device driver for Linux v2.26.02.008.
ahci 0000:00:12.0: version 2.2
ACPI: PCI Interrupt 0000:00:12.0[A] -> GSI 22 (level, low) -> IRQ 22
ahci 0000:00:12.0: controller can't do 64bit DMA, forcing 32bit
ahci 0000:00:12.0: AHCI 0001.0100 32 slots 4 ports 3 Gbps 0xf impl SATA mode
ahci 0000:00:12.0: flags: ncq ilck pm led clo pmp pio slum part

ata1.00: ATA-8: SAMSUNG HD403LJ, CT100-12, max UDMA7
ata1.00: 781422768 sectors, multi 16: LBA48 NCQ (depth 31/32)
ata1.00: configured for UDMA/133
ata2: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata2.00: ATA-8: SAMSUNG HD403LJ, CT100-12, max UDMA7
ata2.00: 781422768 sectors, multi 16: LBA48 NCQ (depth 31/32)
ata2.00: configured for UDMA/133

sd 0:0:0:0: [sda] 781422768 512-byte hardware sectors (400088 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sd 0:0:0:0: [sda] 781422768 512-byte hardware sectors (400088 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
 sda:
sd 0:0:0:0: [sda] Attached SCSI disk
sd 1:0:0:0: [sdb] 781422768 512-byte hardware sectors (400088 MB)
sd 1:0:0:0: [sdb] Write Protect is off
sd 1:0:0:0: [sdb] Mode Sense: 00 3a 00 00
sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sd 1:0:0:0: [sdb] 781422768 512-byte hardware sectors (400088 MB)
sd 1:0:0:0: [sdb] Write Protect is off
sd 1:0:0:0: [sdb] Mode Sense: 00 3a 00 00
sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
 sdb:
sd 1:0:0:0: [sdb] Attached SCSI disk

powernow-k8: Found 2 AMD Athlon(tm) 64 X2 Dual Core Processor 5600+ processors (version 2.00.00)
powernow-k8:    0 : fid 0x14 (2800 MHz), vid 0xa
powernow-k8:    1 : fid 0x12 (2600 MHz), vid 0xc
powernow-k8:    2 : fid 0x10 (2400 MHz), vid 0xe
powernow-k8:    3 : fid 0xe (2200 MHz), vid 0x10
powernow-k8:    4 : fid 0xc (2000 MHz), vid 0x10
powernow-k8:    5 : fid 0xa (1800 MHz), vid 0x10
powernow-k8:    6 : fid 0x2 (1000 MHz), vid 0x12

Ausgabe von ‚lspci‘

root@rescue ~ # lspci
00:00.0 Host bridge: ATI Technologies Inc Unknown device 7910
00:01.0 PCI bridge: ATI Technologies Inc Unknown device 7912
00:07.0 PCI bridge: ATI Technologies Inc Unknown device 7917
00:12.0 SATA controller: ATI Technologies Inc SB600 Non-Raid-5 SATA
00:13.0 USB Controller: ATI Technologies Inc SB600 USB (OHCI0)
00:13.1 USB Controller: ATI Technologies Inc SB600 USB (OHCI1)
00:13.2 USB Controller: ATI Technologies Inc SB600 USB (OHCI2)
00:13.3 USB Controller: ATI Technologies Inc SB600 USB (OHCI3)
00:13.4 USB Controller: ATI Technologies Inc SB600 USB (OHCI4)
00:13.5 USB Controller: ATI Technologies Inc SB600 USB Controller (EHCI)
00:14.0 SMBus: ATI Technologies Inc SB600 SMBus (rev 14)
00:14.1 IDE interface: ATI Technologies Inc SB600 IDE
00:14.3 ISA bridge: ATI Technologies Inc SB600 PCI to LPC Bridge
00:14.4 PCI bridge: ATI Technologies Inc SB600 PCI to PCI Bridge
00:18.0 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration
00:18.1 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Address Map
00:18.2 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] DRAM Controller
00:18.3 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Miscellaneous Control
01:05.0 VGA compatible controller: ATI Technologies Inc Unknown device 791e
01:05.2 Audio device: ATI Technologies Inc Unknown device 7919
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 01)

Festplatten partitionieren

root@rescue ~ # fdisk /dev/sda
root@rescue:~ # fdisk /dev/sdb

Einteilung:

Partition /dev/sda /dev/sdb
1 /boot 64 swap 4096
2 swap 4096
3 /tmp 8196
4 / rest
2 /opt rest

Anlegen der Filesysteme

root@rescue ~ # mkfs.ext2 /dev/sda1
root@rescue ~ # mkfs.ext2 /dev/sda3
root@rescue ~ # mkfs.ext3 /dev/sda4
root@rescue ~ # mkfs.ext3 /dev/sdb2

Einrichten und Aktivieren der Swap Partition

root@rescue ~ # mkswap /dev/sda2
root@rescue ~ # mkswap /dev/sdb1
root@rescue ~ # swapon /dev/sda2
root@rescue ~ # swapon /dev/sdb1

Mounten der Partitionen

root@rescue ~ # mkdir /mnt/gentoo
root@rescue ~ # mount /dev/sda4 /mnt/gentoo
root@rescue ~ # mkdir /mnt/gentoo/boot
root@rescue ~ # mount /dev/sda1 /mnt/gentoo/boot
root@rescue ~ # mkdir /mnt/gentoo/tmp
root@rescue ~ # mount /dev/sda3 /mnt/gentoo/tmp
root@rescue ~ # chmod 1777 /mnt/gentoo/tmp

Prüfen des Datums und ggf. Korrigieren

root@rescue ~ # date
Fri Feb  1 11:23:20 CET 2008

Download eines Stage3 Tarballs

root@rescue ~ # cd /mnt/gentoo
root@rescue /mnt/gentoo # links http://www.gentoo.org/main/en/mirrors.xml

Auspacken des Stage3 Tarballs

root@rescue /mnt/gentoo # tar xvjpf stage3-amd64-2007.0.tar.bz2

Download und Installieren von Portage

root@rescue /mnt/gentoo # links http://www.gentoo.org/main/en/mirrors.xml

Der Portage Tarball ist im Snapshots Unterverzeichnis zu finden

root@rescue /mnt/gentoo # tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr

Konfiguration der Compile Options

root@rescue /mnt/gentoo # vi /mnt/gentoo/etc/make.conf
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /etc/make.conf.example for a more detailed example.
CFLAGS="-march=athlon64 -O2 -msse3 -pipe"
CXXFLAGS="${CFLAGS}"
# This should not be changed unless you know exactly what you are doing.  You
# should probably be using a different stage, instead.
CHOST="x86_64-pc-linux-gnu"
MAKEOPTS="-j3"

Auswählen eines schnellen Mirrors

root@rescue /mnt/gentoo # mirrorselect -i -o >> /mnt/gentoo/etc/make.conf
root@rescue /mnt/gentoo # mirrorselect -i -r -o >> /mnt/gentoo/etc/make.conf

root@rescue /mnt/gentoo # cat !$
cat etc/make.conf
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /etc/make.conf.example for a more detailed example.
CFLAGS="-march=athlon64 -O2 -msse3 -pipe"
CXXFLAGS="${CFLAGS}"
# This should not be changed unless you know exactly what you are doing.  You
# should probably be using a different stage, instead.
CHOST="x86_64-pc-linux-gnu"
MAKEOPTS="-j3"
GENTOO_MIRRORS="http://gentoo.intergenia.de http://gentoo.mneisen.org/ http://pandemonium.tiscali.de/pub/gentoo/"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"

Kopieren der DNS Einstellungen

root@rescue /mnt/gentoo # cp -L /etc/resolv.conf /mnt/gentoo/etc/

Mounten der /proc und /dev Filesysteme

root@rescue /mnt/gentoo # mount -t proc none /mnt/gentoo/proc
root@rescue /mnt/gentoo # mount -o bind /dev /mnt/gentoo/dev

Betreten der neuen Umgebung mit chroot

root@rescue /mnt/gentoo # chroot /mnt/gentoo /bin/bash
rescue / # env-update
>>> Regenerating /etc/ld.so.cache...
rescue / # source /etc/profile
rescue / # export PS1="(chroot) $PS1"
(chroot) rescue / #

Konfiguration von Portage

(chroot) rescue / # emerge –-sync

Profile überprüfen mit:

(chroot) rescue / # ls -FGg /etc/make.profile
lrwxrwxrwx 1 50 Feb  1 10:30 /etc/make.profile -> ../usr/portage/profiles/default-linux/amd64/2007.0/

USE Variable konfigurieren:

(chroot) rescue / # nano -w /etc/make.conf

USE="-gnome -ipv6 -ldap -qt4 X a52 apache2 ctype encode exif flac ffmpeg gd gif jpeg jpeg2k kde libwww maildir mp3 mpeg mysql objc ogg opengl openntpd openssh pcre php posix png qt3 rtsp screen session shout snmp ssl stream theora tiff truetype unicode vhosts vlm vorbis vroot x264 xml"

Glibc Locales

(chroot) rescue / # nano -w /etc/locale.gen

en_US ISO-8859-1
en_US.UTF-8 UTF-8
#ja_JP.EUC-JP EUC-JP
#ja_JP.UTF-8 UTF-8
#ja_JP EUC-JP
#en_HK ISO-8859-1
#en_PH ISO-8859-1
de_DE ISO-8859-1
de_DE@euro ISO-8859-15
#es_MX ISO-8859-1
#fa_IR UTF-8
#fr_FR ISO-8859-1
#fr_FR@euro ISO-8859-15
#it_IT ISO-8859-1

(chroot) rescue / # locale-gen

Zeitzone setzen

(chroot) rescue / # cp /usr/share/zoneinfo/MET /etc/localtime

Kernel Sourcecode installieren

(chroot) rescue / # emerge gentoo-sources

Manuelle Kernelkonfiguration…

cd /usr/src/linux
make menuconfig
usw…

(chroot) rescue linux # make && make modules_install

(chroot) rescue linux # cp arch/x86_64/boot/bzImage /boot/kernel-2008-02-01-A

Konfiguration des Systems

(chroot) rescue linux # nano -w /etc/fstab
/dev/sda1               /boot           ext2            noauto,noatime  1 2
/dev/sda4               /               ext3            noatime         0 1
/dev/sda3               /tmp            ext2            noatime         0 1
/dev/sdb2               /opt            ext3            noatime         0 1
/dev/sda2               none            swap            sw              0 0
/dev/sdb1               none            swap            sw              0 0
#/dev/cdrom             /mnt/cdrom      audo            noauto,ro       0 0
#/dev/fd0               /mnt/floppy     auto            noauto          0 0
(chroot) rescue linux # nano -w /etc/conf.d/hostname

(chroot) rescue linux # nano -w /etc/conf.d/net

cat /etc/conf.d/net
# This blank configuration will automatically use DHCP for any net.*
# scripts in /etc/init.d.  To create a more complete configuration,
# please review /etc/conf.d/net.example and save your configuration
# in /etc/conf.d/net (this file :]!).
config_eth0=( "dhcp" )
dhcp_eth0="nodns nontp nonis"
(chroot) rescue linux # rc-update add net.eth0 default
 * net.eth0 added to runlevel default

(chroot) rescue linux # nano -w /etc/hosts
127.0.0.1       pegasus.dmsp.de pegasus localhost
(chroot) rescue linux # passwd
New UNIX password:
Retype new UNIX password:
passwd: password updated successfully

(chroot) rescue linux # nano -w /etc/rc.conf

(chroot) rescue linux # nano -w /etc/conf.d/clock

(set to UTC)

Installation von notwendigen Systemtools

(chroot) rescue linux # emerge syslog-ng
(chroot) rescue linux # rc-update add syslog-ng default

(chroot) rescue linux # emerge vixie-cron
(chroot) rescue linux # rc-update add vixie-cron default

(chroot) rescue linux # emerge dhcpcd

Bootloader installieren und konfigurieren

(chroot) rescue linux # emerge grub
(chroot) rescue linux # nano -w /boot/grub/grub.conf

cat /boot/grub/grub.conf
default 0
timeout 5

title  RegularKernel
root (hd0,0)
kernel /boot/kernel-2008-02-01-A root=/dev/sda4
(chroot) rescue linux # grep -v rootfs /proc/mounts > /etc/mtab

(chroot) rescue linux # grub --no-floppy
grub> root (hd0,0)    (Specify where your /boot partition resides)
grub> setup (hd0)     (Install GRUB in the MBR)
grub> quit            (Exit the GRUB shell)

Vorbereiten für Reboot und erstmaliges Remote-Einloggen ohne Rescue-System

(chroot) rescue linux # emerge openssh
(chroot) rescue linux # rc-update add sshd default

System rebooten

exit
cd
umount /mnt/gentoo/boot
umount /mnt/gentoo/tmp
umount /mnt/gentoo/dev
umount /mnt/gentoo/proc
umount /mnt/gentoo

reboot

Bei Problemen: Schnelleinstieg über das Rescue-System

mkdir /mnt/gentoo
mount /dev/sda4 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot
mkdir /mnt/gentoo/tmp
mount /dev/sda3 /mnt/gentoo/tmp
chmod 1777 /mnt/gentoo/tmp
chroot /mnt/gentoo /bin/bash
env-update
source /etc/profile
export PS1="(chroot) $PS1"

Restliches System nach der USE-Variable generieren

emerge --update --newuse --deep world



emerge mysql
emerge proftpd
emerge apache
emerge net-snmp
emerge icecast


Hinterlasse einen Kommentar