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 1580 2011-01-16 20:18:37Z 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 | grep oot
/dev/mapper/Casper-root on / type ext3 (rw,errors=remount-ro)
/dev/sda1 on /boot type ext3 (rw) # partition formatée exclue du gestionnaire LVM
# ls -1X /boot/
grub # répertoire configuration GRUB lost+found
config-2.6.32.2
initrd.img-2.6.32.2 # disque RAM initialisé au démarrage du système System.map-2.6.32.2 # carte des appels de fonctions vmlinuz-2.6.32.2 # partie monolithique du noyau config-2.6.30-2-amd64 # configuration du noyau distribuée avec le paquet initrd.img-2.6.30-2-amd64
System.map-2.6.30-2-amd64
vmlinuz-2.6.30-2-amd64

(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 $ make-kpkg --rootcmd fakeroot --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
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32.2 # noyau ajouté Found initrd image: /boot/initrd.img-2.6.32.2
Found linux image: /boot/vmlinuz-2.6.30-2-amd64 # noyau fourni par la distribution Found initrd image: /boot/initrd.img-2.6.30-2-amd64
done
  • Personnalisation de GRUB
# ll /etc/grub.d/
total 18K
-rwxr-xr-x 1 root root 3,4K janv. 1 00:49 00_header
-rwxr-xr-x 1 root root 1,4K déc. 10 00:47 05_debian_theme
-rwxr-xr-x 1 root root 3,6K déc. 14 15:05 10_linux
-rwxr-xr-x 1 root root 5,5K janv. 1 00:49 30_os-prober
-rwxr-xr-x 1 root root 214 sept. 12 15:47 40_custom
-rw-r--r-- 1 root root 483 mars 17 2009 README

(page 11)

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

(13/28)
Initialisation des processus
$ man init

(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 | grep 02:0e.0
02:0e.0 RAID bus controller: Dell PowerEdge Expandable RAID controller 5
  • Informations reconnues par le noyau
# less /var/log/kern.log
scsi0 : LSI SAS based MegaRAID driver
scsi 0:0:0:0: Direct-Access SEAGATE ST3500620SS MS07 PQ: 0 ANSI: 5
scsi 0:0:1:0: Direct-Access SEAGATE ST3500620SS MS07 PQ: 0 ANSI: 5
scsi 0:0:2:0: Direct-Access SEAGATE ST3500620SS MS07 PQ: 0 ANSI: 5
scsi 0:0:3:0: Direct-Access SEAGATE ST3500620SS MS07 PQ: 0 ANSI: 5
scsi 0:0:4:0: Direct-Access SEAGATE ST3500620SS MS07 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] 2927099904 512-byte hardware sectors: (1.49 TB/1.36 TiB)
  • Informations collectées
# udevadm info --query=all --name=/dev/sda
P: /devices/pci0000:00/0000:00:05.0/0000:01:00.0/0000:02:0e.0/host0/target0:2:0/0:2:0:0/block/sda
N: sda
W: 31
S: block/8:0
S: disk/by-id/scsi-360022190c6377400118c892518e63397
S: disk/by-id/wwn-0x60022190c6377400
S: disk/by-path/pci-0000:02:0e.0-scsi-0:2:0:0
...

(page 23)

(24/28)
Représentation des périphériques
# lspci | grep 0f:00.0
0f:00.0 Ethernet controller: Intel Corporation 82575GB Gigabit Network Connection (rev 02)
  • Informations reconnues par le noyau
# grep igb /var/log/kern.log
igb 0000:0f:00.0: Intel(R) Gigabit Ethernet Network Connection
igb 0000:0f:00.0: eth1: (PCIe:2.5Gb/s:Width x4) 00:1b:21:36:35:1c
igb 0000:0f:00.0: eth1: PBA No: d96950-006
igb 0000:0f:00.0: Using MSI-X interrupts. 4 rx queue(s), 4 tx queue(s)
  • Informations collectées
# udevadm info -a -p /sys/class/net/eth1
...
looking at device '/devices/pci0000:00/0000:00:04.0/0000:0c:00.0/0000:0d:04.0/0000:0f:00.0/net/eth1':
KERNEL=="eth1"
SUBSYSTEM=="net"
DRIVER==""
ATTR{addr_len}=="6"
...
ATTR{link_mode}=="0"
ATTR{address}=="00:1b:21:36:35:1c"
ATTR{broadcast}=="ff:ff:ff:ff:ff:ff"
...

(page 24)

(25/28)
Représentation des périphériques
$ cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x8086:0x10d6 (igb) <----- Identification composant SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:36:35:18", \ ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
# PCI device 0x8086:0x10d6 (igb) Adresse MAC --. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:36:35:1c", \ ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x10d6 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:36:35:1d", \ ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
^
Nom d'interface -----'

(page 25)

(26/28)
Chargement des modules
$ cat /etc/modprobe.d/ieee80211
options cfg80211 ieee80211_regdom=EU
$ lsmod |grep cfg80211
cfg80211 37856 2 iwl3945,mac80211
$ dmesg | grep cfg80211
cfg80211: Using static regulatory domain info
cfg80211: Regulatory domain: EU

(page 26)

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

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