Dernière mise-à-jour : 2020/01/30 03:28
Au démarrage d'un système à base d'un processeur x86 ou x86-64, le premier programme exécuté a été traditionnellement le BIOS. Le BIOS a pour fonction de :
La première partie du gestionnaire d'amorçage est en règle générale placé dans le MBR du disque. Le format du MBR est le suivant :
Important : Il est à noter que la première partie du gestionnaire d'amorçage peut également être installé dans un PBR.
Depuis 2011, le BIOS est en train d'être remplacé par l'utilisation de l'UEFI (Unified Extensible Firmware Interface ou Interface micrologicielle extensible unifiée) issue du développement de l'EFI conçue par Intel pour les processeurs Itanium..
Sous EFI la première partie du gestionnaire de démarrage est un fichier ayant une extension .efi se trouvant dans un sous-répertoire au nom du système d'exploitation à lancer dans une partition appelée EFI System Partition ou ESP. Cette partition est normalement montée à /boot/efi sous Linux.
Pour que EFI fonctionne, le micrologiciel (firmware) d'EFI doit avoir connaissance de chaque système d'exploitation à démarrer.
Les systèmes utilisant des processeurs autre qu'un x86 ou x86-64 utilisent un logiciel tel OpenFirmware.
Des gestionnaires d'amorçage sous Linux, un se distingue comme étant le plus utilisé :
Cependant il en existe d'autres :
LILO (LInux LOader) est configuré par le fichier /etc/lilo.conf.
La commande lilo peut prendre une de plusieurs options. Les options les plus importantes sont :
Option | Description |
---|---|
-M | Permet d'écrire sur le MBR |
-d | Permet de réduire ou augmenter le temps d'attente avant le lancement du noyau par défaut |
-D | Permet de sélectionner un noyau par défaut en indiquant son label |
-u | Permet de désinstaller LILO |
-v | Permet d'activer le mode verbose |
-m | Permet de modifier le fichier map par défaut (/boot/map) |
-i | Permet de spécifier un nouveau fichier à utiliser comme secteur de boot (/boot/boot.b) |
-C | Permet de modifier le fichier de configuration par défaut |
-q | Permet de créer le fichier /boot/map qui contient l'emplacement des noyaux qui peuvent être booter |
Lors du démarrage, LILO permet d'identifier les éventuelles erreurs :
Affichage | Erreur |
---|---|
(rien) | Aucun morceau de LILO n'a été chargé. Soit LILO n'est pas installé, soit la partition sur laquelle son secteur d'amorce se trouve n'est pas active. |
L | Le premier morceau du chargeur d'amorce a été chargé et démarré, mais il ne peut charger le second morceau. Les codes d'erreur à deux chiffres indiquent le type de problème. (Voir également la section “Codes d'erreur disque”.) Ce cas indique en général une panne de périphérique ou une incohérence de géométrie (c'est à dire de mauvais paramètres disques). |
LI | Le premier morceau du chargeur d'amorce a pu charger le second morceau, mais n'a pas réussi à l'exécuter. Cela peut être causé par une incohérence de géométrie ou par le déplacement de /boot/boot.b sans lancer l'installateur de carte. |
LIL | Le second morceau du chargeur d'amorce a été démarré, mais il ne trouve pas la table de descripteurs dans le fichier carte. C'est en général dû à une panne de périphérique ou une incohérence de géométrie. |
LIL? | Le second morceau du chargeur d'amorce a été chargé à un adresse incorrecte. C'est en général causé par une subtile incohérence de géométrie, ou par le déplacement de /boot/boot.b sans lancer l'installateur de carte. |
LIL- | La table de descripteurs est corrompue. Cela peut être dû à une incohérence de géométrie ou au déplacement de /boot/map sans lancer l'installeur. |
LILO | Tous les éléments de LILO ont été correctement chargés. |
Si le BIOS signale une erreur lorsque LILO essaye de charger une image d'amorce, le code d'erreur correspondant est affiché. Ces codes vont de 0x00 à 0xbb. Reportez-vous au Guide Utilisateur de LILO pour leur explication.
Dans le cas où le gestionnaire d'amorçage grub n'est pas installé, il convient de saisir la commande suivante :
# grub-install /dev/périphérique [Entrée]
où périphérique est le nom du périphérique ou grub doit s'installer dans le MBR. Notez cependant que le MBR a une taille trop petite pour contenir tout le gestionnaire d'amorçage. Pour cette raison, le gestionnaire est divisé en deux. Le gestionnaire de niveau 1 est stocké dans le MBR et indique où se trouve le gestionnaire de niveau 2, c'est-à-dire le répertoire /boot.
Le gestionnaire de niveau 1 a pour seul but le lancement du gestionnaire de niveau 2. Le gestionnaire de niveau 2 charge le noyau en mémoire, monte l'image initrd et charge les modules nécessaires pendant que le noyau monte la partition racine / en lecture seule.
Important : Pour désinstaller grub du MBR, utilisez une disquette DOS pour démarrer la machine puis taper la commande suivante au prompt :
A> fdisk /mbr [Entrée]
grub se configure grâce au fichier /boot/grub/menu.lst. Pour visualiser ce fichier, il convient de saisir la commande suivante :
[root@centos6 ~]# cat /boot/grub/menu.lst # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/sda2 # initrd /initrd-[generic-]version.img #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS Linux (2.6.32-71.29.1.el6.i686) root (hd0,0) kernel /vmlinuz-2.6.32-71.29.1.el6.i686 ro root=UUID=e73735d6-c14b-4a40-8735-f34fc868da8a rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=fr-latin9 crashkernel=auto rhgb quiet initrd /initramfs-2.6.32-71.29.1.el6.i686.img title centos (2.6.32-71.el6.i686) root (hd0,0) kernel /vmlinuz-2.6.32-71.el6.i686 ro root=UUID=e73735d6-c14b-4a40-8735-f34fc868da8a rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=fr-latin9 crashkernel=auto rhgb quiet initrd /initramfs-2.6.32-71.el6.i686.img
Dans ce fichier, on peut constater la présence de certaines options :
Option | Explication |
---|---|
default=0 | Cette option désigne le numéro de l'entrée à charger par défaut. La valeur de 0 indique la première option commençant par le mot clef title |
timeout=5 | Cette option indique le délai en secondes après lequel l'entrée par défaut sera chargée. |
splashimage=(hd0,0)/grub/splash.xpm.gz | Cette option indique l'emplacement de l'image de fond du menu de GRUB Legacy |
hiddenmenu | Cette option cache le menu de GRUB Legacy pendant le chargement de l'entrée par défaut, sauf si l'utilisateur appuie sur une touche |
password=motdepasse | Cette option n'est présente que dans le cas où un mot de passe a été spécifié pour protéger GRUB Legacy |
title CentOS Linux (2.6.32-71.29.1.el6.i686) | Cette option indique le début d'une section de configuration d'une entrée pour un système d'exploitation ainsi que le nom qui apparaît dans le menu de GRUB Legacy |
root (hd0,0) | Cette option indique la partition contenant le noyau de Linux. Dans l'exemple hd0,0 indique la première partition du premier disque dur. Cette partition est ensuite montée en tant que /boot. |
kernel /vmlinuz-2.6.32-71.29.1.el6.i686 | Cette option indique le nom du noyau à charger pour démarrer la machine. Son chemin est relatif à la partition de démarrage (hd0,0). Certaines options peuvent être passées au noyau en les spécifiant en tant qu'arguments telles rhgb ou Red Hat Graphical Boot et quiet qui supprime les messages de démarrage qui apparaissent avant le lancement de l'animation graphique activée par l'option rhgb |
initrd | Cette option stipule l'emplacement du disque initial chargé en mémoire lors du démarrage. Son chemin est relatif à la partition de démarrage (hd0,0). |
Grub Legacy peut être protéger par un mot de passe en incluant la directive suivante dans le fichier /boot/grub/menu.lst :
password --md5 <mot de passe>
Le mot de passe doit être chiffré avec MD5 :
[root@centos6 ~]# grub-md5-crypt Password: Retype password: $1$VLOzG$ibdk0my4IHny/XtNIGRhv1
Editez ensuite le fichier /boot/grub/menu.lst :
[root@centos6 ~]# cat /boot/grub/menu.lst # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/sda2 # initrd /initrd-[generic-]version.img #boot=/dev/sda default=0 timeout=5 password --md5 $1$VLOzG$ibdk0my4IHny/XtNIGRhv1 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS (2.6.32-504.1.3.el6.i686) lock root (hd0,0) kernel /vmlinuz-2.6.32-504.1.3.el6.i686 ro root=UUID=b9f29672-c84e-4d3b-b132-189758a084eb rd_NO_LUKS rd_NO_MD LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=fr-latin9 rd_NO_LVM rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-504.1.3.el6.i686.img title CentOS (2.6.32-358.18.1.el6.i686) lock root (hd0,0) kernel /vmlinuz-2.6.32-358.18.1.el6.i686 ro root=UUID=b9f29672-c84e-4d3b-b132-189758a084eb rd_NO_LUKS rd_NO_MD LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=fr-latin9 rd_NO_LVM rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-358.18.1.el6.i686.img title CentOS (2.6.32-358.6.1.el6.i686) lock root (hd0,0) kernel /vmlinuz-2.6.32-358.6.1.el6.i686 ro root=UUID=b9f29672-c84e-4d3b-b132-189758a084eb rd_NO_LUKS rd_NO_MD LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=fr-latin9 rd_NO_LVM rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-358.6.1.el6.i686.img title CentOS (2.6.32-279.el6.i686) lock root (hd0,0) kernel /vmlinuz-2.6.32-279.el6.i686 ro root=UUID=b9f29672-c84e-4d3b-b132-189758a084eb rd_NO_LUKS rd_NO_MD LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=fr-latin9 rd_NO_LVM rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-279.el6.i686.img
Important : Notez l'addition de la ligne password –md5 $1$VLOzG$ibdk0my4IHny/XtNIGRhv1 ainsi que le mot clef lock sur une ligne située après chaque ligne commençant par title.
Lors du démarrage de GRUB Legacy, il est possible de voir son menu en appuyant sur n'importe quelle touche. Si GRUB Legacy a été protégé par un mot de passe, il convient d'appuyer sur la touche p puis de rentrer le mot de passe. A ce stade il est possible d'utiliser deux autres touches :
En mode édition notez l'utilisation des touches suivantes :
GRUB 2 est une ré-écriture complète de GRUB Legacy. Il apporte des améliorations, notamment GRUB 2 sait utiliser des partitions RAID et LVM.
Le lancement de GRUB 2 se fait en trois étapes :
Dans le cas où le gestionnaire d'amorçage GRUB 2 n'est pas installé, il convient de saisir la commande suivante :
# grub2-install /dev/périphérique [Entrée]
où périphérique est le nom du périphérique ou l'étape 1 de GRUB2 doit s'installer dans le MBR.
GRUB 2 lit ses entrées de menus à partir du fichier /boot/grub2/grub.cfg. Pour visualiser ce fichier, il convient de saisir la commande suivante :
[root@centos7 ~]# cat /boot/grub2/grub.cfg # # DO NOT EDIT THIS FILE # # It is automatically generated by grub2-mkconfig using templates # from /etc/grub.d and settings from /etc/default/grub # ### BEGIN /etc/grub.d/00_header ### set pager=1 if [ -s $prefix/grubenv ]; then load_env fi if [ "${next_entry}" ] ; then set default="${next_entry}" set next_entry= save_env next_entry set boot_once=true else set default="${saved_entry}" fi if [ x"${feature_menuentry_id}" = xy ]; then menuentry_id_option="--id" else menuentry_id_option="" fi export menuentry_id_option if [ "${prev_saved_entry}" ]; then set saved_entry="${prev_saved_entry}" save_env saved_entry set prev_saved_entry= save_env prev_saved_entry set boot_once=true fi function savedefault { if [ -z "${boot_once}" ]; then saved_entry="${chosen}" save_env saved_entry fi } function load_video { if [ x$feature_all_video_module = xy ]; then insmod all_video else insmod efi_gop insmod efi_uga insmod ieee1275_fb insmod vbe insmod vga insmod video_bochs insmod video_cirrus fi } terminal_output console if [ x$feature_timeout_style = xy ] ; then set timeout_style=menu set timeout=5 # Fallback normal timeout code in case the timeout_style feature is # unavailable. else set timeout=5 fi ### END /etc/grub.d/00_header ### ### BEGIN /etc/grub.d/10_linux ### menuentry 'CentOS Linux (3.10.0-229.4.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' e8d3bd48-1386-411c-9675-41c3f8f1a309 else search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 fi linux16 /vmlinuz-3.10.0-229.4.2.el7.x86_64 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet LANG=en_US.UTF-8 initrd16 /initramfs-3.10.0-229.4.2.el7.x86_64.img } menuentry 'CentOS Linux, with Linux 3.10.0-123.el7.x86_64' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' e8d3bd48-1386-411c-9675-41c3f8f1a309 else search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 fi linux16 /vmlinuz-3.10.0-123.el7.x86_64 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet LANG=en_US.UTF-8 initrd16 /initramfs-3.10.0-123.el7.x86_64.img } menuentry 'CentOS Linux, with Linux 0-rescue-a2feb9eb09b1488da0f23b99a66350f8' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-a2feb9eb09b1488da0f23b99a66350f8-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' { load_video insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' e8d3bd48-1386-411c-9675-41c3f8f1a309 else search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 fi linux16 /vmlinuz-0-rescue-a2feb9eb09b1488da0f23b99a66350f8 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet initrd16 /initramfs-0-rescue-a2feb9eb09b1488da0f23b99a66350f8.img } if [ "x$default" = 'CentOS Linux, with Linux 3.10.0-123.el7.x86_64' ]; then default='Advanced options for CentOS Linux>CentOS Linux, with Linux 3.10.0-123.el7.x86_64'; fi; ### END /etc/grub.d/10_linux ### ### BEGIN /etc/grub.d/20_linux_xen ### ### END /etc/grub.d/20_linux_xen ### ### BEGIN /etc/grub.d/20_ppc_terminfo ### ### END /etc/grub.d/20_ppc_terminfo ### ### BEGIN /etc/grub.d/30_os-prober ### ### END /etc/grub.d/30_os-prober ### ### BEGIN /etc/grub.d/40_custom ### # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. ### END /etc/grub.d/40_custom ### ### BEGIN /etc/grub.d/41_custom ### if [ -f ${config_directory}/custom.cfg ]; then source ${config_directory}/custom.cfg elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then source $prefix/custom.cfg; fi ### END /etc/grub.d/41_custom ###
root@debian8:~# cat /boot/grub/grub.cfg # # DO NOT EDIT THIS FILE # # It is automatically generated by grub-mkconfig using templates # from /etc/grub.d and settings from /etc/default/grub # ### BEGIN /etc/grub.d/00_header ### if [ -s $prefix/grubenv ]; then set have_grubenv=true load_env fi if [ "${next_entry}" ] ; then set default="${next_entry}" set next_entry= save_env next_entry set boot_once=true else set default="0" fi if [ x"${feature_menuentry_id}" = xy ]; then menuentry_id_option="--id" else menuentry_id_option="" fi export menuentry_id_option if [ "${prev_saved_entry}" ]; then set saved_entry="${prev_saved_entry}" save_env saved_entry set prev_saved_entry= save_env prev_saved_entry set boot_once=true fi function savedefault { if [ -z "${boot_once}" ]; then saved_entry="${chosen}" save_env saved_entry fi } function load_video { if [ x$feature_all_video_module = xy ]; then insmod all_video else insmod efi_gop insmod efi_uga insmod ieee1275_fb insmod vbe insmod vga insmod video_bochs insmod video_cirrus fi } if [ x$feature_default_font_path = xy ] ; then font=unicode else insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi font="/usr/share/grub/unicode.pf2" fi if loadfont $font ; then set gfxmode=auto load_video insmod gfxterm set locale_dir=$prefix/locale set lang=en_US insmod gettext fi terminal_output gfxterm if [ "${recordfail}" = 1 ] ; then set timeout=-1 else if [ x$feature_timeout_style = xy ] ; then set timeout_style=menu set timeout=5 # Fallback normal timeout code in case the timeout_style feature is # unavailable. else set timeout=5 fi fi ### END /etc/grub.d/00_header ### ### BEGIN /etc/grub.d/05_debian_theme ### insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi insmod png if background_image /usr/share/images/desktop-base/lines-grub.png; then set color_normal=white/black set color_highlight=black/white else set menu_color_normal=cyan/blue set menu_color_highlight=white/blue fi ### END /etc/grub.d/05_debian_theme ### ### BEGIN /etc/grub.d/10_linux ### function gfxmode { set gfxpayload="${1}" } set linux_gfx_mode= export linux_gfx_mode menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0fc7a234-259a-416b-b674-51eedfb1823b' { load_video insmod gzio if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi echo 'Loading Linux 3.16.0-4-686-pae ...' linux /boot/vmlinuz-3.16.0-4-686-pae root=UUID=0fc7a234-259a-416b-b674-51eedfb1823b ro initrd=/install/gtk/initrd.gz quiet echo 'Loading initial ramdisk ...' initrd /boot/initrd.img-3.16.0-4-686-pae } submenu 'Advanced options for Debian GNU/Linux' $menuentry_id_option 'gnulinux-advanced-0fc7a234-259a-416b-b674-51eedfb1823b' { menuentry 'Debian GNU/Linux, with Linux 3.16.0-4-686-pae' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-4-686-pae-advanced-0fc7a234-259a-416b-b674-51eedfb1823b' { load_video insmod gzio if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi echo 'Loading Linux 3.16.0-4-686-pae ...' linux /boot/vmlinuz-3.16.0-4-686-pae root=UUID=0fc7a234-259a-416b-b674-51eedfb1823b ro initrd=/install/gtk/initrd.gz quiet echo 'Loading initial ramdisk ...' initrd /boot/initrd.img-3.16.0-4-686-pae } menuentry 'Debian GNU/Linux, with Linux 3.16.0-4-686-pae (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-4-686-pae-recovery-0fc7a234-259a-416b-b674-51eedfb1823b' { load_video insmod gzio if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi echo 'Loading Linux 3.16.0-4-686-pae ...' linux /boot/vmlinuz-3.16.0-4-686-pae root=UUID=0fc7a234-259a-416b-b674-51eedfb1823b ro single initrd=/install/gtk/initrd.gz echo 'Loading initial ramdisk ...' initrd /boot/initrd.img-3.16.0-4-686-pae } menuentry 'Debian GNU/Linux, with Linux 3.16.0-4-586' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-4-586-advanced-0fc7a234-259a-416b-b674-51eedfb1823b' { load_video insmod gzio if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi echo 'Loading Linux 3.16.0-4-586 ...' linux /boot/vmlinuz-3.16.0-4-586 root=UUID=0fc7a234-259a-416b-b674-51eedfb1823b ro initrd=/install/gtk/initrd.gz quiet echo 'Loading initial ramdisk ...' initrd /boot/initrd.img-3.16.0-4-586 } menuentry 'Debian GNU/Linux, with Linux 3.16.0-4-586 (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-4-586-recovery-0fc7a234-259a-416b-b674-51eedfb1823b' { load_video insmod gzio if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi echo 'Loading Linux 3.16.0-4-586 ...' linux /boot/vmlinuz-3.16.0-4-586 root=UUID=0fc7a234-259a-416b-b674-51eedfb1823b ro single initrd=/install/gtk/initrd.gz echo 'Loading initial ramdisk ...' initrd /boot/initrd.img-3.16.0-4-586 } } ### END /etc/grub.d/10_linux ### ### BEGIN /etc/grub.d/20_linux_xen ### ### END /etc/grub.d/20_linux_xen ### ### BEGIN /etc/grub.d/20_memtest86+ ### menuentry "Memory test (memtest86+)" { insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi linux16 /boot/memtest86+.bin } menuentry "Memory test (memtest86+, serial console 115200)" { insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi linux16 /boot/memtest86+.bin console=ttyS0,115200n8 } menuentry "Memory test (memtest86+, experimental multiboot)" { insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi multiboot /boot/memtest86+_multiboot.bin } menuentry "Memory test (memtest86+, serial console 115200, experimental multiboot)" { insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi multiboot /boot/memtest86+_multiboot.bin console=ttyS0,115200n8 } ### END /etc/grub.d/20_memtest86+ ### ### BEGIN /etc/grub.d/30_os-prober ### ### END /etc/grub.d/30_os-prober ### ### BEGIN /etc/grub.d/30_uefi-firmware ### ### END /etc/grub.d/30_uefi-firmware ### ### BEGIN /etc/grub.d/40_custom ### # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. ### END /etc/grub.d/40_custom ### ### BEGIN /etc/grub.d/41_custom ### if [ -f ${config_directory}/custom.cfg ]; then source ${config_directory}/custom.cfg elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then source $prefix/custom.cfg; fi ### END /etc/grub.d/41_custom ###
Notez que ce fichier ne doit pas être modifié manuellement. En effet, il est généré par la commande grub2-mkconfig sous RHEL/CentOS 7 et par la commande update-grub ou la commande grub-mkconfig sous Debian. Les commandes grub2-mkconfig et grub-mkconfig prennent en argument l'emplacement du fichier destination, par exemple :
Lors de l'exécution de la commande grub2-mkconfig, update-grub ou grub-mkconfig, plusieurs fichiers sont lus :
[root@centos7 ~]# cat /boot/grub2/device.map # this device map was generated by anaconda (hd0) /dev/sda (hd1) /dev/sda
root@debian8:~# cat /boot/grub/device.map cat: /boot/grub/device.map: No such file or directory root@debian8:~# which grub-mkdevicemap /usr/sbin/grub-mkdevicemap root@debian8:~# grub-mkdevicemap root@debian8:~# cat /boot/grub/device.map (hd0) /dev/disk/by-id/ata-VBOX_HARDDISK_VB823e2981-6120fc97
Ce fichier contient la configuration par défaut des paramètres de GRUB 2 :
root@debian:~# cat /etc/default/grub # If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. GRUB_DEFAULT=0 GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet" GRUB_CMDLINE_LINUX="" # Uncomment to enable BadRAM filtering, modify to suit your needs # This works with Linux (no patch required) and with any kernel that obtains # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" # Uncomment to disable graphical terminal (grub-pc only) #GRUB_TERMINAL=console # The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command `vbeinfo' #GRUB_GFXMODE=640x480 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux #GRUB_DISABLE_LINUX_UUID=true # Uncomment to disable generation of recovery mode menu entries #GRUB_DISABLE_LINUX_RECOVERY="true" # Uncomment to get a beep at grub start #GRUB_INIT_TUNE="480 440 1"
root@debian8:~# cat /etc/default/grub # If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' GRUB_DEFAULT=0 GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet" GRUB_CMDLINE_LINUX="initrd=/install/gtk/initrd.gz" # Uncomment to enable BadRAM filtering, modify to suit your needs # This works with Linux (no patch required) and with any kernel that obtains # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" # Uncomment to disable graphical terminal (grub-pc only) #GRUB_TERMINAL=console # The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command `vbeinfo' #GRUB_GFXMODE=640x480 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux #GRUB_DISABLE_LINUX_UUID=true # Uncomment to disable generation of recovery mode menu entries #GRUB_DISABLE_RECOVERY="true" # Uncomment to get a beep at grub start #GRUB_INIT_TUNE="480 440 1"
Important : Notez que toute modification de ce fichier nécessite l'exécution de la commande grub2-mkconfig sous RHEL/CentOS 7 ou grub-mkconfig / update-grub sous Debian pour que les modifications soient prises en compte.
Dans ce fichier les directives sont :
Directive | Description |
---|---|
GRUB_DEFAULT | Entrée du menu sélectionner par défaut |
GRUB_TIMEOUT | Durée de l'affichage du menu avant le démarrage en utilisant la valeur de GRUB_DEFAULT |
GRUB_DISTRIBUTOR | Ligne de commande qui génère le texte de l'entrée |
GRUB_CMDLINE_LINUX_DEFAULT | Paramètres passés au noyau lors d'un démarrage normal (Hors donc le mode secours) |
GRUB_CMDLINE_LINUX | Paramètres passés au noyau peu importe le type de démarrage |
GRUB_TERMINAL | Si non commentée, cette directive désactive le démarrage graphique |
GRUB_GFXMODE | Indique la résolution utilisée lors d'un démarrage graphique |
GRUB_DISABLE_LINUX_UUID | Si true, cette directive empêche l'utilisation de l'UUID de la partition |
GRUB_DISABLE_LINUX_RECOVERY | Si true, cette directive empêche la génération des entrées en mode recovery |
GRUB_INIT_TUNE | Permet d'obtenir un beep au démarrage de GRUB 2 |
GRUB_BADRAM | Permet de spécifier de la mémoire défaillante |
Les fichiers de ce répertoire sont exécutés dans l'ordre alphanumérique et servent à construire les menus de GRUB 2 :
[root@centos7 ~]# ls -l /etc/grub.d total 68 -rwxr-xr-x. 1 root root 8702 Mar 26 09:27 00_header -rwxr-xr-x. 1 root root 992 Oct 17 2014 00_tuned -rwxr-xr-x. 1 root root 10114 Mar 26 09:27 10_linux -rwxr-xr-x. 1 root root 10275 Mar 26 09:27 20_linux_xen -rwxr-xr-x. 1 root root 2559 Mar 26 09:27 20_ppc_terminfo -rwxr-xr-x. 1 root root 11169 Mar 26 09:27 30_os-prober -rwxr-xr-x. 1 root root 214 Mar 26 09:27 40_custom -rwxr-xr-x. 1 root root 216 Mar 26 09:27 41_custom -rw-r--r--. 1 root root 483 Mar 26 09:27 README
root@debian8:~# ls -l /etc/grub.d total 76 -rwxr-xr-x 1 root root 9424 Mar 23 2015 00_header -rwxr-xr-x 1 root root 6058 Mar 23 2015 05_debian_theme -rwxr-xr-x 1 root root 12261 Mar 23 2015 10_linux -rwxr-xr-x 1 root root 11082 Mar 23 2015 20_linux_xen -rwxr-xr-x 1 root root 1570 Sep 10 2014 20_memtest86+ -rwxr-xr-x 1 root root 11692 Mar 23 2015 30_os-prober -rwxr-xr-x 1 root root 1416 Mar 23 2015 30_uefi-firmware -rwxr-xr-x 1 root root 214 Mar 23 2015 40_custom -rwxr-xr-x 1 root root 216 Mar 23 2015 41_custom -rw-r--r-- 1 root root 483 Mar 23 2015 README
Pour configurer l'authentification sous GRUB 2, il faut créer le fichier /etc/grub.d/01_users :
[root@centos7 ~]# touch /etc/grub.d/01_users [root@centos7 ~]# chmod 755 /etc/grub.d/01_users
root@debian8:~# touch /etc/grub.d/01_users root@debian8:~# chmod 755 /etc/grub.d/01_users
Créez deux mots de passe hashés au format PBKDF2 en utilisant la commande grub2-mkpasswd-pbkdf2 sous RHEL/CentOS ou la commande grub-mkpasswd-pbkdf2 sous Debian :
[root@centos7 ~]# grub2-mkpasswd-pbkdf2 Enter password: pass123 Reenter password: pass123 PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.0298C1C613A451C46FBC95BB2AC7A41BCEC1C61512EF785BD81E3B65DFF9D57ED4ADF8906C3EF33C22C06FBDD366E1C118FC41110BD646A4D49EF86EFD0573BF.E14A45900096D773BE99BEA9AB8D4FA81431458952798B997D4FC9E0850426F6798979371B8EBD331DB33AE8FEAE25E6773156D42F21B884DBA405546782B3BD [root@centos7 ~]# grub2-mkpasswd-pbkdf2 Enter password: pass456 Reenter password: pass456 PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.161D4183DC832357403296ED05961FCF494AED9E20DC21C84EA89085EB9EF5AAE4C7D4A276AA5CC21F9C224B2ECA010B915B4830E9648A7398EB4A91E7E3D252.8277512B849FF727FDD0716D1D4CDC6B92E53918F665282E02133AAD1046EB10273A2BC70D76558FFC34A0C0C8BE5132E4C4C02C7C9C1A567BD5365D77350FCF
root@debian8:~# grub-mkpasswd-pbkdf2 Enter password: pass123 Reenter password: pass123 PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.270AE83E768097679495D221C76D2052E6493B7787E374A7BF6EFFC93E375427866E34C75E668778FAF795B19E38FAA5C864A86F1372ECBC1E559E546AF11D71.64C6E790267D3B9B84CF4DFA062A64ECAB4C8831AA80D5FA210C6886C4B1ED96155D66B0A90F4C6FC32CE59D8FE67E0A465E829E39E3B1BAE180C31C547BBABE root@debian8:~# grub-mkpasswd-pbkdf2 Enter password: pass456 Reenter password: pas456 PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.79F2080FA9C06BE4FD5872AD20AA36D760EC5409C4E01238C01B237B701E7C32A119AF3872D612F6E39D5472E727F1E6FD4CDFEC03D49ABA04BDEB61868DB754.A1E75121775C691A1060B1B206FCECFA5F8060F5395E5D58F862EB3B8E356148414FF99E0B43935B2EF89D312A611CB8BD8134DB4FFDCAD995D69992AE660750
Editez le fichier /etc/grub.d/01_users ainsi :
#!/bin/sh -e cat <<EOF set superusers="root" password_pbkdf2 root grub.pbkdf2.sha512.10000.0298C1C613A451C46FBC95BB2AC7A41BCEC1C61512EF785BD81E3B65DFF9D57ED4ADF8906C3EF33C22C06FBDD366E1C118FC41110BD646A4D49EF86EFD0573BF.E14A45900096D773BE99BEA9AB8D4FA81431458952798B997D4FC9E0850426F6798979371B8EBD331DB33AE8FEAE25E6773156D42F21B884DBA405546782B3BD password_pbkdf2 trainee grub.pbkdf2.sha512.10000.161D4183DC832357403296ED05961FCF494AED9E20DC21C84EA89085EB9EF5AAE4C7D4A276AA5CC21F9C224B2ECA010B915B4830E9648A7398EB4A91E7E3D252.8277512B849FF727FDD0716D1D4CDC6B92E53918F665282E02133AAD1046EB10273A2BC70D76558FFC34A0C0C8BE5132E4C4C02C7C9C1A567BD5365D77350FCF EOF
#!/bin/sh -e cat <<EOF set superusers="root" password_pbkdf2 root grub.pbkdf2.sha512.10000.270AE83E768097679495D221C76D2052E6493B7787E374A7BF6EFFC93E375427866E34C75E668778FAF795B19E38FAA5C864A86F1372ECBC1E559E546AF11D71.64C6E790267D3B9B84CF4DFA062A64ECAB4C8831AA80D5FA210C6886C4B1ED96155D66B0A90F4C6FC32CE59D8FE67E0A465E829E39E3B1BAE180C31C547BBABE password_pbkdf2 trainee grub.pbkdf2.sha512.10000.79F2080FA9C06BE4FD5872AD20AA36D760EC5409C4E01238C01B237B701E7C32A119AF3872D612F6E39D5472E727F1E6FD4CDFEC03D49ABA04BDEB61868DB754.A1E75121775C691A1060B1B206FCECFA5F8060F5395E5D58F862EB3B8E356148414FF99E0B43935B2EF89D312A611CB8BD8134DB4FFDCAD995D69992AE660750 EOF
Il est aussi possible d'utiliser des mots de passe non cryptés. Modifiez donc le fichier /etc/grub.d/01_users ainsi :
#!/bin/sh -e cat <<EOF set superusers="root" password root fenestros password trainee trainee EOF
Ouvrez maintenant le fichier /boot/grub/grub.cfg et copier le premier menuentry de la section /etc/grub.d/10_linux :
menuentry 'CentOS Linux (3.10.0-229.4.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' e8d3bd48-1386-411c-9675-41c3f8f1a309 else search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 fi linux16 /vmlinuz-3.10.0-229.4.2.el7.x86_64 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet LANG=en_US.UTF-8 initrd16 /initramfs-3.10.0-229.4.2.el7.x86_64.img }
menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0fc7a234-259a-416b-b674-51eedfb1823b' { load_video insmod gzio if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi echo 'Loading Linux 3.16.0-4-686-pae ...' linux /boot/vmlinuz-3.16.0-4-686-pae root=UUID=0fc7a234-259a-416b-b674-51eedfb1823b ro initrd=/install/gtk/initrd.gz quiet echo 'Loading initial ramdisk ...' initrd /boot/initrd.img-3.16.0-4-686-pae }
Collez maintenant ce menuentry dans le fichier /etc/grub.d/40_custom :
#!/bin/sh exec tail -n +3 $0 # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. menuentry 'CentOS Linux (3.10.0-229.4.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' e8d3bd48-1386-411c-9675-41c3f8f1a309 else search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 fi linux16 /vmlinuz-3.10.0-229.4.2.el7.x86_64 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet LANG=en_US.UTF-8 initrd16 /initramfs-3.10.0-229.4.2.el7.x86_64.img }
#!/bin/sh exec tail -n +3 $0 # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0fc7a234-259a-416b-b674-51eedfb1823b' { load_video insmod gzio if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi echo 'Loading Linux 3.16.0-4-686-pae ...' linux /boot/vmlinuz-3.16.0-4-686-pae root=UUID=0fc7a234-259a-416b-b674-51eedfb1823b ro initrd=/install/gtk/initrd.gz quiet echo 'Loading initial ramdisk ...' initrd /boot/initrd.img-3.16.0-4-686-pae }
Modifier le debut du menuentry ainsi :
menuentry 'CentOS Linux (3.10.0-229.4.2.el7.x86_64) 7 (Core) pour TRAINEE' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' --users trainee {
menuentry 'Debian GNU/Linux pour TRAINEE' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0fc7a234-259a-416b-b674-51eedfb1823b' --users trainee {
Sous RHEL/CentOS, lancez la commande grub2-mkconfig -o /boot/grub2/grub.cfg. Sous Debian, lancez la commande grub-mkconfig -o /boot/grub/grub.cfg :
[root@centos7 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-229.4.2.el7.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-a2feb9eb09b1488da0f23b99a66350f8 Found initrd image: /boot/initramfs-0-rescue-a2feb9eb09b1488da0f23b99a66350f8.img done
root@debian8:~# grub-mkconfig -o /boot/grub/grub.cfg Generating grub configuration file ... Found background image: /usr/share/images/desktop-base/desktop-grub.png Found linux image: /boot/vmlinuz-3.16.0-4-686-pae Found initrd image: /boot/initrd.img-3.16.0-4-686-pae Found linux image: /boot/vmlinuz-3.16.0-4-586 Found initrd image: /boot/initrd.img-3.16.0-4-586 Found memtest86+ image: /boot/memtest86+.bin Found memtest86+ multiboot image: /boot/memtest86+_multiboot.bin done
En examinant le fichier /boot/grub2/grub.cfg ou /boot/grub/grub.cfg on doit pouvoir constater la présence de la section /etc/grub.d/40_custom :
... ### BEGIN /etc/grub.d/40_custom ### # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. menuentry 'CentOS Linux (3.10.0-229.4.2.el7.x86_64) 7 (Core) pour TRAINEE' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' --users trainee { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' e8d3bd48-1386-411c-9675-41c3f8f1a309 else search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 fi linux16 /vmlinuz-3.10.0-229.4.2.el7.x86_64 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet LANG=en_US.UTF-8 initrd16 /initramfs-3.10.0-229.4.2.el7.x86_64.img } ### END /etc/grub.d/40_custom ### ...
... ### BEGIN /etc/grub.d/40_custom ### # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. menuentry 'Debian GNU/Linux pour TRAINEE' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0fc7a234-259a-416b-b674-51eedfb1823b' --users trainee { load_video insmod gzio if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi echo 'Loading Linux 3.16.0-4-686-pae ...' linux /boot/vmlinuz-3.16.0-4-686-pae root=UUID=0fc7a234-259a-416b-b674-51eedfb1823b ro initrd=/install/gtk/initrd.gz quiet echo 'Loading initial ramdisk ...' initrd /boot/initrd.img-3.16.0-4-686-pae } ### END /etc/grub.d/40_custom ### ...
A faire : Redémarrez votre VM et choisissez l'entrée de GRUB 2 issue du fichier /etc/grub.d/40_custom puis constatez que GRUB 2 demande un nom d'utilisateur ainsi qu'un mot de passe quand vous voulez éditer une entrée de GRUB 2.
Lors du démarrage de GRUB 2, trois actions sont possibles à partir du menu :
En mode édition notez l'utilisation des touches suivantes :
Un fichier Initramfs INITial Ram File System est une image d'un système minimal initialisée au démarrage du système.
Ce fichier utilise le système de fichier cramFS qui est un système de fichier compressé au format gzip et archivé via cpio.
L'image est chargée en mémoire vive et permet ainsi d'avoir un système minimal pouvant ensuite charger le système de fichier principal.
Pour examiner une image initramfs, il convient d'abord de la copier vers /tmp et de la décompresser :
[root@centos6 ~]# cp /boot/initramfs-2.6.32-71.29.1.el6.i686.img /tmp/custom.gz [root@centos6 ~]# gunzip /tmp/custom.gz
Ensuite il convient d'extraire l'image grâce à la commande cpio :
[root@centos6 ~]# cd /tmp [root@centos6 tmp]# mkdir initrd [root@centos6 tmp]# cd initrd [root@centos6 initrd]# cpio -cid -I ../custom 59631 blocs
Installez maintenant le paquet tree :
[root@centos6 initrd]# yum install tree Loaded plugins: fastestmirror, refresh-packagekit Loading mirror speeds from cached hostfile * atomic: www3.atomicorp.com * base: centos.crazyfrogs.org * epel: ftp.astral.ro * extras: centos.crazyfrogs.org * updates: centos.crazyfrogs.org Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package tree.i686 0:1.5.3-2.el6 set to be updated --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: tree i686 1.5.3-2.el6 base 36 k Transaction Summary ================================================================================ Install 1 Package(s) Upgrade 0 Package(s) Total download size: 36 k Installed size: 63 k Is this ok [y/N]: y Downloading Packages: tree-1.5.3-2.el6.i686.rpm | 36 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : tree-1.5.3-2.el6.i686 1/1 Installed: tree.i686 0:1.5.3-2.el6 Complete!
Utilisez maintenant la commande tree pour examiner le contenu de l'image :
[root@centos6 initrd]# tree | more . ├── bin │ ├── basename │ ├── cat │ ├── cp │ ├── dash │ ├── dd │ ├── dmesg │ ├── grep │ ├── gzip │ ├── ln │ ├── loadkeys │ ├── ls │ ├── mkdir │ ├── mknod │ ├── mount │ ├── mv │ ├── plymouth │ ├── plymouthd │ ├── readlink │ ├── rm │ ├── sed │ ├── setfont │ ├── sh -> dash │ ├── sleep │ ├── umount │ └── uname ├── cmdline --Plus--
Comme vous pouvez le constater, l'image contient une arborescence Linux minimaliste :
[root@centos6 initrd]# ls bin dev emergency init initqueue-finished lib pre-pivot pre-udev sbin sysroot usr cmdline dracut-004-33.2.el6_0 etc initqueue initqueue-settled mount pre-trigger proc sys tmp var
A faire : Utilisez le manuel de la commande cpio pour comprendre les options utilisées.
Le script init est lancé lors du chargement de l'image :
[root@centos6 initrd]# more init #!/bin/sh # # Licensed under the GPLv2 # # Copyright 2008-2009, Red Hat, Inc. # Harald Hoyer <harald@redhat.com> # Jeremy Katz <katzj@redhat.com> wait_for_loginit() { if getarg rdinitdebug; then set +x exec 0<>/dev/console 1<>/dev/console 2<>/dev/console # wait for loginit i=0 while [ $i -lt 10 ]; do j=$(jobs) [ -z "$j" ] && break [ -z "${j##*Running*}" ] || break sleep 0.1 i=$(($i+1)) done [ $i -eq 10 ] && kill %1 >/dev/null 2>&1 while pidof -x /sbin/loginit >/dev/null 2>&1; do for pid in $(pidof -x /sbin/loginit); do kill $HARD $pid >/dev/null 2>&1 done --Plus--(8%)
A faire : Passez en revue le contenu du script.
La commande dracut permet de créer facilement une image initramfs. Les options de la commande sont :
[root@centos6 initrd]# dracut --help Usage: /sbin/dracut [OPTION]... <initramfs> <kernel-version> Creates initial ramdisk images for preloading modules -f, --force Overwrite existing initramfs file. -m, --modules [LIST] Specify a space-separated list of dracut modules to call when building the initramfs. Modules are located in /usr/share/dracut/modules.d. -o, --omit [LIST] Omit a space-separated list of dracut modules. -a, --add [LIST] Add a space-separated list of dracut modules. -d, --drivers [LIST] Specify a space-separated list of kernel modules to exclusively include in the initramfs. --add-drivers [LIST] Specify a space-separated list of kernel modules to add to the initramfs. --filesystems [LIST] Specify a space-separated list of kernel filesystem modules to exclusively include in the generic initramfs. -k, --kmoddir [DIR] Specify the directory, where to look for kernel modules --fwdir [DIR] Specify additional directories, where to look for firmwares, separated by : --kernel-only Only install kernel drivers and firmware files --no-kernel Do not install kernel drivers and firmware files --strip Strip binaries in the initramfs --nostrip Do not strip binaries in the initramfs (default) --mdadmconf Include local /etc/mdadm.conf --nomdadmconf Do not include local /etc/mdadm.conf --lvmconf Include local /etc/lvm/lvm.conf --nolvmconf Do not include local /etc/lvm/lvm.conf -h, --help This message --debug Output debug information of the build process -v, --verbose Verbose output during the build process -c, --conf [FILE] Specify configuration file to use. Default: /etc/dracut.conf -l, --local Local mode. Use modules from the current working directory instead of the system-wide installed in /usr/share/dracut/modules.d. Useful when running dracut from a git checkout. -H, --hostonly Host-Only mode: Install only what is needed for booting the local host instead of a generic host. -i, --include [SOURCE] [TARGET] Include the files in the SOURCE directory into the Target directory in the final initramfs. -I, --install [LIST] Install the space separated list of files into the initramfs.
Le fichier de configuration de dracut est /etc/dracut.conf. Editez ce fichier pour spécifier des modules noyau supplémentaires à inclure dans le fichier image générée :
[root@centos6 initrd]# cat /etc/dracut.conf # Sample dracut config file # Specific list of dracut modules to use #dracutmodules+="" # Dracut modules to omit #omit_dracutmodules+="" # Dracut modules to add to the default #add_dracutmodules+="" # additional kernel modules to the default add_drivers+="ehci-hcd ohci-hcd usb-storage scsi_mod sd_mod" # list of kernel filesystem modules to be included in the generic initramfs #filesystems+="" # build initrd only to boot current hardware #hostonly="yes" # # install local /etc/mdadm.conf mdadmconf="yes" # install local /etc/lvm/lvm.conf lvmconf="yes"
Exécutez maintenant la commande suivante afin de générer le fichier usbinitramfs :
# dracut -v usbinitramfs [Entrée]
Notez la présence de votre nouvelle image /tmp/initrd/usbinitramfs.
Déplacez votre fichier usbinitramfs au répertoire /boot :
[root@centos6 initrd]# mv usbinitramfs /boot
Editez maintenant votre fichier /boot/grub/menu.lst et ajoutez une nouvelle section qui utilise votre usbinitramfs.
... splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS Linux (usbinitramfs) root (hd0,0) kernel /vmlinuz-2.6.32-71.29.1.el6.i686 ro root=UUID=e73735d6-c14b-4a40-8735-f34fc868da8a rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=fr-latin9 crashkernel=auto rhgb quiet initrd /usbinitramfs title CentOS Linux (2.6.32-71.29.1.el6.i686) ...
A faire : Re-démarrez votre machine pour tester votre configuration.
Comme sous RHEL/CentOS 6, le fichier Initramfs INITial Ram File System est une image d'un système minimal initialisée au démarrage du système.
Pour examiner une image initramfs, il convient d'abord de la copier vers /tmp et de la décompresser :
[root@centos7 ~]# cp /boot/initramfs-3.10.0-229.4.2.el7.x86_64.img /tmp/custom.gz [root@centos7 ~]# gunzip /tmp/custom.gz
root@debian8:~# cp /boot/initrd.img-3.16.0-4-686-pae /tmp/custom.gz root@debian8:~# gunzip /tmp/custom.gz
Ensuite il convient d'extraire l'image grâce à la commande cpio :
[root@centos7 ~]# cd /tmp [root@centos7 tmp]# mkdir initrd [root@centos7 tmp]# cd initrd [root@centos7 initrd]# cpio -cid -I ../custom 71439 blocks
root@debian8:~# cd /tmp root@debian8:/tmp# mkdir initrd root@debian8:/tmp# cd initrd root@debian8:/tmp/initrd# cpio -idvB < ../custom . sbin sbin/fsck sbin/logsave sbin/dmsetup sbin/e2fsck sbin/blkid sbin/mount.fuse sbin/plymouthd sbin/fsck.ext4 sbin/mount.ntfs sbin/udevadm sbin/modprobe sbin/mount.ntfs-3g sbin/sulogin ... conf conf/arch.conf conf/conf.d conf/conf.d/resume conf/initramfs.conf 10250 blocks
Installez maintenant le paquet tree :
[root@centos7 initrd]# yum install tree Loaded plugins: fastestmirror, langpacks base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 Loading mirror speeds from cached hostfile * base: miroir.univ-paris13.fr * extras: miroir.univ-paris13.fr * updates: mirrors.atosworldline.com Resolving Dependencies --> Running transaction check ---> Package tree.x86_64 0:1.6.0-10.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================================== Package Arch Version Repository Size ====================================================================================================================================================== Installing: tree x86_64 1.6.0-10.el7 base 46 k Transaction Summary ====================================================================================================================================================== Install 1 Package Total download size: 46 k Installed size: 87 k Is this ok [y/d/N]: y Downloading packages: tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : tree-1.6.0-10.el7.x86_64 1/1 Verifying : tree-1.6.0-10.el7.x86_64 1/1 Installed: tree.x86_64 0:1.6.0-10.el7 Complete!
root@debian8:/tmp/initrd# apt-get install tree Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: tree 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 47.9 kB of archives. After this operation, 137 kB of additional disk space will be used. Get:1 http://ftp.fr.debian.org/debian/ jessie/main tree i386 1.7.0-3 [47.9 kB] Fetched 47.9 kB in 0s (263 kB/s) Selecting previously unselected package tree. (Reading database ... 167512 files and directories currently installed.) Preparing to unpack .../archives/tree_1.7.0-3_i386.deb ... Unpacking tree (1.7.0-3) ... Processing triggers for man-db (2.7.0.2-5) ... Setting up tree (1.7.0-3) ...
Utilisez maintenant la commande tree pour examiner le contenu de l'image :
[root@centos7 initrd]# tree | more . ├── bin -> usr/bin ├── dev │ ├── console │ ├── kmsg │ └── null ├── etc │ ├── cmdline.d │ ├── conf.d │ │ └── systemd.conf │ ├── dhclient.conf │ ├── fstab.empty │ ├── group │ ├── hostname │ ├── initrd-release │ ├── ld.so.cache │ ├── ld.so.conf │ ├── ld.so.conf.d │ │ ├── dyninst-x86_64.conf │ │ ├── kernel-3.10.0-123.el7.x86_64.conf │ │ ├── kernel-3.10.0-229.4.2.el7.x86_64.conf │ │ ├── libiscsi-x86_64.conf │ │ ├── mariadb-x86_64.conf │ │ └── tracker-x86_64.conf │ ├── libnl │ │ └── classid │ ├── locale.conf │ ├── machine-id │ ├── modprobe.d --More--
root@debian8:/tmp/initrd# tree | more . ├── bin │ ├── [ │ ├── [[ │ ├── ar │ ├── ash │ ├── awk │ ├── basename │ ├── bunzip2 │ ├── busybox │ ├── bzcat │ ├── bzip2 │ ├── cal │ ├── cat │ ├── chgrp │ ├── chmod │ ├── chown │ ├── chroot │ ├── chvt │ ├── clear │ ├── cmp │ ├── cp │ ├── cpio │ ├── cttyhack │ ├── cut │ ├── date │ ├── dc │ ├── dd │ ├── deallocvt │ ├── df │ ├── diff --More--
Comme vous pouvez le constater, l'image contient une arborescence Linux minimaliste :
[root@centos7 initrd]# ls -l total 8 lrwxrwxrwx. 1 root root 7 Jun 10 10:09 bin -> usr/bin drwxr-xr-x. 2 root root 42 Jun 10 10:09 dev drwxr-xr-x. 11 root root 4096 Jun 10 10:09 etc lrwxrwxrwx. 1 root root 23 Jun 10 10:09 init -> usr/lib/systemd/systemd lrwxrwxrwx. 1 root root 7 Jun 10 10:09 lib -> usr/lib lrwxrwxrwx. 1 root root 9 Jun 10 10:09 lib64 -> usr/lib64 drwxr-xr-x. 2 root root 6 Jun 10 10:09 proc drwxr-xr-x. 2 root root 6 Jun 10 10:09 root drwxr-xr-x. 2 root root 6 Jun 10 10:09 run lrwxrwxrwx. 1 root root 8 Jun 10 10:09 sbin -> usr/sbin -rwxr-xr-x. 1 root root 3041 Jun 10 10:09 shutdown drwxr-xr-x. 2 root root 6 Jun 10 10:09 sys drwxr-xr-x. 2 root root 6 Jun 10 10:09 sysroot drwxr-xr-x. 2 root root 6 Jun 10 10:09 tmp drwxr-xr-x. 7 root root 61 Jun 10 10:09 usr drwxr-xr-x. 3 root root 47 Jun 10 10:09 var
root@debian8:/tmp/initrd# ls -l total 44 drwxr-xr-x 2 root root 4096 Oct 29 16:17 bin drwxr-xr-x 3 root root 4096 Oct 29 16:17 conf drwxr-xr-x 7 root root 4096 Oct 29 16:17 etc -rwxr-xr-x 1 root root 7057 Oct 29 16:17 init drwxr-xr-x 8 root root 4096 Oct 29 16:17 lib drwxr-xr-x 2 root root 4096 Oct 29 16:17 run drwxr-xr-x 2 root root 4096 Oct 29 16:17 sbin drwxr-xr-x 7 root root 4096 Oct 29 16:17 scripts drwxr-xr-x 4 root root 4096 Oct 29 16:17 usr drwxr-xr-x 3 root root 4096 Oct 29 16:17 var
Le script init est lancé lors du chargement de l'image. RHEL/CentOS 7 utilise le système de démarrage systemd. Pour cette raison le script init sous RHEL/CentOS 7 est un lien symbolique vers /usr/lib/systemd/systemd :
lrwxrwxrwx. 1 root root 23 Jun 10 10:09 init -> usr/lib/systemd/systemd
Par contre, sous Debian 8, le script init demeure :
-rwxr-xr-x 1 root root 7057 Oct 29 16:17 init
A faire : Passez en revue le contenu du script sous Debian.
La commande dracut permet de créer facilement une image initramfs. Les options de la commande sont :
[root@centos7 initrd]# dracut --help Usage: /sbin/dracut [OPTION]... [<initramfs> [<kernel-version>]] Version: 033-241.el7_1.1 Creates initial ramdisk images for preloading modules --kver [VERSION] Set kernel version to [VERSION]. -f, --force Overwrite existing initramfs file. -a, --add [LIST] Add a space-separated list of dracut modules. --rebuild Append arguments to those of existing image and rebuild -m, --modules [LIST] Specify a space-separated list of dracut modules to call when building the initramfs. Modules are located in /usr/lib/dracut/modules.d. -o, --omit [LIST] Omit a space-separated list of dracut modules. --force-add [LIST] Force to add a space-separated list of dracut modules to the default set of modules, when -H is specified. -d, --drivers [LIST] Specify a space-separated list of kernel modules to exclusively include in the initramfs. --add-drivers [LIST] Specify a space-separated list of kernel modules to add to the initramfs. --omit-drivers [LIST] Specify a space-separated list of kernel modules not to add to the initramfs. --filesystems [LIST] Specify a space-separated list of kernel filesystem modules to exclusively include in the generic initramfs. -k, --kmoddir [DIR] Specify the directory, where to look for kernel modules --fwdir [DIR] Specify additional directories, where to look for firmwares, separated by : --kernel-only Only install kernel drivers and firmware files --no-kernel Do not install kernel drivers and firmware files --print-cmdline Print the kernel command line for the given disk layout --early-microcode Combine early microcode with ramdisk --no-early-microcode Do not combine early microcode with ramdisk --kernel-cmdline [PARAMETERS] Specify default kernel command line parameters --strip Strip binaries in the initramfs --nostrip Do not strip binaries in the initramfs --prelink Prelink binaries in the initramfs --noprelink Do not prelink binaries in the initramfs --hardlink Hardlink files in the initramfs --nohardlink Do not hardlink files in the initramfs --prefix [DIR] Prefix initramfs files with [DIR] --noprefix Do not prefix initramfs files --mdadmconf Include local /etc/mdadm.conf --nomdadmconf Do not include local /etc/mdadm.conf --lvmconf Include local /etc/lvm/lvm.conf --nolvmconf Do not include local /etc/lvm/lvm.conf --fscks [LIST] Add a space-separated list of fsck helpers. --nofscks Inhibit installation of any fsck helpers. --ro-mnt Mount / and /usr read-only by default. -h, --help This message --debug Output debug information of the build process --profile Output profile information of the build process -L, --stdlog [0-6] Specify logging level (to standard error) 0 - suppress any messages 1 - only fatal errors 2 - all errors 3 - warnings 4 - info 5 - debug info (here starts lots of output) 6 - trace info (and even more) -v, --verbose Increase verbosity level -q, --quiet Decrease verbosity level -c, --conf [FILE] Specify configuration file to use. Default: /etc/dracut.conf --confdir [DIR] Specify configuration directory to use *.conf files from. Default: /etc/dracut.conf.d --tmpdir [DIR] Temporary directory to be used instead of default /var/tmp. -l, --local Local mode. Use modules from the current working directory instead of the system-wide installed in /usr/lib/dracut/modules.d. Useful when running dracut from a git checkout. -H, --hostonly Host-Only mode: Install only what is needed for booting the local host instead of a generic host. -N, --no-hostonly Disables Host-Only mode --hostonly-cmdline Store kernel command line arguments needed in the initramfs --no-hostonly-cmdline Do not store kernel command line arguments needed in the initramfs --persistent-policy [POLICY] Use [POLICY] to address disks and partitions. POLICY can be any directory name found in /dev/disk. E.g. "by-uuid", "by-label" --fstab Use /etc/fstab to determine the root device. --add-fstab [FILE] Add file to the initramfs fstab --mount "[DEV] [MP] [FSTYPE] [FSOPTS]" Mount device [DEV] on mountpoint [MP] with filesystem [FSTYPE] and options [FSOPTS] in the initramfs --add-device "[DEV]" Bring up [DEV] in initramfs -i, --include [SOURCE] [TARGET] Include the files in the SOURCE directory into the Target directory in the final initramfs. If SOURCE is a file, it will be installed to TARGET in the final initramfs. -I, --install [LIST] Install the space separated list of files into the initramfs. --gzip Compress the generated initramfs using gzip. This will be done by default, unless another compression option or --no-compress is passed. --bzip2 Compress the generated initramfs using bzip2. Make sure your kernel has bzip2 decompression support compiled in, otherwise you will not be able to boot. --lzma Compress the generated initramfs using lzma. Make sure your kernel has lzma support compiled in, otherwise you will not be able to boot. --xz Compress the generated initramfs using xz. Make sure that your kernel has xz support compiled in, otherwise you will not be able to boot. --lzo Compress the generated initramfs using lzop. Make sure that your kernel has lzo support compiled in, otherwise you will not be able to boot. --lz4 Compress the generated initramfs using lz4. Make sure that your kernel has lz4 support compiled in, otherwise you will not be able to boot. --compress [COMPRESSION] Compress the generated initramfs with the passed compression program. Make sure your kernel knows how to decompress the generated initramfs, otherwise you will not be able to boot. --no-compress Do not compress the generated initramfs. This will override any other compression options. --list-modules List all available dracut modules. -M, --show-modules Print included module's name to standard output during build. --keep Keep the temporary initramfs for debugging purposes --printsize Print out the module install size --sshkey [SSHKEY] Add ssh key to initramfs (use with ssh-client module) --logfile [FILE] Logfile to use (overrides configuration setting) If [LIST] has multiple arguments, then you have to put these in quotes. For example: # dracut --add-drivers "module1 module2" ...
Le fichier de configuration de dracut est /etc/dracut.conf. Editez ce fichier pour spécifier des modules noyau supplémentaires à inclure dans le fichier image générée :
# PUT YOUR CONFIG HERE OR IN separate files named *.conf # in /etc/dracut.conf.d # SEE man dracut.conf(5) # Sample dracut config file #logfile=/var/log/dracut.log #fileloglvl=6 # Exact list of dracut modules to use. Modules not listed here are not going # to be included. If you only want to add some optional modules use # add_dracutmodules option instead. #dracutmodules+="" # dracut modules to omit #omit_dracutmodules+="" # dracut modules to add to the default #add_dracutmodules+="" # additional kernel modules to the default add_drivers+="ehci-hcd ohci-hcd usb-storage scsi_mod sd_mod" # list of kernel filesystem modules to be included in the generic initramfs #filesystems+="" # build initrd only to boot current hardware #hostonly="yes" # # install local /etc/mdadm.conf #mdadmconf="no" # install local /etc/lvm/lvm.conf #lvmconf="no" # A list of fsck tools to install. If it's not specified, module's hardcoded # default is used, currently: "umount mount /sbin/fsck* xfs_db xfs_check # xfs_repair e2fsck jfs_fsck reiserfsck btrfsck". The installation is # opportunistic, so non-existing tools are just ignored. #fscks="" # inhibit installation of any fsck tools #nofscks="yes" # mount / and /usr read-only by default #ro_mnt="no" # set the directory for temporary files # default: /var/tmp #tmpdir=/tmp
Exécutez maintenant la commande suivante afin de générer le fichier usbinitramfs :
[root@centos7 initrd]# dracut -v usbinitramfs Executing: /sbin/dracut -v usbinitramfs *** Including module: bash *** *** Including module: nss-softokn *** *** Including module: i18n *** *** Including module: network *** *** Including module: ifcfg *** *** Including module: drm *** *** Including module: plymouth *** *** Including module: kernel-modules *** *** Including module: fcoe *** *** Including module: fcoe-uefi *** *** Including module: resume *** *** Including module: rootfs-block *** *** Including module: terminfo *** *** Including module: udev-rules *** Skipping udev rule: 91-permissions.rules *** Including module: biosdevname *** *** Including module: systemd *** *** Including module: usrmount *** *** Including module: base *** *** Including module: fs-lib *** *** Including module: shutdown *** *** Including module: uefi-lib *** *** Including modules done *** *** Installing kernel module dependencies and firmware *** *** Installing kernel module dependencies and firmware done *** *** Resolving executable dependencies *** *** Resolving executable dependencies done*** *** Hardlinking files *** *** Hardlinking files done *** *** Stripping files *** *** Stripping files done *** *** Generating early-microcode cpio image *** *** Constructing GenuineIntel.bin **** *** Store current command line parameters *** *** Creating image file *** *** Creating image file done ***
Notez la présence de votre nouvelle image /tmp/initrd/usbinitramfs :
[root@centos7 initrd]# ls -l /tmp/initrd/usbinitramfs -rw-------. 1 root root 16373488 Jun 10 10:23 /tmp/initrd/usbinitramfs
Déplacez votre fichier usbinitramfs au répertoire /boot :
[root@centos7 initrd]# mv usbinitramfs /boot
Créez maintenant le fichier /etc/grub.d/09_usbredhat :
#!/bin/sh -e cat << EOF menuentry 'CentOS Linux, with Linux 3.10.0-229.4.2.el7.x86_64 et usbinitramfs' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.4.2.el7.x86_64-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' e8d3bd48-1386-411c-9675-41c3f8f1a309 else search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 fi linux16 /vmlinuz-3.10.0-229.4.2.el7.x86_64 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet initrd16 /usbinitramfs } EOF
Rendez ce fichier exécutable :
[root@centos7 initrd]# chmod +x /etc/grub.d/09_usbredhat
Avant de continuer, supprimer le fichier /etc/grub.d/01_users et éditez le contenu du fichier /etc/grub.d/40_custom ainsi :
#!/bin/sh exec tail -n +3 $0 # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above.
Mettez à jour grub afin que celui-ci prend en compte le nouveau fichier :
[root@centos7 initrd]# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-229.4.2.el7.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-a2feb9eb09b1488da0f23b99a66350f8 Found initrd image: /boot/initramfs-0-rescue-a2feb9eb09b1488da0f23b99a66350f8.img done
Controlez le fichier /boot/grub/grub.cfg :
... ### BEGIN /etc/grub.d/09_usbredhat ### menuentry 'CentOS Linux, with Linux 3.10.0-229.4.2.el7.x86_64 et usbinitramfs' --class centos --class gnu-linux --class gnu --class os --unrestricted 'gnulinux-3.10.0-229.4.2.el7.x86_64-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ x = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' e8d3bd48-1386-411c-9675-41c3f8f1a309 else ...
A faire : Re-démarrez votre machine pour tester votre configuration.
La commande mkinitramfs permet de créer facilement une image initramfs. Les options de la commande sont :
Le fichier de configuration de mkinitramfs est /etc/initramfs-tools/modules. Editez ce fichier pour spécifier des modules noyau supplémentaires à inclure dans le fichier image générée :
# List of modules that you want to include in your initramfs. # They will be loaded at boot time in the order below. # # Syntax: module_name [args ...] # # You must run update-initramfs(8) to effect this change. # # Examples: # # raid1 # sd_mod usbcore uhci ehci-hcd usb-ohci usb-uhci usb-storage scsi_mod sd_mod
Exécutez maintenant la commande suivante afin de générer le fichier usbinitramfs :
root@debian8:/tmp/initrd# mkinitramfs -o usbinitramfs-`uname -r`.img
Notez la présence de votre nouvelle image /tmp/initrd/usbinitramfs :
root@debian8:/tmp/initrd# ls -l /tmp/initrd/usbinitramfs-3.16.0-4-686-pae.img -rw-r--r-- 1 root root 21454339 Oct 29 16:35 /tmp/initrd/usbinitramfs-3.16.0-4-686-pae.img
Déplacez votre fichier usbinitramfs au répertoire /boot :
root@debian8:/tmp/initrd# mv usbinitramfs-3.16.0-4-686-pae.img /boot /code> Créez maintenant le fichier **/etc/grub.d/09_usbdebian** : <file> #!/bin/sh -e cat << EOF menuentry 'Debian GNU/Linux et usbinitramfs' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0fc7a234-259a-416b-b674-51eedfb1823b' { load_video insmod gzio if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi echo 'Loading Linux 3.16.0-4-686-pae ...' linux /boot/vmlinuz-3.16.0-4-686-pae root=UUID=0fc7a234-259a-416b-b674-51eedfb1823b ro initrd=/install/gtk/initrd.gz quiet echo 'Loading initial ramdisk ...' initrd /boot/usbinitramfs-3.16.0-4-686-pae.img } EOF </file> Rendez ce fichier exécutable : <code> root@debian8:/tmp/initrd# chmod +x /etc/grub.d/09_usbdebian
Avant de continuer, supprimer le fichier /etc/grub.d/01_users et éditez le contenu du fichier /etc/grub.d/40_custom ainsi :
#!/bin/sh exec tail -n +3 $0 # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above.
Mettez à jour grub afin que celui-ci prend en compte le nouveau fichier :
root@debian8:/tmp/initrd# update-grub Generating grub configuration file ... Found background image: /usr/share/images/desktop-base/desktop-grub.png Found linux image: /boot/vmlinuz-3.16.0-4-686-pae Found initrd image: /boot/initrd.img-3.16.0-4-686-pae Found linux image: /boot/vmlinuz-3.16.0-4-586 Found initrd image: /boot/initrd.img-3.16.0-4-586 Found memtest86+ image: /boot/memtest86+.bin Found memtest86+ multiboot image: /boot/memtest86+_multiboot.bin done
Important : Notez l'utilisation de la commande update-grub en lieu et place de la commande grub-mkconfig -o /boot/grub/grub.cfg.
Controlez le fichier /boot/grub/grub.cfg :
... ### BEGIN /etc/grub.d/09_usbdebian ### menuentry 'Debian GNU/Linux et usbinitramfs' --class debian --class gnu-linux --class gnu --class os 'gnulinux-simple-0fc7a234-259a-416b-b674-51eedfb1823b' { load_video insmod gzio if [ x = xxen ]; then insmod xzio; insmod lzopio; fi insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0fc7a234-259a-416b-b674-51eedfb1823b else search --no-floppy --fs-uuid --set=root 0fc7a234-259a-416b-b674-51eedfb1823b fi echo 'Loading Linux 3.16.0-4-686-pae ...' linux /boot/vmlinuz-3.16.0-4-686-pae root=UUID=0fc7a234-259a-416b-b674-51eedfb1823b ro initrd=/install/gtk/initrd.gz quiet echo 'Loading initial ramdisk ...' initrd /boot/usbinitramfs-3.16.0-4-686-pae.img } ### END /etc/grub.d/09_usbdebian ### ### BEGIN /etc/grub.d/10_linux ### ...
A faire : Re-démarrez votre machine pour tester votre configuration.
Le processus de démarrage du Noyau Linux peut être divisé en 6 étapes :
Etape | Description |
---|---|
Chargement, configuration et exécution du chargeur du noyau | Le fichier bootsect.s est chargé en mémoire par le BIOS. Une fois configuré celui-ci charge le reste du noyau en mémoire |
Configuration des paramètres et bascule vers le mode 32 bits | Le fichier boot.s met en place un IDT (Interrupt Descriptor Table) temporaire et GDT (Global Descriptor Table) temporaire et gère le basculement vers le mode 32 bits |
Décompression du Noyau | Le fichier head.s décompresse le noyau |
Initialisation du noyau et de la mémoire | Le fichier head.s crée un GDT et IDT définitif |
Configuration du noyau | Le fichier main.c met en place les contraintes de mémoire et configure la mémoire virtuelle |
Création du processus Init | Le fichier main.c crée le processus init |
La fonction init_post() essaie ensuite d'exécuter un des processus suivant dans l'ordre :
Dans le cas d'un échec à ce stade le message Kernel Panic sera affiché.
Le premier processus lancé par le noyau est Init. L'exécutable lancé est /sbin/init. Son rôle est de d'initialiser le système et de lancer certains autres services. Les tâches accomplies par init sont :
Il existe 8 niveaux d'exécution ou RUNLEVELS sous RHEL/CentOS 5. Quatre des 8 sont réservés :
RUNLEVEL | Description |
---|---|
0 | Arrêt de la machine |
1 | Mode mono-utilisateur pour la maintenance |
6 | Redémarrage de la machine |
S ou s | Mode mono-utilisateur avec seul la partition racine montée |
Les autres quatre RUNLEVELS sont définis par chaque distribution. Par exemple, sous RedHat, ils sont :
RUNLEVEL | Description |
---|---|
2 | Mode multi-utilisateur sans NFS |
3 | Mode multi-utilisateur |
4 | Non-utilisé |
5 | Mode multi-utilisateur avec session graphique |
Il existe aussi 3 pseudo-niveaux d'exécution a, b et c. Ces pseudo-niveaux permettent à init de faire quelquechose sans changer de niveau d'exécution.
Pour connaître le niveau d'exécution actuel de la machine, saisissez la commande suivante :
[root@centos5 ~]# runlevel N 5
La lettre N indique que le système n'a pas changé de niveau d'exécution depuis son démarrage.
Pour modifier le niveau d'exécution courant, il convient d'utiliser la commande init ou telinit suivie du numéro du nouveau niveau d'exécution. Ces commandes peuvent prendre plusieurs options :
Option | Description |
---|---|
Q ou q | Demande à Init de relire le fichier /etc/inittab |
-t | Permet de modifier le temps accordé par Init aux processus entre l'envoi du signal SIGTERM et l'envoi du signal SIGKILL |
Il existe 8 niveaux d'exécution ou RUNLEVELS sous Linux. Quatre des 8 sont réservés :
RUNLEVEL | Description |
---|---|
0 | Arrêt de la machine |
1 | Mode mono-utilisateur pour la maintenance |
6 | Redémarrage de la machine |
S ou s | Mode mono-utilisateur avec seul la partition racine montée |
Les autres quatre RUNLEVELS sont définis par chaque distribution. Par exemple, sous Debian, ils sont :
RUNLEVEL | Description |
---|---|
2 | Mode multi-utilisateur |
3 | Mode multi-utilisateur - Non-utilisé |
4 | Mode multi-utilisateur - Non-utilisé |
5 | Mode multi-utilisateur - Non-utilisé |
Il existe aussi 3 pseudo-niveaux d'exécution a, b et c. Ces pseudo-niveaux permettent à init de faire quelquechose sans changer de niveau d'exécution.
Pour connaître le niveau d'exécution actuel de la machine, saisissez la commande suivante :
root@debian6:~# runlevel N 2
La lettre N indique que le système n'a pas changé de niveau d'exécution depuis son démarrage.
Pour modifier le niveau d'exécution courant, il convient d'utiliser la commande init ou telinit suivie du numéro du nouveau niveau d'exécution. Ces commandes peuvent prendre plusieurs options :
Option | Description |
---|---|
Q ou q | Demande à Init de relire le fichier /etc/inittab |
-t | Permet de modifier le temps accordé par Init aux processus entre l'envoi du signal SIGTERM et l'envoi du signal SIGKILL |
Le fichier /etc/inittab permet de définir les services à démarrer en fonction du RUNLEVEL :
[root@centos5 ~]# cat /etc/inittab # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org> # Modified for RHS Linux by Marc Ewing and Donnie Barnes # # Default runlevel. The runlevels used by RHS are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:5:initdefault: # System initialization. si::sysinit:/etc/rc.d/rc.sysinit l0:0:wait:/etc/rc.d/rc 0 l1:1:wait:/etc/rc.d/rc 1 l2:2:wait:/etc/rc.d/rc 2 l3:3:wait:/etc/rc.d/rc 3 l4:4:wait:/etc/rc.d/rc 4 l5:5:wait:/etc/rc.d/rc 5 l6:6:wait:/etc/rc.d/rc 6 # Trap CTRL-ALT-DELETE ca::ctrlaltdel:/sbin/shutdown -t3 -r now # When our UPS tells us power has failed, assume we have a few minutes # of power left. Schedule a shutdown for 2 minutes from now. # This does, of course, assume you have powerd installed and your # UPS connected and working correctly. pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down" # If power was restored before the shutdown kicked in, cancel it. pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled" # Run gettys in standard runlevels 1:2345:respawn:/sbin/mingetty tty1 2:2345:respawn:/sbin/mingetty tty2 3:2345:respawn:/sbin/mingetty tty3 4:2345:respawn:/sbin/mingetty tty4 5:2345:respawn:/sbin/mingetty tty5 6:2345:respawn:/sbin/mingetty tty6 # Run xdm in runlevel 5 x:5:respawn:/etc/X11/prefdm -nodaemon
root@debian6:~# cat /etc/inittab # /etc/inittab: init(8) configuration. # $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $ # The default runlevel. id:2:initdefault: # Boot-time system configuration/initialization script. # This is run first except when booting in emergency (-b) mode. si::sysinit:/etc/init.d/rcS # What to do in single-user mode. ~~:S:wait:/sbin/sulogin # /etc/init.d executes the S and K scripts upon change # of runlevel. # # Runlevel 0 is halt. # Runlevel 1 is single-user. # Runlevels 2-5 are multi-user. # Runlevel 6 is reboot. l0:0:wait:/etc/init.d/rc 0 l1:1:wait:/etc/init.d/rc 1 l2:2:wait:/etc/init.d/rc 2 l3:3:wait:/etc/init.d/rc 3 l4:4:wait:/etc/init.d/rc 4 l5:5:wait:/etc/init.d/rc 5 l6:6:wait:/etc/init.d/rc 6 # Normally not reached, but fallthrough in case of emergency. z6:6:respawn:/sbin/sulogin # What to do when CTRL-ALT-DEL is pressed. ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now # Action on special keypress (ALT-UpArrow). #kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work." # What to do when the power fails/returns. pf::powerwait:/etc/init.d/powerfail start pn::powerfailnow:/etc/init.d/powerfail now po::powerokwait:/etc/init.d/powerfail stop # /sbin/getty invocations for the runlevels. # # The "id" field MUST be the same as the last # characters of the device (after "tty"). # # Format: # <id>:<runlevels>:<action>:<process> # # Note that on most Debian systems tty7 is used by the X Window System, # so if you want to add more getty's go ahead but skip tty7 if you run X. # 1:2345:respawn:/sbin/getty 38400 tty1 2:23:respawn:/sbin/getty 38400 tty2 3:23:respawn:/sbin/getty 38400 tty3 4:23:respawn:/sbin/getty 38400 tty4 5:23:respawn:/sbin/getty 38400 tty5 6:23:respawn:/sbin/getty 38400 tty6 # Example how to put a getty on a serial line (for a terminal) # #T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 #T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100 # Example how to put a getty on a modem line. # #T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3
Dans l'exemple ci-dessus, chaque ligne non-commentée est composée de quatre champs, séparés par le caractère : :
Champ | Nom | Description |
---|---|---|
1 | Identifiant | Identifiant unique de la ligne composé de 1 à 4 caractères |
2 | RUNLEVELS | Liste des niveaux d'exécution concernés par la ligne |
3 | Action | Méthode utilisé pour lancer la commande se trouvant dans le champ 4 |
4 | Commande | Commande à lancer |
Le champ action prend une des directives suivantes :
Directive | Description |
---|---|
respawn | Le processus est relancé en cas d'arrêt de celui-ci |
mingetty | Assure la gestion du terminal texte |
once | Le processus n'est exécuté qu'une fois |
wait | Le processus n'est exécuté qu'une fois. Init attend la fin du processus avant de passer à la ligne suivante |
boot | Le processus est exécuté au démarrage de la machine. Le champ RUNLEVELS est sans importance |
bootwait | Le processus est exécuté au démarrage de la machine. Le champ RUNLEVELS est sans importance. Init attend la fin du processus avant de passer à la ligne suivante |
off | Revient à commenter la ligne |
ondemand | La même chose que respawn mais la commande est exécuté dans un des 3 pseudo-niveaux d'exécution |
initdefault | Définit le niveau d'exécution par défaut |
sysinit | La commande est exécutée au démarrage da la machine avant les lignes boot et bootwait |
powerfail | La commande est exécutée quand init reçoit un signal SIGPWR d'un onduleur |
powerwait | La commande est exécutée quand init reçoit un signal SIGPWR d'un onduleur. Init attend la fin du processus avant de passer à la ligne suivante |
powerokwait | La commande est exécutée si Init reçoit un signal de rétablissement du courant |
powerfailnow | La commande est exécutée quand Init reçoit un signal comme quoi la batterie de l'onduleur est presque vide |
ctrlaltdel | La commande est exécutée quand Init reçoit un signal SIGINT. Ce signal est envoyé par la combinaison de touches [CTRL] [ALT] [SUPPR] |
kbrequest | La commande est exécutée suivant des séquences de touches saisies au clavier |
L'analyse de notre fichier d'exemple sous RHEL/CentOS 5 indique :
Ligne | Description |
---|---|
id:5:initdefault: | Le niveau d'exécution par défaut est 5 |
si::sysinit:/etc/rc.d/rc.sysinit | La commande /etc/rc.d/rc.sysinit est lancée au démarrage de la machine |
l0:0:wait:/etc/rc.d/rc 0 | La commande /etc/rc.d/rc est lancée pour le niveau d'exécution 0 |
l1:1:wait:/etc/rc.d/rc 1 | La commande /etc/rc.d/rc est lancée pour le niveau d'exécution 1 |
l2:2:wait:/etc/rc.d/rc 2 | La commande /etc/rc.d/rc est lancée pour le niveau d'exécution 2 |
l3:3:wait:/etc/rc.d/rc 3 | La commande /etc/rc.d/rc est lancée pour le niveau d'exécution 3 |
l4:4:wait:/etc/rc.d/rc 4 | La commande /etc/rc.d/rc est lancée pour le niveau d'exécution 4 |
l5:5:wait:/etc/rc.d/rc 5 | La commande /etc/rc.d/rc est lancée pour le niveau d'exécution 5 |
l6:6:wait:/etc/rc.d/rc 6 | La commande /etc/rc.d/rc est lancée pour le niveau d'exécution 6 |
ca::ctrlaltdel:/sbin/shutdown -t3 -r now | La commande /sbin/shutdown -t3 -r now est lancée si les touches [CTRL] [ALT] [SUPPR] sont appuyées simultanément |
pf::powerfail:/sbin/shutdown -f -h +2 “Power Failure; System Shutting Down” | La commande /sbin/shutdown -f -h +2 est lancée quand Init reçoit le signal SIGPWR |
pr:12345:powerokwait:/sbin/shutdown -c “Power Restored; Shutdown Cancelled” | La commande /sbin/shutdown -c est lancée quand Init reçoit un signal de rétablissement du courant |
1:2345:respawn:/sbin/mingetty tty1 | Le terminal tty1 est initialisé par la commande /sbin/mingetty. Le terminal est disponible en appuyant sur les touches [CTRL] [ALT] [F1] |
2:2345:respawn:/sbin/mingetty tty2 | Le terminal tty2 est initialisé par la commande /sbin/mingetty. Le terminal est disponible en appuyant sur les touches [CTRL] [ALT] [F2] |
3:2345:respawn:/sbin/mingetty tty3 | Le terminal tty3 est initialisé par la commande /sbin/mingetty. Le terminal est disponible en appuyant sur les touches [CTRL] [ALT] [F3] |
4:2345:respawn:/sbin/mingetty tty4 | Le terminal tty4 est initialisé par la commande /sbin/mingetty. Le terminal est disponible en appuyant sur les touches [CTRL] [ALT] [F4] |
5:2345:respawn:/sbin/mingetty tty5 | Le terminal tty5 est initialisé par la commande /sbin/mingetty. Le terminal est disponible en appuyant sur les touches [CTRL] [ALT] [F5] |
6:2345:respawn:/sbin/mingetty tty6 | Le terminal tty6 est initialisé par la commande /sbin/mingetty. Le terminal est disponible en appuyant sur les touches [CTRL] [ALT] [F6] |
x:5:respawn:/etc/X11/prefdm -nodaemon | xdm est lancé dans le niveau d'exécution 5 |
L'analyse de notre fichier d'exemple sous Debian 6 indique :
Ligne | Description |
---|---|
id:2:initdefault: | Le niveau d'exécution par défaut est 2 |
si::sysinit:/etc/init.d/rcS | Le script /etc/init.d/rcS est lancé au démarrage de la machine |
~~:S:wait:/sbin/sulogin | La commande /sbin/sulogin est lancée au démarrage de la machine en niveau d'exécution S |
l0:0:wait:/etc/init.d/rc 0 | Le script /etc/rc.d/rc est lancé pour le niveau d'exécution 0 |
l1:1:wait:/etc/init.d/rc 1 | Le script /etc/rc.d/rc est lancé pour le niveau d'exécution 1 |
l2:2:wait:/etc/init.d/rc 2 | Le script /etc/rc.d/rc est lancé pour le niveau d'exécution 2 |
l3:3:wait:/etc/init.d/rc 3 | Le script /etc/rc.d/rc est lancé pour le niveau d'exécution 3 |
l4:4:wait:/etc/init.d/rc 4 | Le script /etc/rc.d/rc est lancé pour le niveau d'exécution 4 |
l5:5:wait:/etc/init.d/rc 5 | Le script /etc/rc.d/rc est lancé pour le niveau d'exécution 5 |
l6:6:wait:/etc/init.d/rc 6 | Le script /etc/rc.d/rc est lancé pour le niveau d'exécution 6 |
z6:6:respawn:/sbin/sulogin | La commande /sbin/sulogin est lancée au redémarrage de la machine si necéssaire |
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now | La commande /sbin/shutdown -t1 -a -r now est lancée si les touches [CTRL] [ALT] [SUPPR] sont appuyées simultanément |
pf::powerwait:/etc/init.d/powerfail start | Le script /etc/init.d/powerfail start est lancée quand Init reçoit le signal SIGPWR |
pn::powerfailnow:/etc/init.d/powerfail now | Le script /etc/init.d/powerfail now est lancée quand Init reçoit un signal comme quoi la batterie de l'onduleur est presque vide |
po::powerokwait:/etc/init.d/powerfail stop | Le script /etc/init.d/powerfail stop est lancée quand Init reçoit un signal de rétablissement du courant |
1:2345:respawn:/sbin/getty 38400 tty1 | Le terminal tty1 est initialisé par la commande /sbin/mingetty. Le terminal est disponible en appuyant sur les touches [CTRL] [ALT] [F1] |
2:23:respawn:/sbin/getty 38400 tty2 | Le terminal tty2 est initialisé par la commande /sbin/mingetty. Le terminal est disponible en appuyant sur les touches [CTRL] [ALT] [F2] |
3:23:respawn:/sbin/getty 38400 tty3 | Le terminal tty3 est initialisé par la commande /sbin/mingetty. Le terminal est disponible en appuyant sur les touches [CTRL] [ALT] [F3] |
4:23:respawn:/sbin/getty 38400 tty4 | Le terminal tty4 est initialisé par la commande /sbin/mingetty. Le terminal est disponible en appuyant sur les touches [CTRL] [ALT] [F4] |
5:23:respawn:/sbin/getty 38400 tty5 | Le terminal tty5 est initialisé par la commande /sbin/mingetty. Le terminal est disponible en appuyant sur les touches [CTRL] [ALT] [F5] |
6:23:respawn:/sbin/getty 38400 tty6 | Le terminal tty6 est initialisé par la commande /sbin/mingetty. Le terminal est disponible en appuyant sur les touches [CTRL] [ALT] [F6] |
Naviguez à /etc/rc.d et saisissez la commande ls :
[root@centos5 ~]# cd /etc/rc.d [root@centos5 rc.d]# ls init.d rc0.d rc2.d rc4.d rc6.d rc.sysinit rc rc1.d rc3.d rc5.d rc.local
D'après l'étude du fichier inittab nous savons que le script rc.sysinit est exécuté en premier.
D'après l'étude du fichier inittab, nous savons que le script /etc/init.d/rcS est exécuté en premier. Ce script appelle tous les scripts dans /etc/init.d qui sont référencés par les liens dans /etc/rcS.d/ et ceci dans un ordre numérique/alphabétique :
root@debian6:/etc/init.d# cat /etc/init.d/rcS #! /bin/sh # # rcS # # Call all S??* scripts in /etc/rcS.d/ in numerical/alphabetical order # exec /etc/init.d/rc S
Le répertoire /etc/rc.d/init.d contient les scripts permettant de lancer les services du système :
[root@centos5 rc.d]# ls init.d/* init.d/abrtd init.d/cpuspeed init.d/iptables init.d/netfs init.d/portreserve init.d/sandbox init.d/vboxadd init.d/acpid init.d/crond init.d/irqbalance init.d/network init.d/postfix init.d/saslauthd init.d/vboxadd-service init.d/atd init.d/cups init.d/jexec init.d/NetworkManager init.d/psacct init.d/single init.d/vboxadd-x11 init.d/auditd init.d/dnsmasq init.d/kdump init.d/nfs init.d/rdisc init.d/smartd init.d/wpa_supplicant init.d/autofs init.d/firstboot init.d/killall init.d/nfslock init.d/restorecond init.d/snmpd init.d/ypbind init.d/avahi-daemon init.d/functions init.d/lvm2-monitor init.d/nscd init.d/rpcbind init.d/snmptrapd init.d/bluetooth init.d/haldaemon init.d/mdmonitor init.d/nslcd init.d/rpcgssd init.d/sshd init.d/certmonger init.d/halt init.d/messagebus init.d/ntpd init.d/rpcidmapd init.d/sssd init.d/cgconfig init.d/httpd init.d/microcode_ctl init.d/ntpdate init.d/rpcsvcgssd init.d/sysstat init.d/cgred init.d/ip6tables init.d/netconsole init.d/oddjobd init.d/rsyslog init.d/udev-post
root@debian6:/etc# cd init.d root@debian6:/etc/init.d# ls acpid hwclockfirst.sh rc.local alsa-utils hwclock.sh rcS anacron ifupdown README atd ifupdown-clean reboot avahi-daemon kerneloops rmnologin binfmt-support keyboard-setup rsyslog bluetooth killprocs saned bootlogd lm-sensors sendsigs bootlogs loadcpufreq single bootmisc.sh module-init-tools skeleton checkfs.sh mountall-bootclean.sh stop-bootlogd checkroot.sh mountall.sh stop-bootlogd-single console-screen.sh mountdevsubfs.sh sudo console-setup mountkernfs.sh udev cpufrequtils mountnfs-bootclean.sh udev-mtab cron mountnfs.sh umountfs cups mountoverflowtmp umountnfs.sh dbus mtab.sh umountroot exim4 networking unattended-upgrades fancontrol network-manager urandom fuse nfs-common vboxadd gdm3 portmap vboxadd-service halt pppd-dns vboxadd-x11 hdparm procps x11-common hostname.sh rc
Linux Standard Base (LSB) fut introduit par le Linux Foundation dans un but de permettre la portabilité des scripts init entre distributions différentes.
Les scripts init qui sont conformes au standard LSB doivent fournir :
Les scripts init conforment au standard LSB peuvent aussi fournir :
Les fonctions proposées par défaut par LSB sont contenues dans le fichier /lib/lsb/init-functions :
[root@centos5 ~]# cat /lib/lsb/init-functions #!/bin/sh # LSB initscript functions, as defined in the LSB Spec 1.1.0 # # Lawrence Lim <llim@redhat.com> - Tue, 26 June 2007 # Updated to the latest LSB 3.1 spec # http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic_lines.txt start_daemon () { /etc/redhat-lsb/lsb_start_daemon "$@" } killproc () { /etc/redhat-lsb/lsb_killproc "$@" } pidofproc () { /etc/redhat-lsb/lsb_pidofproc "$@" } log_success_msg () { /etc/redhat-lsb/lsb_log_message success "$@" } log_failure_msg () { /etc/redhat-lsb/lsb_log_message failure "$@" } log_warning_msg () { /etc/redhat-lsb/lsb_log_message warning "$@" }
Ces fonctions sont des scripts se trouvant dans le répertoire /etc/redhat-lsb :
[root@centos5 ~]# ls -l /etc/redhat-lsb/ total 16 -rwxr-xr-x. 1 root root 70 22 févr. 2013 lsb_killproc -rwxr-xr-x. 1 root root 243 22 févr. 2013 lsb_log_message -rwxr-xr-x. 1 root root 59 22 févr. 2013 lsb_pidofproc -rwxr-xr-x. 1 root root 650 22 févr. 2013 lsb_start_daemon
L'examen de ces scripts nous démontre que le système appelle le fichier /etc/init.d/functions :
[root@centos5 ~]# cat /etc/redhat-lsb/lsb_killproc #!/bin/bash . /etc/init.d/functions LSB=LSB-1.1 killproc $* exit $? [root@centos ~]# [root@centos ~]# cat /etc/redhat-lsb/lsb_pidofproc #!/bin/bash . /etc/init.d/functions pidofproc $* exit $?
Le fichier /etc/init.d/functions contient les fonctions à exécuter, par exemple :
... # A function to stop a program. killproc() { local RC killlevel= base pid pid_file= delay try binary= RC=0; delay=3; try=0 # Test syntax. if [ "$#" -eq 0 ]; then echo $"Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]" return 1 fi if [ "$1" = "-p" ]; then pid_file=$2 shift 2 fi if [ "$1" = "-b" ]; then if [ -z $pid_file ]; then echo $"-b option can be used only with -p" echo $"Usage: killproc -p pidfile -b binary program" return 1 fi binary=$2 shift 2 fi if [ "$1" = "-d" ]; then delay=$(echo $2 | awk -v RS=' ' -v IGNORECASE=1 '{if($1!~/^[0-9.]+[smhd]?$/) exit 1;d=$1~/s$|^[0-9.]*$/?1:$1~/m$/?60:$1~/h$/?60*60:$1~/d$/?24*60*60:-1;if(d==-1) exit 1;delay+=d*$1} END {printf("%d",delay+0.5)}') if [ "$?" -eq 1 ]; then echo $"Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]" return 1 fi shift 2 ...
et
... pidofproc() { local RC pid pid_file= # Test syntax. if [ "$#" = 0 ]; then echo $"Usage: pidofproc [-p pidfile] {program}" return 1 fi if [ "$1" = "-p" ]; then pid_file=$2 shift 2 fi fail_code=3 # "Program is not running" # First try "/var/run/*.pid" files __pids_var_run "$1" "$pid_file" RC=$? if [ -n "$pid" ]; then echo $pid return 0 fi [ -n "$pid_file" ] && return $RC __pids_pidof "$1" || return $RC } ...
Les codes retour standardisés sont :
Code Retour | Description |
---|---|
0 | Le programme fonctionne et le service est correctement démarré |
1 | Le programme est mort et le fichier pid dans /var/run existe |
2 | Le programme est mort et le fichier verrou dans /var/lock existe |
3 | Le programme ne fonctionne pas et le service n'est pas correctement démarré |
4 | Le statut du programme ou du service est inconnu |
5 - 99 | Réservés pour LSB |
100-149 | Réserves pour la distribution |
150-199 | Réservés pour l'application |
200-254 | Réservés |
LSB stipule un format rigide de script qui commence par une section délimitée par deux clauses :
Par exemple :
[root@centos5 ~]# more /etc/rc.d/init.d/sshd #!/bin/bash # # sshd Start up the OpenSSH server daemon # # chkconfig: 2345 55 25 # description: SSH is a protocol for secure remote shell access. \ # This service starts up the OpenSSH server daemon. # # processname: sshd # config: /etc/ssh/ssh_host_key # config: /etc/ssh/ssh_host_key.pub # config: /etc/ssh/ssh_random_seed # config: /etc/ssh/sshd_config # pidfile: /var/run/sshd.pid ### BEGIN INIT INFO # Provides: sshd # Required-Start: $local_fs $network $syslog # Required-Stop: $local_fs $syslog # Should-Start: $syslog # Should-Stop: $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start up the OpenSSH server daemon # Description: SSH is a protocol for secure remote shell access. # This service starts up the OpenSSH server daemon. ### END INIT INFO # source function library . /etc/rc.d/init.d/functions # pull in sysconfig settings [ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd --Plus--(20%)
Les lignes se trouvant entre les deux clauses ont un format spécifique :
# {MotClef}: valeur1 [valeur2...]
Important : Notez qu'à part la deuxième ligne de la description, chaque ligne doit commencer par le caractère # suivi par un espace.
Les Mots Clefs sont :
Mot Clef | Description |
---|---|
Provides | Indique le service -(boot facilities en anglais) démarré par le script. Le nom doit être unique. |
Required-start | Indique d'autres services qui doivent être démarrés avant le démarrage de celui indiqué par le mot-clef Provides. |
Required-Stop | Indique d'autres services qui doivent être arrêtés après l'arrêt de celui indiqué par le mot-clef Provides. |
Should-Start | Indique d'autres services qui, s'ils sont présents sur le système, être démarrés avant le démarrage de celui indiqué par le mot-clef Provides. |
Should-Stop | Indique d'autres services qui, s'ils sont présents sur le système, doivent être arrêtés après l'arrêt de celui indiqué par le mot-clef Provides. |
Default-Start | Indique les niveaux d'exécution dans lesquels le service doit être démarré. |
Default-Stop | Indique les niveaux d'exécution dans lesquels le service doit être arrêté. |
Short-Description | Indique une description du service en une seule ligne. |
Description | Indique une description multi-lignes du service. |
Il existe des groupements de services, appelés en anglais des Virtual Facilities. Les plus importants sont :
Virtual Facility | Description |
---|---|
$local_fs | Tous les systèmes de fichiers locaux doivent être montés. |
$network | La carte Ethernet doit fonctionner |
$named | Les daemons, si présents, responsables de la résolution des noms tels DNS, NIS+ ou LDAP doivent être démarrés. |
$portmap | Les daemons qui fournissent le SunRPC/ONCRPC port mapping doivent être démarrés. |
$remote_fs | Tous les systèmes de fichiers doivent être montés. |
$syslog | Syslog, Syslog-ng ou Rsyslog doit être démarré. |
$time | L'heure du système doit avoir été fixé soit par NTP, soit par rdate soit par l'horloge système. |
Les répertoires rc0.d à rc6.d contiennent des liens vers les scripts du répertoire init.d.
Pour mieux comprendre, saisissez les commandes suivantes :
[root@centos5 rc.d]# for rep in rc[345].d; do echo "dans $rep :"; ls $rep/S*; done dans rc3.d : rc3.d/S00microcode_ctl rc3.d/S10network rc3.d/S13irqbalance rc3.d/S24avahi-daemon rc3.d/S25netfs rc3.d/S30vboxadd rc3.d/S80postfix rc3.d/S01sysstat rc3.d/S11auditd rc3.d/S13rpcbind rc3.d/S24nfslock rc3.d/S26acpid rc3.d/S30vboxadd-x11 rc3.d/S82abrtd rc3.d/S02lvm2-monitor rc3.d/S11portreserve rc3.d/S15mdmonitor rc3.d/S24rpcgssd rc3.d/S26haldaemon rc3.d/S35vboxadd-service rc3.d/S90crond rc3.d/S08ip6tables rc3.d/S12rsyslog rc3.d/S22messagebus rc3.d/S24rpcidmapd rc3.d/S26udev-post rc3.d/S50bluetooth rc3.d/S95atd rc3.d/S08iptables rc3.d/S13cpuspeed rc3.d/S23NetworkManager rc3.d/S25cups rc3.d/S28autofs rc3.d/S55sshd rc3.d/S99local dans rc4.d : rc4.d/S00microcode_ctl rc4.d/S10network rc4.d/S13irqbalance rc4.d/S24avahi-daemon rc4.d/S25netfs rc4.d/S30vboxadd rc4.d/S90crond rc4.d/S01sysstat rc4.d/S11auditd rc4.d/S13rpcbind rc4.d/S24nfslock rc4.d/S26acpid rc4.d/S35vboxadd-service rc4.d/S95atd rc4.d/S02lvm2-monitor rc4.d/S11portreserve rc4.d/S15mdmonitor rc4.d/S24rpcgssd rc4.d/S26haldaemon rc4.d/S50bluetooth rc4.d/S99local rc4.d/S08ip6tables rc4.d/S12rsyslog rc4.d/S22messagebus rc4.d/S24rpcidmapd rc4.d/S26udev-post rc4.d/S55sshd rc4.d/S08iptables rc4.d/S13cpuspeed rc4.d/S23NetworkManager rc4.d/S25cups rc4.d/S28autofs rc4.d/S80postfix dans rc5.d : rc5.d/S00microcode_ctl rc5.d/S10network rc5.d/S13irqbalance rc5.d/S24avahi-daemon rc5.d/S25netfs rc5.d/S30vboxadd rc5.d/S80postfix rc5.d/S01sysstat rc5.d/S11auditd rc5.d/S13rpcbind rc5.d/S24nfslock rc5.d/S26acpid rc5.d/S30vboxadd-x11 rc5.d/S82abrtd rc5.d/S02lvm2-monitor rc5.d/S11portreserve rc5.d/S15mdmonitor rc5.d/S24rpcgssd rc5.d/S26haldaemon rc5.d/S35vboxadd-service rc5.d/S90crond rc5.d/S08ip6tables rc5.d/S12rsyslog rc5.d/S22messagebus rc5.d/S24rpcidmapd rc5.d/S26udev-post rc5.d/S50bluetooth rc5.d/S95atd rc5.d/S08iptables rc5.d/S13cpuspeed rc5.d/S23NetworkManager rc5.d/S25cups rc5.d/S28autofs rc5.d/S55sshd rc5.d/S99local
root@debian6:/etc/init.d# for rep in /etc/rc[2345].d; do echo "dans $rep : "; ls $rep/S*; done dans /etc/rc2.d : /etc/rc2.d/S01vboxadd /etc/rc2.d/S18kerneloops /etc/rc2.d/S02vboxadd-service /etc/rc2.d/S18loadcpufreq /etc/rc2.d/S14portmap /etc/rc2.d/S19avahi-daemon /etc/rc2.d/S15nfs-common /etc/rc2.d/S19bluetooth /etc/rc2.d/S17binfmt-support /etc/rc2.d/S19cpufrequtils /etc/rc2.d/S17fancontrol /etc/rc2.d/S19network-manager /etc/rc2.d/S17rsyslog /etc/rc2.d/S20cups /etc/rc2.d/S17sudo /etc/rc2.d/S20gdm3 /etc/rc2.d/S18acpid /etc/rc2.d/S20saned /etc/rc2.d/S18anacron /etc/rc2.d/S21bootlogs /etc/rc2.d/S18atd /etc/rc2.d/S22rc.local /etc/rc2.d/S18cron /etc/rc2.d/S22rmnologin /etc/rc2.d/S18dbus /etc/rc2.d/S22stop-bootlogd /etc/rc2.d/S18exim4 dans /etc/rc3.d : /etc/rc3.d/S01vboxadd /etc/rc3.d/S18kerneloops /etc/rc3.d/S02vboxadd-service /etc/rc3.d/S18loadcpufreq /etc/rc3.d/S14portmap /etc/rc3.d/S19avahi-daemon /etc/rc3.d/S15nfs-common /etc/rc3.d/S19bluetooth /etc/rc3.d/S17binfmt-support /etc/rc3.d/S19cpufrequtils /etc/rc3.d/S17fancontrol /etc/rc3.d/S19network-manager /etc/rc3.d/S17rsyslog /etc/rc3.d/S20cups /etc/rc3.d/S17sudo /etc/rc3.d/S20gdm3 /etc/rc3.d/S18acpid /etc/rc3.d/S20saned /etc/rc3.d/S18anacron /etc/rc3.d/S21bootlogs /etc/rc3.d/S18atd /etc/rc3.d/S22rc.local /etc/rc3.d/S18cron /etc/rc3.d/S22rmnologin /etc/rc3.d/S18dbus /etc/rc3.d/S22stop-bootlogd /etc/rc3.d/S18exim4 dans /etc/rc4.d : /etc/rc4.d/S01vboxadd /etc/rc4.d/S18kerneloops /etc/rc4.d/S02vboxadd-service /etc/rc4.d/S18loadcpufreq /etc/rc4.d/S14portmap /etc/rc4.d/S19avahi-daemon /etc/rc4.d/S15nfs-common /etc/rc4.d/S19bluetooth /etc/rc4.d/S17binfmt-support /etc/rc4.d/S19cpufrequtils /etc/rc4.d/S17fancontrol /etc/rc4.d/S19network-manager /etc/rc4.d/S17rsyslog /etc/rc4.d/S20cups /etc/rc4.d/S17sudo /etc/rc4.d/S20gdm3 /etc/rc4.d/S18acpid /etc/rc4.d/S20saned /etc/rc4.d/S18anacron /etc/rc4.d/S21bootlogs /etc/rc4.d/S18atd /etc/rc4.d/S22rc.local /etc/rc4.d/S18cron /etc/rc4.d/S22rmnologin /etc/rc4.d/S18dbus /etc/rc4.d/S22stop-bootlogd /etc/rc4.d/S18exim4 dans /etc/rc5.d : /etc/rc5.d/S01vboxadd /etc/rc5.d/S18kerneloops /etc/rc5.d/S02vboxadd-service /etc/rc5.d/S18loadcpufreq /etc/rc5.d/S14portmap /etc/rc5.d/S19avahi-daemon /etc/rc5.d/S15nfs-common /etc/rc5.d/S19bluetooth /etc/rc5.d/S17binfmt-support /etc/rc5.d/S19cpufrequtils /etc/rc5.d/S17fancontrol /etc/rc5.d/S19network-manager /etc/rc5.d/S17rsyslog /etc/rc5.d/S20cups /etc/rc5.d/S17sudo /etc/rc5.d/S20gdm3 /etc/rc5.d/S18acpid /etc/rc5.d/S20saned /etc/rc5.d/S18anacron /etc/rc5.d/S21bootlogs /etc/rc5.d/S18atd /etc/rc5.d/S22rc.local /etc/rc5.d/S18cron /etc/rc5.d/S22rmnologin /etc/rc5.d/S18dbus /etc/rc5.d/S22stop-bootlogd /etc/rc5.d/S18exim4
Important : Notez que chaque répertoire correspondant à un niveau d'exécution contient des liens pointant vers un script dans le répertoire /etc/init.d. La lettre S indique au script rc que le script dans /etc/rc.d/init.d doit être exécutée avec l'option start. De cette façon les processus sont lancés dans le niveau d'exécution spécifié. Le numéro qui suit la lettre S indique l'ordre de lancement par le script rc. Si deux scripts dans un répertoire /etc/rc.d/rcX.d ont le même numéro, l'ordre alphabétique prime. Notez aussi la présence du lien S99local qui lance le script rc.local en dernier. Le script rc.local est lancé dans les niveaux d'exécution 2, 3, 4 et 5. C'est dans ce script que root peut ajouter des commandes.
Rappelez la commande précédente et modifiez la lettre S en K :
[root@centos5 rc.d]# for rep in rc[345].d; do echo "dans $rep :"; ls $rep/K*; done dans rc3.d : rc3.d/K01certmonger rc3.d/K10saslauthd rc3.d/K50snmpd rc3.d/K73ypbind rc3.d/K80kdump rc3.d/K87restorecond rc3.d/K95firstboot rc3.d/K01smartd rc3.d/K15httpd rc3.d/K50snmptrapd rc3.d/K74nscd rc3.d/K80sssd rc3.d/K88nslcd rc3.d/K02oddjobd rc3.d/K50dnsmasq rc3.d/K60nfs rc3.d/K74ntpd rc3.d/K84wpa_supplicant rc3.d/K89rdisc rc3.d/K10psacct rc3.d/K50netconsole rc3.d/K69rpcsvcgssd rc3.d/K75ntpdate rc3.d/K86cgred rc3.d/K95cgconfig dans rc4.d : rc4.d/K01certmonger rc4.d/K10saslauthd rc4.d/K50netconsole rc4.d/K69rpcsvcgssd rc4.d/K74ntpd rc4.d/K84wpa_supplicant rc4.d/K89rdisc rc4.d/K01smartd rc4.d/K15httpd rc4.d/K50snmpd rc4.d/K70vboxadd-x11 rc4.d/K75ntpdate rc4.d/K86cgred rc4.d/K95cgconfig rc4.d/K02oddjobd rc4.d/K16abrtd rc4.d/K50snmptrapd rc4.d/K73ypbind rc4.d/K80kdump rc4.d/K87restorecond rc4.d/K95firstboot rc4.d/K10psacct rc4.d/K50dnsmasq rc4.d/K60nfs rc4.d/K74nscd rc4.d/K80sssd rc4.d/K88nslcd dans rc5.d : rc5.d/K01certmonger rc5.d/K10saslauthd rc5.d/K50snmpd rc5.d/K73ypbind rc5.d/K80kdump rc5.d/K87restorecond rc5.d/K95firstboot rc5.d/K01smartd rc5.d/K15httpd rc5.d/K50snmptrapd rc5.d/K74nscd rc5.d/K80sssd rc5.d/K88nslcd rc5.d/K02oddjobd rc5.d/K50dnsmasq rc5.d/K60nfs rc5.d/K74ntpd rc5.d/K84wpa_supplicant rc5.d/K89rdisc rc5.d/K10psacct rc5.d/K50netconsole rc5.d/K69rpcsvcgssd rc5.d/K75ntpdate rc5.d/K86cgred rc5.d/K95cgconfig
root@debian6:/etc/init.d# for rep in /etc/rc[016].d; do echo "dans $rep :"; ls $rep/K*; done dans /etc/rc0.d : /etc/rc0.d/K01alsa-utils /etc/rc0.d/K02avahi-daemon /etc/rc0.d/K01anacron /etc/rc0.d/K02vboxadd /etc/rc0.d/K01atd /etc/rc0.d/K03sendsigs /etc/rc0.d/K01bluetooth /etc/rc0.d/K04rsyslog /etc/rc0.d/K01exim4 /etc/rc0.d/K05umountnfs.sh /etc/rc0.d/K01fuse /etc/rc0.d/K06nfs-common /etc/rc0.d/K01gdm3 /etc/rc0.d/K06portmap /etc/rc0.d/K01kerneloops /etc/rc0.d/K07hwclock.sh /etc/rc0.d/K01network-manager /etc/rc0.d/K07networking /etc/rc0.d/K01saned /etc/rc0.d/K08ifupdown /etc/rc0.d/K01unattended-upgrades /etc/rc0.d/K09umountfs /etc/rc0.d/K01urandom /etc/rc0.d/K10umountroot /etc/rc0.d/K01vboxadd-service /etc/rc0.d/K11halt dans /etc/rc1.d : /etc/rc1.d/K01alsa-utils /etc/rc1.d/K01network-manager /etc/rc1.d/K01anacron /etc/rc1.d/K01saned /etc/rc1.d/K01atd /etc/rc1.d/K01vboxadd-service /etc/rc1.d/K01bluetooth /etc/rc1.d/K02avahi-daemon /etc/rc1.d/K01cups /etc/rc1.d/K02vboxadd /etc/rc1.d/K01exim4 /etc/rc1.d/K04rsyslog /etc/rc1.d/K01gdm3 /etc/rc1.d/K06nfs-common /etc/rc1.d/K01kerneloops /etc/rc1.d/K06portmap dans /etc/rc6.d : /etc/rc6.d/K01alsa-utils /etc/rc6.d/K02avahi-daemon /etc/rc6.d/K01anacron /etc/rc6.d/K02vboxadd /etc/rc6.d/K01atd /etc/rc6.d/K03sendsigs /etc/rc6.d/K01bluetooth /etc/rc6.d/K04rsyslog /etc/rc6.d/K01exim4 /etc/rc6.d/K05umountnfs.sh /etc/rc6.d/K01fuse /etc/rc6.d/K06nfs-common /etc/rc6.d/K01gdm3 /etc/rc6.d/K06portmap /etc/rc6.d/K01kerneloops /etc/rc6.d/K07hwclock.sh /etc/rc6.d/K01network-manager /etc/rc6.d/K07networking /etc/rc6.d/K01saned /etc/rc6.d/K08ifupdown /etc/rc6.d/K01unattended-upgrades /etc/rc6.d/K09umountfs /etc/rc6.d/K01urandom /etc/rc6.d/K10umountroot /etc/rc6.d/K01vboxadd-service /etc/rc6.d/K11reboot
Important : Ici le principe est le même sauf que la lettre K indique au script rc que le script dans /etc/rc.d/init.d doit être lancé avec l'option stop.
Le script rc.local est lancé dans les niveaux d'exécution 2, 3, 4 et 5. C'est dans ce script que root peut ajouter des commandes.
Pour avoir une vue globale des services lancés par niveau d'exécution nous pouvons utiliser la commande chkconfig. Saisissez la commande suivante :
[root@centos5 rc.d]# chkconfig --list NetworkManager 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt abrtd 0:arrêt 1:arrêt 2:arrêt 3:marche 4:arrêt 5:marche 6:arrêt acpid 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt atd 0:arrêt 1:arrêt 2:arrêt 3:marche 4:marche 5:marche 6:arrêt auditd 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt autofs 0:arrêt 1:arrêt 2:arrêt 3:marche 4:marche 5:marche 6:arrêt avahi-daemon 0:arrêt 1:arrêt 2:arrêt 3:marche 4:marche 5:marche 6:arrêt bluetooth 0:arrêt 1:arrêt 2:arrêt 3:marche 4:marche 5:marche 6:arrêt certmonger 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt cgconfig 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt cgred 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt cpuspeed 0:arrêt 1:marche 2:marche 3:marche 4:marche 5:marche 6:arrêt crond 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt cups 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt dnsmasq 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt firstboot 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt haldaemon 0:arrêt 1:arrêt 2:arrêt 3:marche 4:marche 5:marche 6:arrêt httpd 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt ip6tables 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt iptables 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt irqbalance 0:arrêt 1:arrêt 2:arrêt 3:marche 4:marche 5:marche 6:arrêt kdump 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt lvm2-monitor 0:arrêt 1:marche 2:marche 3:marche 4:marche 5:marche 6:arrêt mdmonitor 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt messagebus 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt microcode_ctl 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt netconsole 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt netfs 0:arrêt 1:arrêt 2:arrêt 3:marche 4:marche 5:marche 6:arrêt network 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt nfs 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt nfslock 0:arrêt 1:arrêt 2:arrêt 3:marche 4:marche 5:marche 6:arrêt nscd 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt nslcd 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt ntpd 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt ntpdate 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt oddjobd 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt portreserve 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt postfix 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt psacct 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt rdisc 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt restorecond 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt rpcbind 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt rpcgssd 0:arrêt 1:arrêt 2:arrêt 3:marche 4:marche 5:marche 6:arrêt rpcidmapd 0:arrêt 1:arrêt 2:arrêt 3:marche 4:marche 5:marche 6:arrêt rpcsvcgssd 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt rsyslog 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt saslauthd 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt smartd 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt snmpd 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt snmptrapd 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt sshd 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt sssd 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt sysstat 0:arrêt 1:marche 2:marche 3:marche 4:marche 5:marche 6:arrêt udev-post 0:arrêt 1:marche 2:marche 3:marche 4:marche 5:marche 6:arrêt vboxadd 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt vboxadd-service 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt vboxadd-x11 0:arrêt 1:arrêt 2:arrêt 3:marche 4:arrêt 5:marche 6:arrêt wpa_supplicant 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt ypbind 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt
Sous Debian la commande chkconfig n'est pas installée par défaut. Il convient donc de l'installer en utilisant la commande apt-get :
root@debian6:/etc/init.d# apt-get install chkconfig Lecture des listes de paquets... Fait Construction de l'arbre des dépendances Lecture des informations d'état... Fait Les NOUVEAUX paquets suivants seront installés : chkconfig 0 mis à jour, 1 nouvellement installés, 0 à enlever et 219 non mis à jour. Il est nécessaire de prendre 9 182 o dans les archives. Après cette opération, 69,6 ko d'espace disque supplémentaires seront utilisés. Réception de : 1 http://ftp.fr.debian.org/debian/ squeeze/main chkconfig all 11.0-79.1-2 [9 182 B] 9 182 o réceptionnés en 50s (183 o/s) (Lecture de la base de données... 130287 fichiers et répertoires déjà installés.) Dépaquetage de chkconfig (à partir de .../chkconfig_11.0-79.1-2_all.deb) ... Traitement des actions différées (« triggers ») pour « man-db »... Paramétrage de chkconfig (11.0-79.1-2) ...
Saisissez maintenant la commande suivante :
root@debian6:/tmp# chkconfig --list acpid 0:off 1:off 2:on 3:on 4:on 5:on 6:off alsa-utils 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on anacron 0:off 1:off 2:on 3:on 4:on 5:on 6:off atd 0:off 1:off 2:on 3:on 4:on 5:on 6:off avahi-daemon 0:off 1:off 2:on 3:on 4:on 5:on 6:off binfmt-support 0:off 1:off 2:on 3:on 4:on 5:on 6:off bluetooth 0:off 1:off 2:on 3:on 4:on 5:on 6:off bootlogd 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on bootlogs 0:off 1:on 2:on 3:on 4:on 5:on 6:off bootmisc.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on checkfs.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on checkroot.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on console-screen.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on console-setup 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on cpufrequtils 0:off 1:off 2:on 3:on 4:on 5:on 6:off cron 0:off 1:off 2:on 3:on 4:on 5:on 6:off cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off dbus 0:off 1:off 2:on 3:on 4:on 5:on 6:off exim4 0:off 1:off 2:on 3:on 4:on 5:on 6:off fancontrol 0:off 1:off 2:on 3:on 4:on 5:on 6:off fuse 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on gdm3 0:off 1:off 2:on 3:on 4:on 5:on 6:off hdparm 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on hostname.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on hwclock.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on hwclockfirst.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on ifupdown 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on ifupdown-clean 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on kerneloops 0:off 1:off 2:on 3:on 4:on 5:on 6:off keyboard-setup 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on killprocs 0:off 1:on 2:off 3:off 4:off 5:off 6:off lm-sensors 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on loadcpufreq 0:off 1:off 2:on 3:on 4:on 5:on 6:off module-init-tools 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on mountall-bootclean.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on mountall.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on mountdevsubfs.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on mountkernfs.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on mountnfs-bootclean.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on mountnfs.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on mountoverflowtmp 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on mtab.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on network-manager 0:off 1:off 2:on 3:on 4:on 5:on 6:off networking 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on nfs-common 0:off 1:off 2:on 3:on 4:on 5:on 6:off S:on portmap 0:off 1:off 2:on 3:on 4:on 5:on 6:off S:on pppd-dns 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on procps 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on rc.local 0:off 1:off 2:on 3:on 4:on 5:on 6:off rcS 0:off 1:off 2:off 3:off 4:off 5:off 6:off rmnologin 0:off 1:off 2:on 3:on 4:on 5:on 6:off rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off saned 0:off 1:off 2:on 3:on 4:on 5:on 6:off sendsigs 0:off 1:off 2:off 3:off 4:off 5:off 6:off stop-bootlogd 0:off 1:off 2:on 3:on 4:on 5:on 6:off stop-bootlogd-single 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on sudo 0:off 1:off 2:on 3:on 4:on 5:on 6:off udev 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on udev-mtab 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on umountfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off umountnfs.sh 0:off 1:off 2:off 3:off 4:off 5:off 6:off umountroot 0:off 1:off 2:off 3:off 4:off 5:off 6:off unattended-upgrades 0:off 1:off 2:off 3:off 4:off 5:off 6:off urandom 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on vboxadd 0:off 1:off 2:on 3:on 4:on 5:on 6:off vboxadd-service 0:off 1:off 2:on 3:on 4:on 5:on 6:off vboxadd-x11 0:off 1:off 2:off 3:off 4:off 5:off 6:off x11-common 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on
Les options de la commande chkconfig sont :
[root@centos5 ~]# chkconfig --help chkconfig version 1.3.47 - Copyright (C) 1997-2000 Red Hat, Inc. Ce logiciel peut être librement distribué selon les termes de la licence publique GNU (GPL). utilisation : chkconfig [--list] [--type <type>] [nom] chkconfig --add <nom> chkconfig --del <nom> chkconfig --override <name> chkconfig [--level <niveaux>] [--type <type>] <nom> <on|off|reset|resetpriorities>
root@debian6:/tmp# chkconfig --help usage: chkconfig -A|--allservices (together with -l: show all services) chkconfig -t|--terse [names] (shows the links) chkconfig -e|--edit [names] (configure services) chkconfig -s|--set [name state]... (configure services) chkconfig -l|--list [--deps] [names] (shows the links) chkconfig -c|--check name [state] (check state) chkconfig -a|--add [names] (runs insserv) chkconfig -d|--del [names] (runs insserv -r) chkconfig -h|--help (print usage) chkconfig -f|--force ... (call insserv with -f) chkconfig [name] same as chkconfig -t chkconfig name state... same as chkconfig -s name state
Les options les plus importantes sont :
Option | Description |
---|---|
- -add (nom) | Permet d'ajouter un service aux runlevels définis par le service lui-même |
- -del (nom) | Permet de supprimer un service aux runlevels définis par le service lui-même |
- -level [niveau] (nom) [on|off|reset] | Permet d'activer, de désactiver ou de réinitialiser un service inscrit |
La commande update-rc.d est utilisée pour gérer les liens dans les répertoires rc[x].d. Cette commande permet d'insérer les liens vers un script dans /etc/init.d et prend la forme suivante :
update-rc.d <service> start <priorité de démarrage> <runlevels de démarrage> . stop <priorité d'arrêt> <runlevels d'arrêt> .
Par exemple la commande suivante crée les liens S dans rc2.d à rc5.d avec une priorité de 20 et les liens K dans rc0.d, rc1.d et rc6.d avec une priorité de 20 pour le script /etc/init.d/ssh :
# update-rc.d ssh start 20 2 3 4 5 . stop 20 0 1 6 . [Entrée]
Important : Il existe aussi un mot clef : default. Ce mot clef indique à update-rc.d d'utiliser les valeurs spécifiées dans la command précédente.
Pour supprimer les liens il convient d'utiliser la commande suivante :
# update-rc.d -f ssh remove [Entrée]
Important : Cette commande laisse le script ssh dans le répertoire /etc/init.d.
Les options de cette commande sont :
root@debian:/etc/init.d# update-rc.d --help update-rc.d: using dependency based boot sequencing update-rc.d: error: --help usage: update-rc.d [-n] [-f] <basename> remove update-rc.d [-n] <basename> defaults [NN | SS KK] update-rc.d [-n] <basename> start|stop NN runlvl [runlvl] [...] . update-rc.d [-n] <basename> disable|enable [S|2|3|4|5] -n: not really -f: force The disable|enable API is not stable and might change in the future.
Upstart est un processus Init mieux adapté aux exigences des périphériques modernes de type plug'n'play. Upstart peux faire tout ce que fait le processus Init SysVinit mais supporte d'avantage d'actions. Par exemple, Upstart est capable de démarrer un service quand un périphérique spécifique est branché à chaud. Upstart est néanmoins compatible avec les scripts de démarrage du système SysVinit et ceux-ci fonctionnement normalement en attendant que les éditeurs de logiciels tierces portent les scripts SysVinit vers Upstart.
Sous Upstart, le fichier /etc/inittab ne permet plus de définir les services à démarrer en fonction du RUNLEVEL, seule la définition d'initdefault y est spécifiée :
[root@centos6 ~]# cat /etc/inittab # inittab is only used by upstart for the default runlevel. # # ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM. # # System initialization is started by /etc/init/rcS.conf # # Individual runlevels are started by /etc/init/rc.conf # # Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf # # Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf, # with configuration in /etc/sysconfig/init. # # For information on how to write upstart event handlers, or how # upstart works, see init(5), init(8), and initctl(8). # # Default runlevel. The runlevels used are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:5:initdefault:
[root@centos6 ~]# cat /etc/inittab # inittab is only used by upstart for the default runlevel. # # ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM. # # System initialization is started by /etc/init/rcS.conf # # Individual runlevels are started by /etc/init/rc.conf # # Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf # # Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf, # with configuration in /etc/sysconfig/init. # # For information on how to write upstart event handlers, or how # upstart works, see init(5), init(8), and initctl(8). # # Default runlevel. The runlevels used are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:5:initdefault:
Sous Upstart, les définitions des autres valeurs habituellement incluses dans /etc/inittab se trouvent dans des fichiers de configuration supplémentaires qui se trouvent dans le répertoire /etc/init/ :
[root@centos6 ~]# ls -l /etc/init total 68 -rw-r--r--. 1 root root 412 22 juil. 2014 control-alt-delete.conf -rw-r--r--. 1 root root 130 12 mars 2014 init-system-dbus.conf -rw-r--r--. 1 root root 463 22 juil. 2014 kexec-disable.conf -rw-r--r--. 1 root root 560 22 juil. 2014 plymouth-shutdown.conf -rw-r--r--. 1 root root 357 22 juil. 2014 prefdm.conf -rw-r--r--. 1 root root 505 22 juil. 2014 quit-plymouth.conf -rw-r--r--. 1 root root 417 22 juil. 2014 rc.conf -rw-r--r--. 1 root root 1046 22 juil. 2014 rcS.conf -rw-r--r--. 1 root root 430 22 juil. 2014 rcS-emergency.conf -rw-r--r--. 1 root root 725 22 juil. 2014 rcS-sulogin.conf -rw-r--r--. 1 root root 2915 23 nov. 2013 readahead-collector.conf -rw-r--r--. 1 root root 1559 23 nov. 2013 readahead.conf -rw-r--r--. 1 root root 726 23 nov. 2013 readahead-disable-services.conf -rw-r--r--. 1 root root 1302 22 juil. 2014 serial.conf -rw-r--r--. 1 root root 791 22 juil. 2014 splash-manager.conf -rw-r--r--. 1 root root 473 22 juil. 2014 start-ttys.conf -rw-r--r--. 1 root root 335 22 juil. 2014 tty.conf
L'initialisation du système est configurée dans le fichier /etc/init/rcS.conf :
[root@centos6 init]# cat /etc/init/rcS.conf # rcS - runlevel compatibility # # This task runs the old sysv-rc startup scripts. start on startup stop on runlevel task # Note: there can be no previous runlevel here, if we have one it's bad # information (we enter rc1 not rcS for maintenance). Run /etc/rc.d/rc # without information so that it defaults to previous=N runlevel=S. console output exec /etc/rc.d/rc.sysinit post-stop script if [ "$UPSTART_EVENTS" = "startup" ]; then [ -f /etc/inittab ] && runlevel=$(/bin/awk -F ':' '$3 == "initdefault" && $1 !~ "^#" { print $2 }' /etc/inittab) [ -z "$runlevel" ] && runlevel="3" for t in $(cat /proc/cmdline); do case $t in -s|single|S|s) runlevel="S" ;; [1-9]) runlevel="$t" ;; esac done exec telinit $runlevel fi end script
La gestion des Runlevels est configurée dans le fichier /etc/init/rc.conf :
[root@centos6 init]# cat /etc/init/rc.conf # rc - System V runlevel compatibility # # This task runs the old sysv-rc runlevel scripts. It # is usually started by the telinit compatibility wrapper. start on runlevel [0123456] stop on runlevel [!$RUNLEVEL] task export RUNLEVEL console output exec /etc/rc.d/rc $RUNLEVEL
Le comportement associé avec la combinaison de touches [CTL]-[ALT]-[DEL] est configuré dans le fichier /etc/init/control-alt-delete.conf :
[root@centos6 init]# cat /etc/init/control-alt-delete.conf # control-alt-delete - emergency keypress handling # # This task is run whenever the Control-Alt-Delete key combination is # pressed. Usually used to shut down the machine. start on control-alt-delete exec /sbin/shutdown -r now "Control-Alt-Delete pressed"
Le génération des terminaux getty est spécifiée dans les fichiers /etc/init/tty.conf et /etc/init/serial.conf :
[root@centos6 init]# cat /etc/init/tty.conf # tty - getty # # This service maintains a getty on the sepcified device. stop on runlevel [016] respawn instance $TTY exec /sbin/mingetty $TTY [root@centos rc.d]# cat /etc/init/serial.conf # Automatically start a configured serial console # # How this works: # # On boot, a udev helper examines /dev/console. If a serial console is the # primary console (last console on the commandline in grub), the event # 'fedora.serial-console-available <port name> <speed>' is emitted, which # triggers this script. It waits for the runlevel to finish, ensures # the proper port is in /etc/securetty, and starts the getty. # # If your serial console is not the primary console, or you want a getty # on serial even if it's not the console, create your own event by copying # /etc/init/tty.conf, and changing the getty line in that file. start on fedora.serial-console-available DEV=* and stopped rc RUNLEVEL=[2345] stop on runlevel [016] instance $DEV respawn pre-start exec /sbin/securetty $DEV exec /sbin/agetty /dev/$DEV $SPEED vt100-nav
La configuration des terminaux fait partie du fichier /etc/sysconfig/init
[root@centos6 init]# cat /etc/sysconfig/init # color => new RH6.0 bootup # verbose => old-style bootup # anything else => new style bootup without ANSI colors or positioning BOOTUP=color # column to start "[ OK ]" label in RES_COL=60 # terminal sequence to move to that column. You could change this # to something like "tput hpa ${RES_COL}" if your terminal supports it MOVE_TO_COL="echo -en \\033[${RES_COL}G" # terminal sequence to set color to a 'success' color (currently: green) SETCOLOR_SUCCESS="echo -en \\033[0;32m" # terminal sequence to set color to a 'failure' color (currently: red) SETCOLOR_FAILURE="echo -en \\033[0;31m" # terminal sequence to set color to a 'warning' color (currently: yellow) SETCOLOR_WARNING="echo -en \\033[0;33m" # terminal sequence to reset to the default color. SETCOLOR_NORMAL="echo -en \\033[0;39m" # Set to anything other than 'no' to allow hotkey interactive startup... PROMPT=yes # Set to 'yes' to allow probing for devices with swap signatures AUTOSWAP=no # What ttys should gettys be started on? ACTIVE_CONSOLES=/dev/tty[1-6] # Set to '/sbin/sulogin' to prompt for password on single-user mode # Set to '/sbin/sushell' otherwise SINGLE=/sbin/sushell
Sous Upstart, les services sont appelés des jobs. Les scripts de démarrage de jobs au format Upstart sont placés dans le répertoire /etc/init/ et ont une forme nom.conf où nom est le nom du job :
[root@centos6 ~]# ls /etc/init control-alt-delete.conf rcS-sulogin.conf init-system-dbus.conf readahead-collector.conf kexec-disable.conf readahead.conf plymouth-shutdown.conf readahead-disable-services.conf prefdm.conf serial.conf quit-plymouth.conf splash-manager.conf rc.conf start-ttys.conf rcS.conf tty.conf rcS-emergency.conf
Pour créer un fichier job, il convient de respecter un certain format. Par exemple créez le fichier /etc/init/testjob.conf :
description "Un job pour tester Upstart" author "Linux E-Learning" start on runlevel [2345] exec echo Le job test a été lancé le `date` >> /var/log/testjob.log
Pour obtenir une liste de tous les jobs et leurs états, il convient d'utiliser la commande initctl. Vérifiez donc que le job testjob se trouve dans la sortie de cette commande :
[root@centos6 ~]# initctl list rc stop/waiting tty (/dev/tty3) start/running, process 1833 tty (/dev/tty2) start/running, process 1828 tty (/dev/tty6) start/running, process 1854 tty (/dev/tty5) start/running, process 1845 tty (/dev/tty4) start/running, process 1838 plymouth-shutdown stop/waiting control-alt-delete stop/waiting rcS-emergency stop/waiting readahead-collector stop/waiting kexec-disable stop/waiting quit-plymouth stop/waiting testjob stop/waiting rcS stop/waiting prefdm start/running, process 1814 init-system-dbus stop/waiting readahead stop/waiting splash-manager stop/waiting start-ttys stop/waiting readahead-disable-services stop/waiting rcS-sulogin stop/waiting serial stop/waiting
Les options de la commande initctl sont :
[root@centos6 ~]# initctl --help Usage: initctl [OPTION]... COMMAND [OPTION]... [ARG]... Options: --system use D-Bus system bus to connect to init daemon --dest=NAME destination well-known name on system bus -q, --quiet reduce output to errors only -v, --verbose increase output to include informational messages --help display this help and exit --version output version information and exit For a list of commands, try `initctl help'. Report bugs at <https://launchpad.net/upstart/+bugs>
Il existe trois types de jobs sous Upstart :
Un événement ou event en anglais est un signal envoyé vers un job pour déclencher une action. Par exemple :
L'objectif d'un job est de démarrer ou de s'arrêter. Entre ces deux objectifs se trouvent des états intermédiaires :
Compte tenu de la compatibilité avec le système SysVinit, les commandes traditionnellement utilisées avec ce dernier sont compris par Upstart. Ceci étant Upstart fournit ses propres commandes pour le contrôle des jobs.
Pour voir le status d'un job spécifique, utilisez la commande suivante :
[root@centos6 ~]# status testjob testjob stop/waiting
Les options de la commande status sont :
[root@centos6 ~]# status --help Usage: status [OPTION]... JOB [KEY=VALUE]... Query status of job. Options: --system use D-Bus system bus to connect to init daemon --dest=NAME destination well-known name on system bus -q, --quiet reduce output to errors only -v, --verbose increase output to include informational messages --help display this help and exit --version output version information and exit JOB is the name of the job that is to be queried, this may be followed by zero or more environment variables to distguish between job instances. Report bugs at <https://launchpad.net/upstart/+bugs>
[root@centos6 ~]# start testjob testjob start/running, process 2981 [root@centos ~]# cat /var/log/testjob.log Le job test a été lancé le Tue Jun 30 15:26:10 CEST 2015
Les options de la commande start sont :
[root@centos6 ~]# start --help Usage: start [OPTION]... JOB [KEY=VALUE]... Start job. Options: -n, --no-wait do not wait for job to start before exiting --system use D-Bus system bus to connect to init daemon --dest=NAME destination well-known name on system bus -q, --quiet reduce output to errors only -v, --verbose increase output to include informational messages --help display this help and exit --version output version information and exit JOB is the name of the job that is to be started, this may be followed by zero or more environment variables to be defined in the new job. The environment may also serve to distinguish between job instances, and thus decide whether a new instance will be started or an error returned if an existing instance is already running. Report bugs at <https://launchpad.net/upstart/+bugs>
Pour arrêter un job, utilisez la commande stop.
Les options de la commande stop sont :
[root@centos6 ~]# stop --help Usage: stop [OPTION]... JOB [KEY=VALUE]... Stop job. Options: -n, --no-wait do not wait for job to stop before exiting --system use D-Bus system bus to connect to init daemon --dest=NAME destination well-known name on system bus -q, --quiet reduce output to errors only -v, --verbose increase output to include informational messages --help display this help and exit --version output version information and exit JOB is the name of the job that is to be stopped, this may be followed by zero or more environment variables to be passed to the job's pre-stop and post-stop processes. The environment also serves to distinguish between job instances, and thus decide which of multiple instances will be stopped. Report bugs at <https://launchpad.net/upstart/+bugs>
Pour redémarrer un job, utilisez la commande restart.
Les options de la commande restart sont :
[root@centos6 ~]# restart --help Usage: restart [OPTION]... JOB [KEY=VALUE]... Restart job. Options: -n, --no-wait do not wait for job to restart before exiting --system use D-Bus system bus to connect to init daemon --dest=NAME destination well-known name on system bus -q, --quiet reduce output to errors only -v, --verbose increase output to include informational messages --help display this help and exit --version output version information and exit JOB is the name of the job that is to be restarted, this may be followed by zero or more environment variables to be defined in the job after restarting. The environment also serves to distinguish between job instances, and thus decide which of multiple instances will be restarted. Report bugs at <https://launchpad.net/upstart/+bugs>
Il est aussi possible d'utiliser les commandes initctl start, initctl stop et initctl restart pour gérer les jobs.
RHEL/CentOS 7, comme beaucoup d'autres distributions, ont abandonné Upstart pour Systemd. Ce dernier prend une approche différente au démarrage de Linux. En effet, SysVinit et Upstart sont des systèmes de démarrage séquentiels. Systemd essaie, par contre, de démarrer autant de services en parallèle que possible. Ceci est rendu possible car la majorité d'architectures matérielles modernes sont multi-cœurs. Si un service dépend d'un autre qui n'est pas encore démarré ce premier est mis en attente dans une mémoire tampon. Qui plus est, les services qui ne sont pas nécessaires au démarrage de la machine, tel cups, ne sont démarrés ultérieurement que si nécessaire. Lors de démarrage, les partitions sont montées en parallèle. Dernièrement, Systemd remplace les scripts de démarrage traditionnels avec des binaires compilés, beaucoup plus rapides que leur prédécesseurs.
Au lieu de parler de scripts de démarrage et de niveaux d'exécution, Systemd utilise la terminologie Unités (Units) et Cibles (Targets). Une Cible est en quelque sorte une grande étape dans le démarrage du système tandis qu'une Unité peut être :
Important : Dans le contexte d'une Unité, le type cible regroupe des Unités multiples afin qu'elles puissent être démarrées en même temps. Par exemple network.target regroupe toutes les Unités nécessaires pour démarrer toutes les interfaces réseaux en même temps.
Pour visualiser la liste des Unités, il convient d'utiliser la commande systemctl avec l'option list-units :
[root@centos7 ~]# systemctl list-units UNIT LOAD ACTIVE SUB DESCRIPTION proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File System Automount Point sys-devices-pci0000:...t1-target1:0:0-1:0:0:0-block-sr0.device loaded active plugged VBOX_CD-ROM sys-devices-pci0000:00-0000:00:03.0-net-enp0s3.device loaded active plugged PRO/1000 MT Desktop Adapter sys-devices-pci0000:00-0000:00:05.0-sound-card0.device loaded active plugged 82801AA AC'97 Audio Controller sys-devices-pci0000:...rget2:0:0-2:0:0:0-block-sda-sda1.device loaded active plugged VBOX_HARDDISK sys-devices-pci0000:...rget2:0:0-2:0:0:0-block-sda-sda2.device loaded active plugged VBOX_HARDDISK sys-devices-pci0000:...rget2:0:0-2:0:0:0-block-sda-sda3.device loaded active plugged VBOX_HARDDISK sys-devices-pci0000:...t2-target2:0:0-2:0:0:0-block-sda.device loaded active plugged VBOX_HARDDISK sys-devices-platform-serial8250-tty-ttyS0.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS0 sys-devices-platform-serial8250-tty-ttyS1.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS1 sys-devices-platform-serial8250-tty-ttyS2.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS2 sys-devices-platform-serial8250-tty-ttyS3.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS3 sys-module-configfs.device loaded active plugged /sys/module/configfs sys-module-fuse.device loaded active plugged /sys/module/fuse sys-subsystem-net-devices-enp0s3.device loaded active plugged PRO/1000 MT Desktop Adapter -.mount loaded active mounted / boot.mount loaded active mounted /boot dev-hugepages.mount loaded active mounted Huge Pages File System dev-mqueue.mount loaded active mounted POSIX Message Queue File System proc-fs-nfsd.mount loaded active mounted NFSD configuration filesystem run-media-trainee-VBOXADDITIONS_4.3.28_100309.mount loaded active mounted /run/media/trainee/VBOXADDITIONS_4.3.28_100309 run-user-1000-gvfs.mount loaded active mounted /run/user/1000/gvfs sys-fs-fuse-connections.mount loaded active mounted FUSE Control File System sys-kernel-config.mount loaded active mounted Configuration File System sys-kernel-debug.mount loaded active mounted Debug File System var-lib-nfs-rpc_pipefs.mount loaded active mounted RPC Pipe File System brandbot.path loaded active waiting Flexible branding cups.path loaded active waiting CUPS Printer Service Spool systemd-ask-password-plymouth.path loaded active waiting Forward Password Requests to Plymouth Directory Watch systemd-ask-password-wall.path loaded active waiting Forward Password Requests to Wall Directory Watch session-1.scope loaded active running Session 1 of user trainee abrt-ccpp.service loaded active exited Install ABRT coredump hook abrt-oops.service loaded active running ABRT kernel log watcher abrt-xorg.service loaded active running ABRT Xorg log watcher abrtd.service loaded active running ABRT Automated Bug Reporting Tool accounts-daemon.service loaded active running Accounts Service alsa-state.service loaded active running Manage Sound Card State (restore and store) atd.service loaded active running Job spooling tools auditd.service loaded active running Security Auditing Service avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack bluetooth.service loaded active running Bluetooth service chronyd.service loaded active running NTP client/server colord.service loaded active running Manage, Install and Generate Color Profiles crond.service loaded active running Command Scheduler cups.service loaded active running CUPS Printing Service dbus.service loaded active running D-Bus System Message Bus firewalld.service loaded active running firewalld - dynamic firewall daemon gdm.service loaded active running GNOME Display Manager gssproxy.service loaded active running GSSAPI Proxy Daemon iscsi-shutdown.service loaded active exited Logout off all iSCSI sessions on shutdown kdump.service loaded failed failed Crash recovery kernel arming kmod-static-nodes.service loaded active exited Create list of required static device nodes for the current ker ksm.service loaded active exited Kernel Samepage Merging ksmtuned.service loaded active running Kernel Samepage Merging (KSM) Tuning Daemon libstoragemgmt.service loaded active running libstoragemgmt plug-in server daemon libvirtd.service loaded active running Virtualization daemon lvm2-lvmetad.service loaded active running LVM2 metadata daemon
root@debian8:~# systemctl list-units UNIT LOAD ACTIVE SUB DESCRIPTION proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File System Automount Point sys-devices-pci0000:00-0000:00:01.1-ata3-host2-target2:0:0-2:0:0:0-block-sr0.device loaded active plugged VBOX_CD-ROM sys-devices-pci0000:00-0000:00:03.0-net-eth0.device loaded active plugged 82540EM Gigabit Ethernet Controller (PRO/1000 MT Desktop Adapte sys-devices-pci0000:00-0000:00:05.0-sound-card0.device loaded active plugged 82801AA AC'97 Audio Controller sys-devices-pci0000:00-0000:00:0d.0-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda1.device loaded active plugged VBOX_HARDDISK 1 sys-devices-pci0000:00-0000:00:0d.0-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda2.device loaded active plugged VBOX_HARDDISK 2 sys-devices-pci0000:00-0000:00:0d.0-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda5.device loaded active plugged VBOX_HARDDISK 5 sys-devices-pci0000:00-0000:00:0d.0-ata1-host0-target0:0:0-0:0:0:0-block-sda.device loaded active plugged VBOX_HARDDISK sys-devices-platform-serial8250-tty-ttyS0.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS0 sys-devices-platform-serial8250-tty-ttyS1.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS1 sys-devices-platform-serial8250-tty-ttyS2.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS2 sys-devices-platform-serial8250-tty-ttyS3.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS3 sys-module-fuse.device loaded active plugged /sys/module/fuse sys-subsystem-net-devices-eth0.device loaded active plugged 82540EM Gigabit Ethernet Controller (PRO/1000 MT Desktop Adapte -.mount loaded active mounted / dev-hugepages.mount loaded active mounted Huge Pages File System dev-mqueue.mount loaded active mounted POSIX Message Queue File System etc-machine\x2did.mount loaded active mounted /etc/machine-id run-rpc_pipefs.mount loaded active mounted /run/rpc_pipefs run-user-1000.mount loaded active mounted /run/user/1000 run-user-120.mount loaded active mounted /run/user/120 sys-fs-fuse-connections.mount loaded active mounted FUSE Control File System sys-kernel-debug.mount loaded active mounted Debug File System cups.path loaded active waiting CUPS Printer Service Spool systemd-ask-password-console.path loaded active waiting Dispatch Password Requests to Console Directory Watch systemd-ask-password-wall.path loaded active waiting Forward Password Requests to Wall Directory Watch session-2.scope loaded active running Session 2 of user trainee session-c1.scope loaded active abandoned Session c1 of user lightdm accounts-daemon.service loaded active running Accounts Service atd.service loaded active running Deferred execution scheduler lines 1-31
Pour consulter la liste des Unités inactifs, utilisez la commande suivante :
[root@centos7 ~]# systemctl list-units --all | grep inactive | more proc-sys-fs-binfmt_misc.mount loaded inactive dead Arbitrary Executable File Formats File System systemd-ask-password-console.path loaded inactive dead Dispatch Password Requests to Cons ole Directory Watch abrt-vmcore.service loaded inactive dead Harvest vmcores for ABRT alsa-restore.service loaded inactive dead Restore Sound Card State alsa-store.service loaded inactive dead Store Sound Card State apparmor.service not-found inactive dead apparmor.service auth-rpcgss-module.service loaded inactive dead Kernel Module supporting RPCSEC_GS S brandbot.service loaded inactive dead Flexible Branding Service cpupower.service loaded inactive dead Configure CPU power related settin gs dm-event.service loaded inactive dead Device-mapper event daemon dmraid-activation.service loaded inactive dead Activation of DM RAID sets dracut-shutdown.service loaded inactive dead Restore /run/initramfs ebtables.service loaded inactive dead Ethernet Bridge Filtering tables emergency.service loaded inactive dead Emergency Shell exim.service not-found inactive dead exim.service getty@tty1.service loaded inactive dead Getty on tty1 hypervkvpd.service loaded inactive dead Hyper-V KVP daemon hypervvssd.service loaded inactive dead Hyper-V VSS daemon ip6tables.service loaded inactive dead IPv6 firewall with ip6tables iptables.service loaded inactive dead IPv4 firewall with iptables irqbalance.service loaded inactive dead irqbalance daemon iscsi.service loaded inactive dead Login and scanning of iSCSI device s iscsid.service loaded inactive dead Open-iSCSI iscsiuio.service loaded inactive dead iSCSI UserSpace I/O driver --More--
root@debian8:~# systemctl list-units --all | grep inactive | more proc-sys-fs-binfmt_misc.mount loaded inactive dead Arbitrary Executable File Form ats File System run-vmblock\x2dfuse.mount loaded inactive dead VMware vmblock fuse mount sys-kernel-config.mount loaded inactive dead Configuration File System tmp.mount loaded inactive dead Temporary Directory ● var-lock.mount not-found inactive dead var-lock.mount ● var-run.mount not-found inactive dead var-run.mount systemd-ask-password-plymouth.path loaded inactive dead Forward Password Requests to P lymouth Directory Watch alsa-restore.service loaded inactive dead Restore Sound Card State alsa-state.service loaded inactive dead Manage Sound Card State (resto re and store) alsa-store.service loaded inactive dead Store Sound Card State anacron.service loaded inactive dead Run anacron jobs ● bootmisc.service masked inactive dead bootmisc.service ● clamav-daemon.service not-found inactive dead clamav-daemon.service ● console-screen.service not-found inactive dead console-screen.service debian-fixup.service loaded inactive dead Various fixups to make systemd work better on Debian emergency.service loaded inactive dead Emergency Shell ● festival.service not-found inactive dead festival.service getty-static.service loaded inactive dead getty on tty2-tty6 if dbus and logind are not available ● greylist.service not-found inactive dead greylist.service ● keymap.service not-found inactive dead keymap.service ● mountkernfs.service masked inactive dead mountkernfs.service ● mysql.service not-found inactive dead mysql.service open-vm-tools.service loaded inactive dead Service for virtual machines h osted on VMware plymouth-quit-wait.service loaded inactive dead Wait for Plymouth Boot Screen to Quit --More--
Pour consulter la liste des fichiers Unités, utilisez la commande suivante :
[root@centos7 ~]# systemctl list-unit-files | more UNIT FILE STATE proc-sys-fs-binfmt_misc.automount static dev-hugepages.mount static dev-mqueue.mount static proc-fs-nfsd.mount static proc-sys-fs-binfmt_misc.mount static sys-fs-fuse-connections.mount static sys-kernel-config.mount static sys-kernel-debug.mount static tmp.mount disabled var-lib-nfs-rpc_pipefs.mount static brandbot.path disabled cups.path enabled systemd-ask-password-console.path static systemd-ask-password-plymouth.path static systemd-ask-password-wall.path static session-1.scope static session-8.scope static abrt-ccpp.service enabled abrt-oops.service enabled abrt-pstoreoops.service disabled abrt-vmcore.service enabled abrt-xorg.service enabled abrtd.service enabled accounts-daemon.service enabled alsa-restore.service static alsa-state.service static alsa-store.service static anaconda-direct.service static --More--
root@debian8:~# systemctl list-unit-files | more UNIT FILE STATE proc-sys-fs-binfmt_misc.automount static dev-hugepages.mount static dev-mqueue.mount static proc-sys-fs-binfmt_misc.mount static run-vmblock\x2dfuse.mount enabled sys-fs-fuse-connections.mount static sys-kernel-config.mount static sys-kernel-debug.mount static tmp.mount disabled cups.path enabled systemd-ask-password-console.path static systemd-ask-password-plymouth.path static systemd-ask-password-wall.path static session-2.scope static session-c1.scope static accounts-daemon.service enabled alsa-restore.service static alsa-state.service static alsa-store.service static alsa-utils.service masked anacron-resume.service enabled anacron.service enabled atd.service enabled auditd.service enabled autovt@.service disabled avahi-daemon.service enabled bluetooth.service enabled bootlogd.service masked bootlogs.service masked bootmisc.service masked --More--
Les options de la commande systemctl sont :
[root@centos7 ~]# systemctl --help systemctl [OPTIONS...] {COMMAND} ... Query or send control commands to the systemd manager. -h --help Show this help --version Show package version -t --type=TYPE List only units of a particular type --state=STATE List only units with particular LOAD or SUB or ACTIVE state -p --property=NAME Show only properties by this name -a --all Show all loaded units/properties, including dead/empty ones. To list all units installed on the system, use the 'list-unit-files' command instead. --reverse Show reverse dependencies with 'list-dependencies' -l --full Don't ellipsize unit names on output --fail When queueing a new job, fail if conflicting jobs are pending --irreversible When queueing a new job, make sure it cannot be implicitly cancelled --ignore-dependencies When queueing a new job, ignore all its dependencies --show-types When showing sockets, explicitly show their type -i --ignore-inhibitors When shutting down or sleeping, ignore inhibitors --kill-who=WHO Who to send signal to -s --signal=SIGNAL Which signal to send -H --host=[USER@]HOST Show information for remote host -P --privileged Acquire privileges before execution -q --quiet Suppress output --no-block Do not wait until operation finished --no-wall Don't send wall message before halt/power-off/reboot --no-reload When enabling/disabling unit files, don't reload daemon configuration --no-legend Do not print a legend (column headers and hints) --no-pager Do not pipe output into a pager --no-ask-password Do not ask for system passwords --system Connect to system manager --user Connect to user service manager --global Enable/disable unit files globally --runtime Enable unit files only temporarily until next reboot -f --force When enabling unit files, override existing symlinks When shutting down, execute action immediately --root=PATH Enable unit files in the specified root directory -n --lines=INTEGER Number of journal entries to show -o --output=STRING Change journal output mode (short, short-monotonic, verbose, export, json, json-pretty, json-sse, cat) --plain Print unit dependencies as a list instead of a tree Unit Commands: list-units List loaded units list-sockets List loaded sockets ordered by address start [NAME...] Start (activate) one or more units stop [NAME...] Stop (deactivate) one or more units reload [NAME...] Reload one or more units restart [NAME...] Start or restart one or more units try-restart [NAME...] Restart one or more units if active reload-or-restart [NAME...] Reload one or more units if possible, otherwise start or restart reload-or-try-restart [NAME...] Reload one or more units if possible, otherwise restart if active isolate [NAME] Start one unit and stop all others kill [NAME...] Send signal to processes of a unit is-active [NAME...] Check whether units are active is-failed [NAME...] Check whether units are failed status [NAME...|PID...] Show runtime status of one or more units show [NAME...|JOB...] Show properties of one or more units/jobs or the manager set-property [NAME] [ASSIGNMENT...] Sets one or more properties of a unit help [NAME...|PID...] Show manual for one or more units reset-failed [NAME...] Reset failed state for all, one, or more units list-dependencies [NAME] Recursively show units which are required or wanted by this unit or by which this unit is required or wanted Unit File Commands: list-unit-files List installed unit files enable [NAME...] Enable one or more unit files disable [NAME...] Disable one or more unit files reenable [NAME...] Reenable one or more unit files preset [NAME...] Enable/disable one or more unit files based on preset configuration is-enabled [NAME...] Check whether unit files are enabled mask [NAME...] Mask one or more units unmask [NAME...] Unmask one or more units link [PATH...] Link one or more units files into the search path get-default Get the name of the default target set-default NAME Set the default target Job Commands: list-jobs List jobs cancel [JOB...] Cancel all, one, or more jobs Snapshot Commands: snapshot [NAME] Create a snapshot delete [NAME...] Remove one or more snapshots Environment Commands: show-environment Dump environment set-environment [NAME=VALUE...] Set one or more environment variables unset-environment [NAME...] Unset one or more environment variables Manager Lifecycle Commands: daemon-reload Reload systemd manager configuration daemon-reexec Reexecute systemd manager System Commands: default Enter system default mode rescue Enter system rescue mode emergency Enter system emergency mode halt Shut down and halt the system poweroff Shut down and power-off the system reboot Shut down and reboot the system kexec Shut down and reboot the system with kexec exit Request user instance exit switch-root [ROOT] [INIT] Change to a different root file system suspend Suspend the system hibernate Hibernate the system hybrid-sleep Hibernate and suspend the system lines 95-123/123 (END)
root@debian8:~# systemctl --help systemctl [OPTIONS...] {COMMAND} ... Query or send control commands to the systemd manager. -h --help Show this help --version Show package version --system Connect to system manager --user Connect to user service manager -H --host=[USER@]HOST Operate on remote host -M --machine=CONTAINER Operate on local container -t --type=TYPE List only units of a particular type --state=STATE List only units with particular LOAD or SUB or ACTIVE state -p --property=NAME Show only properties by this name -a --all Show all loaded units/properties, including dead/empty ones. To list all units installed on the system, use the 'list-unit-files' command instead. -l --full Don't ellipsize unit names on output -r --recursive Show unit list of host and local containers --reverse Show reverse dependencies with 'list-dependencies' --job-mode=MODE Specify how to deal with already queued jobs, when queueing a new job --show-types When showing sockets, explicitly show their type -i --ignore-inhibitors When shutting down or sleeping, ignore inhibitors --kill-who=WHO Who to send signal to -s --signal=SIGNAL Which signal to send -q --quiet Suppress output --no-block Do not wait until operation finished --no-wall Don't send wall message before halt/power-off/reboot lines 1-31
Les Cibles et les Unités sont configurées par des fichiers se trouvant dans le répertoire /etc/systemd/system :
[root@centos7 ~]# ls -l /etc/systemd/system total 12 drwxr-xr-x. 2 root root 54 Mar 8 13:57 basic.target.wants drwxr-xr-x. 2 root root 30 Mar 8 13:53 bluetooth.target.wants lrwxrwxrwx. 1 root root 41 Mar 8 13:53 dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service lrwxrwxrwx. 1 root root 41 Mar 8 13:48 dbus-org.fedoraproject.FirewallD1.service -> /usr/lib/systemd/system/firewalld.service lrwxrwxrwx. 1 root root 44 Mar 8 13:48 dbus-org.freedesktop.Avahi.service -> /usr/lib/systemd/system/avahi-daemon.service lrwxrwxrwx. 1 root root 44 Mar 8 13:57 dbus-org.freedesktop.ModemManager1.service -> /usr/lib/systemd/system/ModemManager.service lrwxrwxrwx. 1 root root 46 Mar 8 13:49 dbus-org.freedesktop.NetworkManager.service -> /usr/lib/systemd/system/NetworkManager.service lrwxrwxrwx. 1 root root 57 Mar 8 13:49 dbus-org.freedesktop.nm-dispatcher.service -> /usr/lib/systemd/system/NetworkManager-dispatcher.service lrwxrwxrwx. 1 root root 36 Mar 8 14:05 default.target -> /lib/systemd/system/graphical.target drwxr-xr-x. 2 root root 85 Mar 8 13:47 default.target.wants lrwxrwxrwx. 1 root root 35 Mar 8 13:54 display-manager.service -> /usr/lib/systemd/system/gdm.service drwxr-xr-x. 2 root root 31 Mar 8 13:47 getty.target.wants drwxr-xr-x. 2 root root 63 Jun 4 14:59 graphical.target.wants drwxr-xr-x. 2 root root 4096 Jun 4 10:00 multi-user.target.wants drwxr-xr-x. 2 root root 29 Mar 8 13:48 nfs.target.wants drwxr-xr-x. 2 root root 25 Mar 8 13:50 printer.target.wants drwxr-xr-x. 2 root root 30 Jun 4 10:00 remote-fs.target.wants drwxr-xr-x. 2 root root 4096 Mar 8 13:50 sockets.target.wants drwxr-xr-x. 2 root root 35 Mar 8 13:57 spice-vdagentd.target.wants drwxr-xr-x. 2 root root 4096 Mar 8 13:49 sysinit.target.wants drwxr-xr-x. 2 root root 83 Mar 8 13:49 system-update.target.wants
root@debian8:~# ls -l /etc/systemd/system total 52 drwxr-xr-x 2 root root 4096 Oct 23 16:34 bluetooth.target.wants lrwxrwxrwx 1 root root 37 Oct 23 16:34 dbus-org.bluez.service -> /lib/systemd/system/bluetooth.service lrwxrwxrwx 1 root root 40 Oct 23 16:34 dbus-org.freedesktop.Avahi.service -> /lib/systemd/system/avahi-daemon.service lrwxrwxrwx 1 root root 40 Oct 23 16:34 dbus-org.freedesktop.ModemManager1.service -> /lib/systemd/system/ModemManager.service lrwxrwxrwx 1 root root 53 Oct 23 16:34 dbus-org.freedesktop.nm-dispatcher.service -> /lib/systemd/system/NetworkManager-dispatcher.service lrwxrwxrwx 1 root root 35 Oct 23 16:34 display-manager.service -> /lib/systemd/system/lightdm.service drwxr-xr-x 2 root root 4096 Oct 23 16:34 getty.target.wants drwxr-xr-x 2 root root 4096 Oct 23 16:34 graphical.target.wants drwxr-xr-x 2 root root 4096 Oct 23 16:34 halt.target.wants drwxr-xr-x 2 root root 4096 Oct 23 16:34 hibernate.target.wants drwxr-xr-x 2 root root 4096 Oct 23 16:34 hybrid-sleep.target.wants drwxr-xr-x 2 root root 4096 Oct 28 06:37 multi-user.target.wants drwxr-xr-x 2 root root 4096 Oct 23 16:34 paths.target.wants drwxr-xr-x 2 root root 4096 Oct 23 16:34 poweroff.target.wants drwxr-xr-x 2 root root 4096 Oct 23 16:34 printer.target.wants drwxr-xr-x 2 root root 4096 Oct 23 16:34 reboot.target.wants drwxr-xr-x 2 root root 4096 Oct 23 16:34 sockets.target.wants lrwxrwxrwx 1 root root 31 Oct 23 16:34 sshd.service -> /lib/systemd/system/ssh.service drwxr-xr-x 2 root root 4096 Oct 23 16:34 suspend.target.wants lrwxrwxrwx 1 root root 35 Oct 23 16:34 syslog.service -> /lib/systemd/system/rsyslog.service
ainsi que par des fichiers se trouvant dans le répertoire /lib/systemd/system sous RHEL/CentOS 7 et Debian 8 et /usr/lib/systemd/system sous RHEL/CentOS 7 :
[root@centos7 ~]# ls -l /lib/systemd/system | more total 1208 -rw-r--r--. 1 root root 275 Mar 24 04:56 abrt-ccpp.service -rw-r--r--. 1 root root 380 Mar 24 04:56 abrtd.service -rw-r--r--. 1 root root 361 Mar 24 04:56 abrt-oops.service -rw-r--r--. 1 root root 266 Mar 24 04:56 abrt-pstoreoops.service -rw-r--r--. 1 root root 262 Mar 24 04:56 abrt-vmcore.service -rw-r--r--. 1 root root 311 Mar 24 04:56 abrt-xorg.service -rw-r--r--. 1 root root 421 Jun 10 2014 accounts-daemon.service -rw-r--r--. 1 root root 501 Mar 5 20:37 alsa-restore.service -rw-r--r--. 1 root root 558 Mar 5 20:37 alsa-state.service -rw-r--r--. 1 root root 412 Mar 5 20:37 alsa-store.service -rw-r--r--. 1 root root 645 Mar 26 11:43 anaconda-direct.service -rw-r--r--. 1 root root 185 Mar 26 11:43 anaconda-nm-config.service -rw-r--r--. 1 root root 660 Mar 26 11:43 anaconda-noshell.service -rw-r--r--. 1 root root 387 Mar 26 11:43 anaconda.service -rw-r--r--. 1 root root 684 Mar 26 11:43 anaconda-shell@.service -rw-r--r--. 1 root root 322 Mar 26 11:43 anaconda-sshd.service -rw-r--r--. 1 root root 312 Mar 26 11:43 anaconda.target drwxr-xr-x. 2 root root 4096 Jun 4 15:33 anaconda.target.wants -rw-r--r--. 1 root root 498 Mar 26 11:43 anaconda-tmux@.service -rw-r--r--. 1 root root 275 Jun 10 2014 arp-ethers.service -rw-r--r--. 1 root root 205 Oct 7 2014 atd.service -rw-r-----. 1 root root 669 Mar 5 22:59 auditd.service -rw-r--r--. 1 root root 663 Mar 6 05:17 auth-rpcgss-module.service lrwxrwxrwx. 1 root root 14 Jun 4 09:52 autovt@.service -> getty@.service -rw-r--r--. 1 root root 1044 Mar 5 23:03 avahi-daemon.service -rw-r--r--. 1 root root 874 Mar 5 23:03 avahi-daemon.socket -rw-r--r--. 1 root root 546 May 12 21:44 basic.target drwxr-xr-x. 2 root root 4096 Jun 4 10:07 basic.target.wants --More--
root@debian8:~# ls -l /lib/systemd/system | more total 904 -rw-r--r-- 1 root root 411 Oct 1 2014 accounts-daemon.service -rw-r--r-- 1 root root 476 Jul 8 2014 alsa-restore.service -rw-r--r-- 1 root root 526 Jul 8 2014 alsa-state.service -rw-r--r-- 1 root root 373 Jul 8 2014 alsa-store.service lrwxrwxrwx 1 root root 9 Oct 23 16:34 alsa-utils.service -> /dev/null -rw-r--r-- 1 root root 283 Dec 28 2014 anacron-resume.service -rw-r--r-- 1 root root 183 Dec 28 2014 anacron.service -rw-r--r-- 1 root root 169 Sep 30 2014 atd.service -rw-r--r-- 1 root root 688 Dec 9 2014 auditd.service lrwxrwxrwx 1 root root 14 Aug 31 00:04 autovt@.service -> getty@.service -rw-r--r-- 1 root root 1044 Apr 14 2015 avahi-daemon.service -rw-r--r-- 1 root root 874 Apr 14 2015 avahi-daemon.socket -rw-r--r-- 1 root root 524 Aug 31 00:04 basic.target drwxr-xr-x 2 root root 4096 Oct 23 16:34 basic.target.wants -rw-r--r-- 1 root root 338 Jan 3 2015 bluetooth.service -rw-r--r-- 1 root root 379 Aug 31 00:04 bluetooth.target lrwxrwxrwx 1 root root 9 Aug 31 00:04 bootlogd.service -> /dev/null lrwxrwxrwx 1 root root 9 Aug 31 00:04 bootlogs.service -> /dev/null lrwxrwxrwx 1 root root 9 Aug 31 00:04 bootmisc.service -> /dev/null lrwxrwxrwx 1 root root 9 Aug 31 00:04 checkfs.service -> /dev/null lrwxrwxrwx 1 root root 9 Aug 31 00:04 checkroot-bootclean.service -> /dev/null lrwxrwxrwx 1 root root 9 Aug 31 00:04 checkroot.service -> /dev/null -rw-r--r-- 1 root root 298 Dec 9 2014 colord.service -rw-r--r-- 1 root root 150 Oct 23 2014 configure-printer@.service -rw-r--r-- 1 root root 737 Aug 31 00:04 console-getty.service -rw-r--r-- 1 root root 741 Aug 31 00:04 console-shell.service -rw-r--r-- 1 root root 783 Aug 31 00:04 container-getty@.service -rw-r--r-- 1 root root 251 May 14 09:18 cron.service lrwxrwxrwx 1 root root 9 Aug 31 00:04 cryptdisks-early.service -> /dev/null lrwxrwxrwx 1 root root 9 Aug 31 00:04 cryptdisks.service -> /dev/null --More--
[root@centos7 ~]# ls -l /usr/lib/systemd/system | more total 1208 -rw-r--r--. 1 root root 275 Mar 24 04:56 abrt-ccpp.service -rw-r--r--. 1 root root 380 Mar 24 04:56 abrtd.service -rw-r--r--. 1 root root 361 Mar 24 04:56 abrt-oops.service -rw-r--r--. 1 root root 266 Mar 24 04:56 abrt-pstoreoops.service -rw-r--r--. 1 root root 262 Mar 24 04:56 abrt-vmcore.service -rw-r--r--. 1 root root 311 Mar 24 04:56 abrt-xorg.service -rw-r--r--. 1 root root 421 Jun 10 2014 accounts-daemon.service -rw-r--r--. 1 root root 501 Mar 5 20:37 alsa-restore.service -rw-r--r--. 1 root root 558 Mar 5 20:37 alsa-state.service -rw-r--r--. 1 root root 412 Mar 5 20:37 alsa-store.service -rw-r--r--. 1 root root 645 Mar 26 11:43 anaconda-direct.service -rw-r--r--. 1 root root 185 Mar 26 11:43 anaconda-nm-config.service -rw-r--r--. 1 root root 660 Mar 26 11:43 anaconda-noshell.service -rw-r--r--. 1 root root 387 Mar 26 11:43 anaconda.service -rw-r--r--. 1 root root 684 Mar 26 11:43 anaconda-shell@.service -rw-r--r--. 1 root root 322 Mar 26 11:43 anaconda-sshd.service -rw-r--r--. 1 root root 312 Mar 26 11:43 anaconda.target drwxr-xr-x. 2 root root 4096 Jun 4 15:33 anaconda.target.wants -rw-r--r--. 1 root root 498 Mar 26 11:43 anaconda-tmux@.service -rw-r--r--. 1 root root 275 Jun 10 2014 arp-ethers.service -rw-r--r--. 1 root root 205 Oct 7 2014 atd.service -rw-r-----. 1 root root 669 Mar 5 22:59 auditd.service -rw-r--r--. 1 root root 663 Mar 6 05:17 auth-rpcgss-module.service lrwxrwxrwx. 1 root root 14 Jun 4 09:52 autovt@.service -> getty@.service -rw-r--r--. 1 root root 1044 Mar 5 23:03 avahi-daemon.service -rw-r--r--. 1 root root 874 Mar 5 23:03 avahi-daemon.socket -rw-r--r--. 1 root root 546 May 12 21:44 basic.target drwxr-xr-x. 2 root root 4096 Jun 4 10:07 basic.target.wants --More--
Par exemple, sous RHEL/CentOS 7, le service sshd est configuré par le fichier /usr/lib/systemd/system/sshd.service :
[root@centos7 ~]# cat /usr/lib/systemd/system/sshd.service [Unit] Description=OpenSSH server daemon After=network.target sshd-keygen.service Wants=sshd-keygen.service [Service] EnvironmentFile=/etc/sysconfig/sshd ExecStart=/usr/sbin/sshd -D $OPTIONS ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure RestartSec=42s [Install] WantedBy=multi-user.target
Tandis que sous Debian 8, le même service est configuré par le fichier /etc/systemd/system/sshd.service :
root@debian8:~# cat /etc/systemd/system/sshd.service [Unit] Description=OpenBSD Secure Shell server After=network.target auditd.service ConditionPathExists=!/etc/ssh/sshd_not_to_be_run [Service] EnvironmentFile=-/etc/default/ssh ExecStart=/usr/sbin/sshd -D $SSHD_OPTS ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure [Install] WantedBy=multi-user.target Alias=sshd.service
Dans le fichier de RHEL/CentOS 7 on peut noter la présence des lignes suivantes :
Dans le fichier de Debian 8 on peut noter la présence des lignes suivantes :
Systemd utilise des Cibles d'une manière similaire à ce que SysVinit utilise des niveaux d'exécution. Pour rendre la transition plus facile, il existe des Cibles qui simulent les niveaux d'exécution de SysVinit :
Ceci étant dans RHEL/CentOS 7 il y principalement deux Cibles finales :
Chaque Cible est décrite par un fichier de configuration :
[root@centos7 ~]# cat /usr/lib/systemd/system/graphical.target # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Unit] Description=Graphical Interface Documentation=man:systemd.special(7) Requires=multi-user.target After=multi-user.target Conflicts=rescue.target Wants=display-manager.service AllowIsolate=yes [Install] Alias=default.target
root@debian8:~# cat /lib/systemd/system/graphical.target # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Unit] Description=Graphical Interface Documentation=man:systemd.special(7) Requires=multi-user.target After=multi-user.target Conflicts=rescue.target Wants=display-manager.service AllowIsolate=yes
Dans ce fichier on peut noter la présence des lignes suivantes :
Dernièrement, sous RHEL/CentOS 7, la Cible par défaut peut être modifiée en éditant le lien symbolique /etc/systemd/system/default.target :
[root@centos7 ~]# ls -l /etc/systemd/system/default.target lrwxrwxrwx. 1 root root 36 Mar 8 14:05 /etc/systemd/system/default.target -> /lib/systemd/system/graphical.target
tandis que, sous Debian 8, la Cible par défaut peut être modifiée en éditant le lien symbolique /lib/systemd/system/default.target :
root@debian8:~# ls -l /lib/systemd/system/default.target lrwxrwxrwx 1 root root 16 Aug 31 00:04 /lib/systemd/system/default.target -> graphical.target
Pour avoir une évaluation du temps de démarrage, il convient d'utiliser la commande suivante :
[root@centos7 ~]# systemd-analyze Startup finished in 769ms (kernel) + 4.643s (initrd) + 40.147s (userspace) = 45.560s
root@debian8:~# systemd-analyze Startup finished in 6.296s (kernel) + 17.035s (userspace) = 23.332s
L'option blame de la commande systemd-analyze permet de voir le temps de démarrage de chaque Unité afin de pourvoir se concentrer sur les plus lentes :
[root@centos7 ~]# systemd-analyze blame 12.274s firewalld.service 10.302s tuned.service 9.676s accounts-daemon.service 8.875s gssproxy.service 8.860s ModemManager.service 8.598s vboxadd-x11.service 7.829s kdump.service 7.089s vboxadd.service 6.398s plymouth-quit-wait.service 5.593s NetworkManager-wait-online.service 5.379s avahi-daemon.service 5.104s abrt-ccpp.service 5.065s postfix.service 4.684s systemd-logind.service 4.385s sysstat.service 4.306s rtkit-daemon.service 3.927s systemd-udev-settle.service 3.396s ksmtuned.service 3.084s rhel-dmesg.service 2.811s libvirtd.service 2.428s chronyd.service 2.401s vboxadd-service.service 2.349s nfs-config.service 2.266s var-lib-nfs-rpc_pipefs.mount 2.229s rhel-loadmodules.service 2.104s rsyslog.service 1.357s network.service 1.283s lvm2-monitor.service 1.246s rpcbind.service 1.069s systemd-fsck-root.service 1.007s colord.service 944ms systemd-tmpfiles-setup-dev.service 872ms systemd-tmpfiles-clean.service 791ms rhel-readonly.service 780ms NetworkManager.service 743ms dmraid-activation.service 723ms gdm.service 720ms ksm.service 718ms polkit.service 716ms proc-fs-nfsd.mount 669ms auditd.service 660ms boot.mount 608ms systemd-udev-trigger.service 601ms kmod-static-nodes.service 565ms netcf-transaction.service 520ms systemd-vconsole-setup.service 497ms systemd-sysctl.service 487ms sys-kernel-debug.mount 302ms dev-disk-by\x2duuid-11a4d11d\x2d81e4\x2d46a7\x2d82e0\x2d7796cd597dc9.swap 297ms systemd-tmpfiles-setup.service 283ms dev-mqueue.mount 282ms dev-hugepages.mount 261ms rhel-import-state.service 243ms udisks2.service 239ms systemd-user-sessions.service 235ms rpc-statd-notify.service 217ms systemd-random-seed.service 173ms plymouth-read-write.service 161ms systemd-udevd.service 147ms upower.service 142ms systemd-fsck@dev-disk-by\x2duuid-e8d3bd48\x2d1386\x2d411c\x2d9675\x2d41c3f8f1a309.service 110ms plymouth-start.service 96ms sys-fs-fuse-connections.mount 82ms bluetooth.service 73ms iscsi-shutdown.service 69ms systemd-remount-fs.service 63ms systemd-hostnamed.service 53ms systemd-update-utmp.service 38ms systemd-journal-flush.service 33ms sys-kernel-config.mount 31ms systemd-update-utmp-runlevel.service lines 43-71/71 (END)
root@debian8:~# systemd-analyze blame 6.942s NetworkManager.service 6.781s ModemManager.service 6.672s exim4.service 5.483s accounts-daemon.service 3.697s alsa-restore.service 3.697s pppd-dns.service 3.587s systemd-logind.service 3.554s vboxadd-x11.service 3.545s vboxadd.service 3.543s rc-local.service 3.539s minissdpd.service 3.538s irqbalance.service 3.527s gdomap.service 3.527s speech-dispatcher.service 3.461s avahi-daemon.service 2.895s networking.service 2.726s kbd.service 1.652s polkitd.service 1.459s keyboard-setup.service 1.434s lightdm.service 1.055s rsyslog.service 955ms systemd-tmpfiles-setup.service 864ms systemd-modules-load.service 830ms vboxadd-service.service 778ms systemd-journal-flush.service 697ms nfs-common.service 644ms systemd-tmpfiles-setup-dev.service 600ms console-setup.service 555ms rpcbind.service 494ms systemd-setup-dgram-qlen.service 456ms sys-kernel-debug.mount lines 1-31
L'option critical-chain permet de voir l'enchaînement des événements qui amènent au chargement de l'Unité passée en argument :
[root@centos7 ~]# systemd-analyze critical-chain sshd.service The time after the unit is active or started is printed after the "@" character. The time the unit takes to start is printed after the "+" character. sshd.service @32.037s └─network.target @31.990s └─network.service @30.621s +1.357s └─NetworkManager.service @24.242s +780ms └─firewalld.service @11.954s +12.274s └─basic.target @11.937s └─sockets.target @11.937s └─dbus.socket @11.936s └─sysinit.target @11.784s └─systemd-update-utmp.service @11.726s +53ms └─auditd.service @11.051s +669ms └─systemd-tmpfiles-setup.service @10.734s +297ms └─rhel-import-state.service @10.470s +261ms └─local-fs.target @10.464s └─boot.mount @9.798s +660ms └─systemd-fsck@dev-disk-by\x2duuid-e8d3bd48\x2d1386\x2d411c\x2d9675\x2d41c3f8f1a309.service @9.654s +142ms └─dev-disk-by\x2duuid-e8d3bd48\x2d1386\x2d411c\x2d9675\x2d41c3f8f1a309.device @9.650s
root@debian8:~# systemd-analyze critical-chain sshd.service The time after the unit is active or started is printed after the "@" character. The time the unit takes to start is printed after the "+" character. ssh.service @10.074s └─basic.target @9.951s └─paths.target @9.950s └─cups.path @9.950s └─sysinit.target @9.940s └─nfs-common.service @9.242s +697ms └─rpcbind.target @9.242s └─rpcbind.service @8.684s +555ms └─network-online.target @8.683s └─network.target @8.683s └─networking.service @5.788s +2.895s └─systemd-random-seed.service @5.458s +328ms └─systemd-remount-fs.service @5.298s +157ms └─keyboard-setup.service @3.837s +1.459s └─systemd-udevd.service @3.702s +126ms └─systemd-tmpfiles-setup-dev.service @3.057s +644ms └─kmod-static-nodes.service @2.858s +193ms └─system.slice @2.805s └─-.slice @2.804s
Les options de la commande systemd-analyze sont :
[root@centos7 ~]# systemd-analyze --help systemd-analyze [OPTIONS...] {COMMAND} ... Process systemd profiling information -h --help Show this help --version Show package version --system Connect to system manager --user Connect to user service manager --order When generating a dependency graph, show only order --require When generating a dependency graph, show only requirement --from-pattern=GLOB, --to-pattern=GLOB When generating a dependency graph, filter only origins or destinations, respectively --fuzz=TIMESPAN When printing the tree of the critical chain, print also services, which finished TIMESPAN earlier, than the latest in the branch. The unit of TIMESPAN is seconds unless specified with a different unit, i.e. 50ms --no-pager Do not pipe output into a pager Commands: time Print time spent in the kernel before reaching userspace blame Print list of running units ordered by time to init critical-chain Print a tree of the time critical chain of units plot Output SVG graphic showing service initialization dot Output dependency graph in dot(1) format set-log-level LEVEL Set logging threshold for systemd dump Output state serialization of service manager
root@debian8:~# systemd-analyze --help systemd-analyze [OPTIONS...] {COMMAND} ... Process systemd profiling information. -h --help Show this help --version Show package version --no-pager Do not pipe output into a pager --system Connect to system manager --user Connect to user manager -H --host=[USER@]HOST Operate on remote host -M --machine=CONTAINER Operate on local container --order When generating a dependency graph, show only order --require When generating a dependency graph, show only requirement --from-pattern=GLOB, --to-pattern=GLOB When generating a dependency graph, filter only origins or destinations, respectively --fuzz=TIMESPAN When printing the tree of the critical chain, print also services, which finished TIMESPAN earlier, than the latest in the branch. The unit of TIMESPAN is seconds unless specified with a different unit, i.e. 50ms Commands: time Print time spent in the kernel before reaching userspace blame Print list of running units ordered by time to init critical-chain Print a tree of the time critical chain of units plot Output SVG graphic showing service initialization dot Output dependency graph in dot(1) format set-log-level LEVEL Set logging threshold for systemd dump Output state serialization of service manager
Pour obtenir le détail sur un service donné, il convient d'utiliser la commande systemctl :
[root@centos7 ~]# systemctl status sshd.service sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) Active: active (running) since Thu 2015-06-11 11:01:52 CEST; 2h 45min ago Main PID: 1212 (sshd) CGroup: /system.slice/sshd.service └─1212 /usr/sbin/sshd -D Jun 11 11:01:52 centos7.fenestros.loc systemd[1]: Started OpenSSH server daemon. Jun 11 11:01:53 centos7.fenestros.loc sshd[1212]: Server listening on 0.0.0.0 port 22. Jun 11 11:01:53 centos7.fenestros.loc sshd[1212]: Server listening on :: port 22.
Sous Debian 8, sshd.service est un lien vers ssh.service :
root@debian8:~# ls -l /etc/systemd/system/sshd.service lrwxrwxrwx 1 root root 31 Oct 23 16:34 /etc/systemd/system/sshd.service -> /lib/systemd/system/ssh.service
root@debian8:~# systemctl status ssh.service ● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled) Active: active (running) since Sun 2015-11-01 09:35:03 CET; 10min ago Main PID: 2024 (sshd) CGroup: /system.slice/ssh.service └─2024 /usr/sbin/sshd -D Nov 01 09:35:03 debian8 sshd[2024]: Server listening on 0.0.0.0 port 22. Nov 01 09:35:03 debian8 sshd[2024]: Server listening on :: port 22.
Pour arrêter une Unité de service, utilisez la commande suivante :
[root@centos7 ~]# systemctl stop sshd.service [root@centos7 ~]# systemctl status sshd.service sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) Active: inactive (dead) since Thu 2015-06-11 13:58:59 CEST; 16s ago Process: 1212 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 1212 (code=exited, status=0/SUCCESS) Jun 11 11:01:52 centos7.fenestros.loc systemd[1]: Started OpenSSH server daemon. Jun 11 11:01:53 centos7.fenestros.loc sshd[1212]: Server listening on 0.0.0.0 port 22. Jun 11 11:01:53 centos7.fenestros.loc sshd[1212]: Server listening on :: port 22. Jun 11 13:58:59 centos7.fenestros.loc systemd[1]: Stopping OpenSSH server daemon... Jun 11 13:58:59 centos7.fenestros.loc sshd[1212]: Received signal 15; terminating. Jun 11 13:58:59 centos7.fenestros.loc systemd[1]: Stopped OpenSSH server daemon.
root@debian8:~# systemctl stop ssh.service root@debian8:~# systemctl status ssh.service ● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled) Active: inactive (dead) since Sun 2015-11-01 09:46:13 CET; 2s ago Main PID: 2024 (code=exited, status=0/SUCCESS) Nov 01 09:35:03 debian8 sshd[2024]: Server listening on 0.0.0.0 port 22. Nov 01 09:35:03 debian8 sshd[2024]: Server listening on :: port 22.
Pour démarrer un service, utilisez la commande suivante :
[root@centos7 ~]# systemctl start ssh.service [root@centos7 ~]# systemctl status sshd.service sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) Active: active (running) since Thu 2015-06-11 14:00:17 CEST; 6s ago Main PID: 6624 (sshd) CGroup: /system.slice/sshd.service └─6624 /usr/sbin/sshd -D Jun 11 14:00:17 centos7.fenestros.loc systemd[1]: Starting OpenSSH server daemon... Jun 11 14:00:17 centos7.fenestros.loc systemd[1]: Started OpenSSH server daemon. Jun 11 14:00:17 centos7.fenestros.loc sshd[6624]: Server listening on 0.0.0.0 port 22. Jun 11 14:00:17 centos7.fenestros.loc sshd[6624]: Server listening on :: port 22.
root@debian8:~# systemctl start ssh.service root@debian8:~# systemctl status ssh.service ● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled) Active: active (running) since Sun 2015-11-01 09:47:10 CET; 6s ago Main PID: 2180 (sshd) CGroup: /system.slice/ssh.service └─2180 /usr/sbin/sshd -D Nov 01 09:47:10 debian8 sshd[2180]: Server listening on 0.0.0.0 port 22. Nov 01 09:47:10 debian8 sshd[2180]: Server listening on :: port 22.
Pour désactiver un service au prochain démarrage du système, utilisez l'option disable :
[root@centos7 ~]# systemctl disable sshd.service rm '/etc/systemd/system/multi-user.target.wants/sshd.service' [root@centos7 ~]# systemctl status sshd.service sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled) Active: active (running) since Thu 2015-06-11 14:00:17 CEST; 1min 59s ago Main PID: 6624 (sshd) CGroup: /system.slice/sshd.service └─6624 /usr/sbin/sshd -D Jun 11 14:00:17 centos7.fenestros.loc systemd[1]: Starting OpenSSH server daemon... Jun 11 14:00:17 centos7.fenestros.loc systemd[1]: Started OpenSSH server daemon. Jun 11 14:00:17 centos7.fenestros.loc sshd[6624]: Server listening on 0.0.0.0 port 22. Jun 11 14:00:17 centos7.fenestros.loc sshd[6624]: Server listening on :: port 22.
root@debian8:~# systemctl disable ssh.service Synchronizing state for ssh.service with sysvinit using update-rc.d... Executing /usr/sbin/update-rc.d ssh defaults Executing /usr/sbin/update-rc.d ssh disable insserv: warning: current start runlevel(s) (empty) of script `ssh' overrides LSB defaults (2 3 4 5). insserv: warning: current stop runlevel(s) (2 3 4 5) of script `ssh' overrides LSB defaults (empty). Removed symlink /etc/systemd/system/sshd.service. root@debian8:~# systemctl status ssh.service ● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; disabled) Active: active (running) since Sun 2015-11-01 09:47:10 CET; 1min 7s ago Main PID: 2180 (sshd) CGroup: /system.slice/ssh.service └─2180 /usr/sbin/sshd -D Nov 01 09:47:10 debian8 sshd[2180]: Server listening on 0.0.0.0 port 22. Nov 01 09:47:10 debian8 sshd[2180]: Server listening on :: port 22.
Pour activer un service au prochain démarrage du système, utilisez l'option enable :
[root@centos7 ~]# systemctl enable sshd.service ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service' [root@centos7 ~]# systemctl status sshd.service sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) Active: active (running) since Thu 2015-06-11 14:00:17 CEST; 3min 27s ago Main PID: 6624 (sshd) CGroup: /system.slice/sshd.service └─6624 /usr/sbin/sshd -D Jun 11 14:00:17 centos7.fenestros.loc systemd[1]: Starting OpenSSH server daemon... Jun 11 14:00:17 centos7.fenestros.loc systemd[1]: Started OpenSSH server daemon. Jun 11 14:00:17 centos7.fenestros.loc sshd[6624]: Server listening on 0.0.0.0 port 22. Jun 11 14:00:17 centos7.fenestros.loc sshd[6624]: Server listening on :: port 22.
root@debian8:~# systemctl enable ssh.service Synchronizing state for ssh.service with sysvinit using update-rc.d... Executing /usr/sbin/update-rc.d ssh defaults insserv: warning: current start runlevel(s) (empty) of script `ssh' overrides LSB defaults (2 3 4 5). insserv: warning: current stop runlevel(s) (2 3 4 5) of script `ssh' overrides LSB defaults (empty). Executing /usr/sbin/update-rc.d ssh enable Created symlink from /etc/systemd/system/sshd.service to /lib/systemd/system/ssh.service. root@debian8:~# systemctl status ssh.service ● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled) Active: active (running) since Sun 2015-11-01 09:47:10 CET; 1min 43s ago Main PID: 2180 (sshd) CGroup: /system.slice/ssh.service └─2180 /usr/sbin/sshd -D Nov 01 09:47:10 debian8 sshd[2180]: Server listening on 0.0.0.0 port 22. Nov 01 09:47:10 debian8 sshd[2180]: Server listening on :: port 22.
Lors de l'arrêt de la machine, Linux procède, entre autre, aux tâches suivantes :
La commande utilisée pour arrêter le système est la commande shutdown :
shutdown [-t sec] [-akrhHPfnc] heure [message]
Les options de cette commande sont :
Usage: shutdown [-akrhHPfnc] [-t secs] time [warning message] -a: use /etc/shutdown.allow -k: don't really shutdown, only warn. -r: reboot after shutdown. -h: halt after shutdown. -P: halt action is to turn off power. -H: halt action is to just halt. -f: do a 'fast' reboot (skip fsck). -F: Force fsck on reboot. -n: do not go through "init" but go down real fast. -c: cancel a running shutdown. -t secs: delay between warning and kill signal. ** the "time" argument is mandatory! (try "now") **
root@debian8:~# shutdown --help shutdown [OPTIONS...] [TIME] [WALL...] Shut down the system. --help Show this help -H --halt Halt the machine -P --poweroff Power-off the machine -r --reboot Reboot the machine -h Equivalent to --poweroff, overridden by --halt -k Don't halt/power-off/reboot, just send warnings --no-wall Don't send wall message before halt/power-off/reboot -c Cancel a pending shutdown
Parmi les options les plus importantes, on note :
Option | Description |
---|---|
-h | Arrêter le système |
-r | Re-démarrer le système |
-c | Annuler l'opération shutdown en cours |
-f | Re-démarrer rapidement sans vérifier les systèmes de fichiers |
-F | Forcer la vérification des systèmes de fichiers lors du prochain démarrage |
L'option heure peut prendre plusieurs valeurs :
Valeur | Description |
---|---|
hh:mm | L'heure à laquelle l'opération aura lieu |
+m | Nombre de minutes avant que l'opération aura lieu |
now | L'opération est immédiate |
Important : Si l'opération est programmée pour dans moins de 5 minutes, les connexions supplémentaires sont interdites, y comprises les tentatives de connexion de root. Notez aussi que l'utilisation de la commande shutdown peut être accordée à d'autres utilisateurs de root en utilisant le fichier /etc/shutdown.allow.
Dans votre VM, ouvrez deux terminaux. Dans le premier passez en tant que root. Planifiez ensuite un redémarrage de la VM dans 30 minutes :
[root@centos ~]# shutdown -r +30 Broadcast message from trainee@centos.fenestros.loc (/dev/pts/0) at 10:12 ... The system is going down for reboot in 30 minutes!
root@debian8:~# shutdown -r +30 Shutdown scheduled for Sun 2015-11-01 10:21:04 CET, use 'shutdown -c' to cancel.
Dans le deuxième terminal est passez en tant que route. Annulez ensuite le shutdown :
[trainee@centos ~]$ su - Mot de passe : [root@centos ~]# shutdown -c
trainee@debian8:~$ su - Password: root@debian8:~# shutdown -c Broadcast message from root@debian8 (Sun 2015-11-01 09:53:34 CET): The system shutdown has been cancelled at Sun 2015-11-01 09:54:34 CET! root@debian8:~#
Retournez au premier terminal et constatez le message affiché :
[root@centos ~]# shutdown -r +30 Broadcast message from trainee@centos.fenestros.loc (/dev/pts/0) at 10:12 ... The system is going down for reboot in 30 minutes! shutdown: Shutdown cancelled [root@centos ~]#
root@debian8:~# Broadcast message from root@debian8 (Sun 2015-11-01 09:53:34 CET): The system shutdown has been cancelled at Sun 2015-11-01 09:54:34 CET!
Cette commande redémarre le système. Quand le système fonctionne normalement, l'exécution de reboot appelle la commande shutdown -r.
Les options de cette commande sont :
[root@centos ~]# reboot --help Usage: reboot [OPTION]... Reboot the system. Options: -n, --no-sync don't sync before reboot or halt -f, --force force reboot or halt, don't call shutdown(8) -p, --poweroff switch off the power when called as halt -w, --wtmp-only don't actually reboot or halt, just write wtmp record -q, --quiet reduce output to errors only -v, --verbose increase output to include informational messages --help display this help and exit --version output version information and exit This command is intended to instruct the kernel to reboot or halt the system; when run without the -f option, or when in a system runlevel other than 0 or 6, it will actually execute /sbin/shutdown. Report bugs to <upstart-devel@lists.ubuntu.com>
root@debian8:~# reboot --help reboot [OPTIONS...] [ARG] Reboot the system. --help Show this help --halt Halt the machine -p --poweroff Switch off the machine --reboot Reboot the machine -f --force Force immediate halt/power-off/reboot -w --wtmp-only Don't halt/power-off/reboot, just write wtmp record -d --no-wtmp Don't write wtmp record --no-wall Don't send wall message before halt/power-off/reboot
Cette commande arrête le système. Quand le système fonctionne normalement, l'exécution de halt appelle la commande shutdown -h.
Les options de cette commande sont :
[root@centos ~]# halt --help Usage: halt [OPTION]... Halt the system. Options: -n, --no-sync don't sync before reboot or halt -f, --force force reboot or halt, don't call shutdown(8) -p, --poweroff switch off the power when called as halt -w, --wtmp-only don't actually reboot or halt, just write wtmp record -q, --quiet reduce output to errors only -v, --verbose increase output to include informational messages --help display this help and exit --version output version information and exit This command is intended to instruct the kernel to reboot or halt the system; when run without the -f option, or when in a system runlevel other than 0 or 6, it will actually execute /sbin/shutdown. Report bugs to <upstart-devel@lists.ubuntu.com>
root@debian8:~# halt --help halt [OPTIONS...] Halt the system. --help Show this help --halt Halt the machine -p --poweroff Switch off the machine --reboot Reboot the machine -f --force Force immediate halt/power-off/reboot -w --wtmp-only Don't halt/power-off/reboot, just write wtmp record -d --no-wtmp Don't write wtmp record --no-wall Don't send wall message before halt/power-off/reboot
Cette commande arrête le système et coupe l'alimentation électrique. Elle est l'équivalente de la commande halt -p. Quand le système fonctionne normalement, l'exécution de poweroff appelle la commande shutdown -hP.
Les options de cette commande sont :
[root@centos ~]# poweroff --help Usage: poweroff [OPTION]... Power off the system. Options: -n, --no-sync don't sync before reboot or halt -f, --force force reboot or halt, don't call shutdown(8) -p, --poweroff switch off the power when called as halt -w, --wtmp-only don't actually reboot or halt, just write wtmp record -q, --quiet reduce output to errors only -v, --verbose increase output to include informational messages --help display this help and exit --version output version information and exit This command is intended to instruct the kernel to reboot or halt the system; when run without the -f option, or when in a system runlevel other than 0 or 6, it will actually execute /sbin/shutdown. Report bugs to <upstart-devel@lists.ubuntu.com>
root@debian8:~# poweroff --help poweroff [OPTIONS...] Power off the system. --help Show this help --halt Halt the machine -p --poweroff Switch off the machine --reboot Reboot the machine -f --force Force immediate halt/power-off/reboot -w --wtmp-only Don't halt/power-off/reboot, just write wtmp record -d --no-wtmp Don't write wtmp record --no-wall Don't send wall message before halt/power-off/reboot
<html>
Copyright © 2004-2015 Hugh Norris.<br><br> <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/fr/”><img alt=“Licence Creative Commons” style=“border-width:0” src=“http://i.creativecommons.org/l/by-nc-nd/3.0/fr/88x31.png” /></a><br />Ce(tte) oeuvre est mise à disposition selon les termes de la <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/fr/”>Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Pas de Modification 3.0 France</a>.
</html>