Debian logo [inetdoc.LINUX]




[inetdoc.LINUX]

http://www.linux-france.org/prj/inetdoc
Exploration GNU/Linux - Séance 6

Initialisation système & noyau Linux
Niveaux de démarrage
Chargement des pilotes de périphériques
images/ups.png

Philippe Latu
philippe.latu(at)linux-france.org
IUT 'A' Paul Sabatier - STRI

$Id: explore.seance.6.mgp 1243 2008-01-21 13:55:40Z latu $

(page 1)

(2/28)
Objectifs
(page 2)

(3/28)
Initialisation du système
(page 3)

(4/28)
Initialisation du système
(page 4)

(5/28)
Initialisation du système
$ mount
/dev/sda1 on /boot type ext3 (rw) # partition formatée exclue du gestionnaire LVM /dev/mapper/Master64-root on / type ext3 (rw,errors=remount-ro)
$ ls -1t /boot
grub # répertoire configuration GRUB initrd.img-2.6.22-3-amd64 # disque RAM initialisé au démarrage du système initrd.img-2.6.22-3-amd64.bak
lost+found
config-2.6.22-3-amd64 # configuration du noyau distribuée avec le paquet System.map-2.6.22-3-amd64 # carte des appels de fonctions vmlinuz-2.6.22-3-amd64 # partie monolithique du noyau

(page 5)

(6/28)
Initialisation du système
images/Anatomy-of-bzimage.png
(page 6)

(7/28)
Initialisation du système
$ mkdir initrd ; cd initrd
$ gzip -dc /boot/initrd.img-2.6.xx | cpio -idv
$ tree -L 1
.
|-- bin
|-- conf
|-- etc
|-- init
|-- lib ----------> modules
|-- lib64 `-- 2.6.xx
|-- sbin
`-- scripts

(page 7)

(8/28)
Initialisation du système
$ wget http://www.eu.kernel.org/pub/linux/\ kernel/v2.6/linux-2.6.xx.tar.bz2
$ mv linux-2.6.xx.tar.bz2 /usr/src/
$ cd /usr/src/
$ tar xf linux-2.6.xx.tar.bz2
$ ln -s linux-2.6.xx linux
$ cd linux
$ cp /boot/config-2.6.xx .config
$ make menuconfig # menus de configuration des fonctions du noyau $ fakeroot make-kpkg -initrd kernel_image
$ cd .. ; su
# dpkg -i linux-image-2.6.xx-10.00.Custom_amd64.deb

(page 8)

(9/28)
Initialisation du système
images/kernel-config.png
(page 9)

(10/28)
Initialisation du système
(page 10)

(11/28)
Initialisation du système
# update-grub -v
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /vmlinuz-2.6.23.14 # noyau ajouté Found kernel: /vmlinuz-2.6.22-3-amd64 # noyau fourni par la distribution Updating /boot/grub/menu.lst ... done

(page 11)

(12/28)
Initialisation du noyau
(page 12)

(13/28)
Initialisation des processus
(page 13)

(14/28)
Niveaux de démarrage - runlevels
0 halt
1 single user mode
2 multiuser with no network services exported
3 normal/full multiuser
4 reserved for local use, default is normal/full multiuser
5 multiuser with xdm or equivalent
6 reboot
# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now


(page 14)

(15/28)
Niveaux de démarrage - runlevels
force-reload|restart)
process_options
log_action_begin_msg "Reconfiguring network interfaces"
ifdown -a --exclude=lo || true
if ifup -a --exclude=lo; then
log_action_end_msg $?
else
log_action_end_msg $?
fi
;;

(page 15)

(16/28)
Niveaux de démarrage - runlevels
case "$1" in
start)
log_daemon_msg "Starting deferred execution scheduler" "atd"
start_daemon $DAEMON
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping deferred execution scheduler" "atd"
killproc $DAEMON
log_end_msg $?
;;
force-reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/atd {start|stop|restart|force-reload}"
exit 1
;;
esac

(page 16)

(17/28)
Niveaux de démarrage - runlevels
$ find /etc/rc?.d -type l -name "*acpid" -printf "%p "
/etc/rc0.d/K20acpid /etc/rc1.d/K20acpid \ /etc/rc2.d/S20acpid /etc/rc3.d/S20acpid /etc/rc4.d/S20acpid /etc/rc5.d/S20acpid \ /etc/rc6.d/K20acpid

(page 17)

(18/28)
Niveaux de démarrage - runlevels
images/kde-sysv.png
(page 18)

(19/28)
Chargement du noyau
(page 19)

(20/28)
Chargement des modules
$ apt-cache show module-init-tools
$ ls -lA /lib/modules/
  • Commandes usuelles
$ lsmod # liste les modules chargés en mémoire # modprobe -v <nom_du_module> # chargement d'un module + dépendances # modprobe -rv <nom_du_module> # déchargement d'un module

(page 20)

(21/28)
Représentation des périphériques
(page 21)

(22/28)
Représentation des périphériques
(page 22)

(23/28)
Représentation des périphériques
$ lspci
02:0e.0 RAID bus controller: Dell PowerEdge Expandable RAID controller 5
  • Informations reconnues par le noyau
$ dmesg |less
scsi 0:0:8:0: Enclosure DP BACKPLANE 1.00 PQ: 0 ANSI: 5
scsi 0:2:0:0: Direct-Access DELL PERC 5/i 1.03 PQ: 0 ANSI: 5
sd 0:2:0:0: [sda] 570949632 512-byte hardware sectors (292326 MB)
  • Informations collectées
$ udevinfo --query=all --name=/dev/sda
P: /block/sda
N: sda
S: disk/by-id/scsi-3600188b04f98ed000d54bae071fe76c6
S: disk/by-path/pci-0000:02:0e.0-scsi-0:2:0:0
E: ID_VENDOR=DELL
E: ID_MODEL=PERC_5i
E: ID_REVISION=1.03
E: ID_SERIAL=3600188b04f98ed000d54bae071fe76c6
E: ID_SERIAL_SHORT=600188b04f98ed000d54bae071fe76c6
E: ID_TYPE=disk
E: ID_BUS=scsi
E: ID_PATH=pci-0000:02:0e.0-scsi-0:2:0:0

(page 23)

(24/28)
Représentation des périphériques
$ lspci
0c:00.0 Ethernet controller: Intel Corporation 82572EI Gigabit Ethernet Controller (rev 06)
  • Informations reconnues par le noyau
$ dmesg |less
e1000: eth0: e1000_probe: Intel(R) PRO/1000 Network Connection
udev: renamed network interface eth0 to eth2
  • Informations collectées
$ udevinfo -a -p /sys/class/net/eth2
looking at device '/devices/pci0000:00/0000:00:04.0/0000:0c:00.0/net/eth2':
KERNEL=="eth2"
SUBSYSTEM=="net"
DRIVER==""
ATTR{weight}=="64"
ATTR{tx_queue_len}=="1000"
ATTR{flags}=="0x1002"
ATTR{mtu}=="1500"
ATTR{operstate}=="down"
ATTR{broadcast}=="ff:ff:ff:ff:ff:ff"
ATTR{address}=="00:15:17:19:9b:a9"
...

(page 24)

(25/28)
Représentation des périphériques
$ cat /etc/udev/rules.d/z25_persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, probably run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.
# PCI device 0x14e4:0x164c (bnx2)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:1a:a0:01:f0:32", NAME="eth0"
# PCI device 0x14e4:0x164c (bnx2)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:1a:a0:01:f0:30", NAME="eth1"
# PCI device 0x8086:0x107d (e1000) <----- Identification composant SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:15:17:19:9b:a9", NAME="eth2"
^ ^
Adresse MAC -----' Nom d'interface -----'

(page 25)

(26/28)
Chargement des modules
(page 26)

(27/28)
Chargement des modules
(page 27)

(28/28)
Synthèse
(page 28)