Introduction
Installation de dhcp-3
Installation d'un serveur tftp
Configuration de pxelinux
Configuration du noyau
Configuration de busybox
Creation du système de fichiers
Vérifications

SERVEUR CLIENT boot sur le réseau <======== requête dhcp ====== ======== IP + pxelinux =====> <= demande noyau + initrd === ====== noyau + initrd ====> boot sur le noyau lancement du initrd <== demande du file system == === envoie du file system ==> lancement de init
apt-get install dhcp3-server # Ensuite il faut configurer ce serveur vim /etc/dhcp3/dhcpd.conf
# Le réseau à écouter : 192.168.81.0 avec le masque 255.255.255.0
subnet 192.168.81.0 netmask 255.255.255.0 {
# La passerelle (ici la machine qui tourne le serveur dchp)
option routers 192.168.81.1;
# On définit le groupe de machines
group {
# Tout le monde télécharge le fichier /tftpboot/conf/pxelinux.0 du serveur dhcp
filename "/tftpboot/conf/pxelinux.0";
# Pour chaque machine :
host troll2 {
# Si on reçoit une requête avec l'adresse mac : 00:e0:81:52:af:0a ...
hardware ethernet 00:e0:81:52:af:0a;
# on attribue l'ip 192.168.81.2
fixed-address 192.168.81.2;
}
host troll3 {
hardware ethernet 00:e0:81:52:a9:e5;
fixed-address 192.168.81.3;
}
# ...
# ...
# ...
host troll8 {
hardware ethernet 00:e0:81:52:ab:0b;
fixed-address 192.168.81.8;
}
}
}
apt-get install tftpd-hpa vim /etc/inetd.conf # Il faut que la ligne suivante soit présente. tftp dgram udp nowait root /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot
mkdir /tftpboot /etc/init.d/inetd stop /etc/init.d/inetd start # le restart ne marche pas tout le temps
tar jxvf syslinux-3.07.tar.bz2 mkdir /tftpboot/conf cp syslinux-3.07/pxelinux.0 /tftpboot/confMaintenant, il faut configurer pxelinux.
/tftpboot/conf/pxelinux.cfg/01-00-e0-81-52-af-0a /tftpboot/conf/pxelinux.cfg/C0A85102 /tftpboot/conf/pxelinux.cfg/C0A8510 /tftpboot/conf/pxelinux.cfg/C0A851 /tftpboot/conf/pxelinux.cfg/C0A85 /tftpboot/conf/pxelinux.cfg/C0A8 /tftpboot/conf/pxelinux.cfg/C0A /tftpboot/conf/pxelinux.cfg/C0 /tftpboot/conf/pxelinux.cfg/C /tftpboot/conf/pxelinux.cfg/default (C0A85102 = 192.168.81.2 en héxadécimal)Le contenu d'un fichier de configuration est le suivant :
DEFAULT Linux LABEL Linux KERNEL /linux-2.4.28 APPEND root=/dev/ram0 load_ramdisk=1 initrd=/initrd ramdisk_size=4096 init=linuxrc IPAPPEND 1Ce fichier de config va donc dire au client d'utilisé le noyau /tftpboot/conf/linux-2.4.28 puis le /tftpboot/conf/initrd situés sur le serveur dhcp/tftp
cp arch/i386/boot/bzImage /tftpboot/conf/linux-2.4.28
cd busybox make menuconfig # On met tout ce dont on va avoir besoin et on retire ce qui semble inutile # (en fait il n'est pas nécessaire de retirer grand chose) # Il faut penser à avoir au minimum : # sh mount echo cat pipe fdisk mkswap cd tar (avec l'option -z) gzip rm mv pivot_root exec # Activer l'option "Build BusyBox as a static binary (no shared libs)" # Retirer l'option tftp si elle est présente (ce n'est pas une bonne version) make make install
troll1:~/busybox-1.00/_install# ls -l lib -rwxr-xr-x 1 root root 90088 Jan 19 14:11 ld-2.3.2.so lrwxrwxrwx 1 root root 11 Jan 19 14:11 ld-linux.so.2 -> ld-2.3.2.so -rw-r--r-- 1 root root 1244016 Jan 19 14:11 libc-2.3.2.so lrwxrwxrwx 1 root root 13 Jan 19 14:11 libc.so.6 -> libc-2.3.2.so lrwxrwxrwx 1 root root 17 Jan 19 14:11 libcom_err.so.2 -> libcom_err.so.2.0 -rw-r--r-- 1 root root 5016 Jan 19 14:11 libcom_err.so.2.0 lrwxrwxrwx 1 root root 13 Jan 19 14:11 libe2p.so.2 -> libe2p.so.2.3 -rw-r--r-- 1 root root 14020 Jan 19 14:11 libe2p.so.2.3 lrwxrwxrwx 1 root root 16 Jan 19 14:11 libext2fs.so.2 -> libext2fs.so.2.4 -rw-r--r-- 1 root root 78428 Jan 19 14:11 libext2fs.so.2.4 lrwxrwxrwx 1 root root 14 Jan 19 14:11 libuuid.so.1 -> libuuid.so.1.2 -rw-r--r-- 1 root root 8712 Jan 19 14:11 libuuid.so.1.2
mkdir mnt mkdir mnt/newroot mkdir proc mkdir dev cd dev mknod hda b 3 0 mknod hda1 b 3 1 mknod hda2 b 3 1 mknod tty0 c 4 0 mknod tty1 c 4 1 mknod console c 5 1
ls -l dev/ total 0 crw-r--r-- 1 root root 5, 1 Jan 19 14:11 console brw-r--r-- 1 root root 3, 0 Jan 19 14:11 hda brw-r--r-- 1 root root 3, 1 Jan 19 14:11 hda1 brw-r--r-- 1 root root 3, 2 Jan 19 14:11 hda2 brw-r--r-- 1 root root 3, 3 Jan 19 14:11 hda3 brw-r--r-- 1 root root 3, 4 Jan 19 14:11 hda4 crw-r--r-- 1 root root 4, 0 Jan 19 14:11 tty0 crw-r--r-- 1 root root 4, 1 Jan 19 14:11 tty1
PATH=/bin:/sbin:/usr/bin:/usr/sbin mount -t proc proc /proc echo "***** Creation des partitions *****" cat /fdisk.file | fdisk /dev/hda fdisk -l /dev/hda echo "***** Creation du swap et du systeme de fichiers *****" mkswap /dev/hda1 mke2fs -j /dev/hda2 echo "***** Montage des partitions ******" mount /dev/hda2 /mnt/newroot cd /mnt/newroot echo "***** Recupretation du system de fichier *****" tftp 192.168.81.1 -c get /tftpboot/filesystem.tgz echo "***** Decompression *****" tar zxf filesystem.tgz echo "***** Modification du systeme de fichiers *****" rm -f filesystem.tgz rm -f /mnt/newroot/etc/network/interfaces rm -f /mnt/newroot/etc/rc2.d/S20dhcp3-server mv /mnt/newroot/etc/network/interfaces.client /mnt/newroot/etc/network/interfaces echo "***** Activating root *****" mount -t proc proc /mnt/newroot/proc pivot_root /mnt/newroot /mnt/newroot/oldroot cd / echo "***** Lancement du INIT *****" exec chroot . sh -c 'exec /sbin/init'
apt-get install cramfsprogs mkcramfs _install/ /tftpboot/conf/initrd
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp
127.0.0.1 localhost 129.175.7.81 clustroll 192.168.81.1 troll1 192.168.81.2 troll2 192.168.81.3 troll3 192.168.81.4 troll4 192.168.81.5 troll5 192.168.81.6 troll6 192.168.81.7 troll7 192.168.81.8 troll8
#!/bin/sh
ip_temp=`ifconfig eth0 | grep inet | awk -F":" '{print $2}' | awk -F" " '{print $1}'`
hostname_temp=`grep $ip_temp /etc/hosts | awk -F" " '{print $2}'`
`echo "$hostname_temp" > /etc/hostname`
`hostname $hostname_temp`
mkdir /oldroot
cd / tar --exclude=filesystem.tgz -lzcf filesystem.tgz . # --exclude=filesystem.tgz pour eviter de se compresser soit même et -l pour ne pas compresser le /proc cp filesystem.tgz /tftpboot
/
etc/
dhcp3/
dhcpd.conf // Configuration du serveur dhcp
hosts // Associations nom-ip
inetd.conf // service de tftp
network/
interfaces.client // Configuration du réseau des clients
rc2.d/
S99put_hostname // Moficidation du hostname
oldroot/ // Point de montage du pivot_root
tftpboot/
filesystem.tgz // Le futur système de fichier
conf/
initrd // L'inird fait avec busybox
vmlinuz // Le kernel
pxelinux.0 // Le boot loader
pxelinux.cfg/
C0A85102 // Fichiers de conf (IP en décimal)
C0A85103
...
default // Ou fichier de conf par défaut
tail -f /var/log/syslog