Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
elearning:workbooks:lpic:11:500:l101 [2023/06/08 11:41] – created admin | elearning:workbooks:lpic:11:500:l101 [2024/04/05 05:54] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
- | Version : **2023.01** | + | Version : **2024.01** |
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======Topic 1: System Architecture====== | + | ======Topic 1 : System Architecture====== |
=====Contenu du Module===== | =====Contenu du Module===== | ||
Ligne 11: | Ligne 11: | ||
* **Topic 1: System Architecture** | * **Topic 1: System Architecture** | ||
* Contenu du Module | * Contenu du Module | ||
- | * BIOS, EFI et OpenFirmware | + | * Présentation |
- | * Systèmes à base du BIOS | + | * Processus de Démarrage |
- | * Charger de Démarrage | + | * Processus Init |
- | * Systèmes à base de l'EFI | + | * Démarrer RHEL/CentOS 5 avec SysVinit |
- | * Autres Systèmes | + | * Niveaux |
- | * Gestionnaire | + | * Inittab |
- | * LILO | + | * Scripts de Démarrage |
- | * La Commande LILO | + | * rc.sysinit |
- | * Codes Erreur de LILO | + | * Répertoire init.d |
- | * Grub Legacy | + | * Linux Standard Base |
- | * Configurer GRUB Legacy | + | * Codes Retour Standardisés |
- | * La Section Globale | + | * Scripts |
- | * Une Section spécifique à un OS | + | * Répertoires rcx.d |
- | * Configurer l' | + | * rc.local |
- | * Modifier la Configuration de GRUB Legacy en Ligne de Commande | + | * La Commande chkconfig |
- | * GRUB 2 sous RHEL/CentOS 7 | + | * Démarrer |
- | * Le fichier / | + | * Inittab |
- | * Le fichier / | + | * Initialisation du Système |
- | * Les fichiers du répertoire /etc/grub.d | + | * Runlevels |
- | * Configurer l' | + | * [CTL]-[ALT]-[DEL] |
- | * RHEL/ | + | * mingetty |
- | * RHEL/CentOS >= 7.2 | + | * Gestion des Services |
- | * Modifier la Configuration de GRUB 2 en Ligne de Commande | + | * La Commande initctl |
- | * Chargeurs de Démarrages Alternatifs | + | * Jobs |
- | * Systemd-boot | + | * Événements |
- | * U-boot | + | * Etats |
- | * Le Projet Syslinux | + | * Démarrer et Arrêter les Jobs |
- | * SYSLINUX | + | * La Commande status |
- | * EXTLINUX | + | * La Commande start |
- | * ISOLINUX | + | * La Commande stop |
- | * PXELINUX | + | * La Commande |
- | * Isodhpfx | + | * Démarrer |
- | * Initramfs sous RHEL/CentOS 6 | + | * La Commande systemctl |
- | * Examiner l' | + | * Fichiers de Configuration |
- | * Le script init | + | * La Commande systemd-analyze |
- | | + | * Gestion des Services |
- | * Initramfs sous RHEL/CentOS 7 | + | |
- | * Examiner l' | + | |
- | * Le script init | + | |
- | * Consulter le contenu d'un fichier dans initramfs | + | |
- | * La Commande dracut | + | |
* Fichiers Spéciaux | * Fichiers Spéciaux | ||
* Commandes | * Commandes | ||
Ligne 99: | Ligne 94: | ||
* LAB #1 - Travailler avec les cgroups sous RHEL/CentOS 7 | * LAB #1 - Travailler avec les cgroups sous RHEL/CentOS 7 | ||
- | =====BIOS, EFI et OpenFirmware===== | + | =====Présentation===== |
- | ====Systèmes à base du BIOS==== | + | Le processus de démarrage de Linux peut être résumé en trois étapes majeurs : |
- | Au démarrage d'un système | + | * Le **firmware** ou **micrologiciel** démarre en effectuant |
+ | * Le Charger | ||
+ | * Le noyau se charge en mémoire et commence à exécuter en arrière plan les programmes nécessaires au fonctionnement du système. | ||
- | * Tester les composants et les circuits, | + | <WRAP center round tip> |
- | * Faire appel au BIOS de la carte graphique pour initialiser | + | **A retenir** : Il est possible |
- | * Détecter les périphériques | + | </ |
- | | + | |
- | ===Charger de Démarrage=== | + | Cette description simpliste résume cependant un processus bien plus compliqué que ce cours va détailler. |
- | La première partie du Charger | + | ====Processus |
- | * 446 octets pour le Charger | + | Le processus |
- | * 64 octets pour la table de partitions, soit 16 octets par partition décrite, | + | |
- | * 2 octets ayant une valeur fixe en hexadécimale de **AA55**. | + | |
- | ====Systèmes à base de l' | + | ^ 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 **[[http:// | ||
+ | | 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 | | ||
- | Depuis 2011, le BIOS est en train d' | + | La fonction |
- | 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' | + | |
+ | | ||
+ | | ||
+ | | ||
- | Pour que EFI fonctionne, | + | Dans le cas d'un échec à ce stade le message |
- | <WRAP center round tip> | + | ====Processus Init==== |
- | **A retenir** : Sous Linux c'est l' | + | |
- | </ | + | |
- | <WRAP center round important> | + | Le premier processus lancé par le noyau est **Init**. L'exécutable lancé est **/sbin/init**. Son rôle est de d' |
- | **Important** : L'UEFI gère parfaitement les **SSD** (//Solid State Drives//) qui utilisent le standard | + | |
- | </ | + | |
- | ====Autres Systèmes==== | + | * le montage de /proc et de /sys, |
+ | * configuration des paramètres du noyau présents dans **/ | ||
+ | * l' | ||
+ | * la mise à l' | ||
+ | * la définition des consoles textes, | ||
+ | * la définition du nom de la machine, | ||
+ | * la détection des périphériques USB, | ||
+ | * la mise en place du support RAID et LVM, | ||
+ | * l' | ||
+ | * le montages des systèmes de fichiers, | ||
+ | * le re-montage du système de fichiers racine en lecture/ | ||
+ | * l' | ||
+ | * le lancement de syslog, | ||
+ | * le chargement des modules du noyau, | ||
+ | * le nettoyage des fichiers temporaires, | ||
+ | * la définition des variables d' | ||
- | Les systèmes utilisant des processeurs autre qu'un x86 ou x86-64 utilisent un logiciel tel **[[http:// | + | =====Démarrer RHEL/CentOS 5 avec SysVinit===== |
- | =====Gestionnaires de Démarrage===== | + | ====Niveaux d' |
- | Des gestionnaires | + | Il existe 8 niveaux |
- | * GRUB (Grand Unified Boot Loader) | + | ^ 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 | | ||
- | Cependant il en existe d'autres : | + | Les autres |
- | * LILO (LInux LOader) | + | ^ RUNLEVEL ^ Description ^ |
- | * %%SysLinux%% | + | | 2 | Mode multi-utilisateur sans NFS | |
- | * %%LoadLin%% | + | | 3 | Mode multi-utilisateur | |
- | * ... | + | | 4 | Non-utilisé | |
+ | | 5 | Mode multi-utilisateur avec session graphique | | ||
- | ====LILO==== | + | Il existe aussi 3 pseudo-niveaux d' |
- | LILO (//LInux LOader//) est configuré par le fichier **/ | + | Pour connaître |
- | ===La Commande LILO=== | + | < |
+ | [root@centos5 ~]# runlevel | ||
+ | N 5 | ||
+ | </ | ||
- | La commande **lilo** peut prendre | + | La lettre N indique que le système n'a pas changé de niveau d' |
+ | |||
+ | Pour modifier le niveau d' | ||
^ Option ^ Description ^ | ^ Option ^ Description ^ | ||
- | | -M | Permet d' | + | | Q ou q | Demande à Init de relire |
- | | -d | Permet de réduire | + | | -t | Permet de modifier le temps accordé |
- | | -D | Permet | + | |
- | | -u | Permet de désinstaller LILO | | + | |
- | | -v | Permet d' | + | |
- | | -m | Permet de modifier | + | |
- | | -i | Permet de spécifier un nouveau fichier à utiliser comme secteur de boot (/ | + | |
- | | -C | Permet de modifier le fichier de configuration | + | |
- | | -q | Permet de créer le fichier /boot/map qui contient | + | |
- | ===Codes Erreur de LILO=== | + | ====Inittab==== |
- | Lors du démarrage, LILO permet | + | Le fichier **/ |
- | ^ 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' | + | [root@centos5 ~]# cat /etc/inittab |
- | | L | Le premier morceau du chargeur d' | + | # |
- | | LI | Le premier morceau du chargeur d' | + | # inittab |
- | | LIL | Le second morceau du chargeur d' | + | # the system in a certain run-level. |
- | | LIL? | Le second morceau du chargeur d' | + | # |
- | | 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' | + | # Author: |
- | | 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' | + | # Default runlevel. The runlevels used by RHS are: |
+ | # | ||
+ | # 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: | ||
- | <WRAP center round important> | + | # System initialization. |
- | **Important** | + | si:: |
- | </WRAP> | + | |
- | ====Grub Legacy sous RHEL/CentOS | + | l0:0:wait:/etc/rc.d/rc 0 |
+ | l1: | ||
+ | l2: | ||
+ | l3: | ||
+ | l4: | ||
+ | l5: | ||
+ | l6: | ||
- | <WRAP center round tip> | + | # Trap CTRL-ALT-DELETE |
- | **A retenir** | + | ca:: |
- | </WRAP> | + | |
- | Dans le cas où le Charger de Démarrage **grub** n'est pas installé, il convient de saisir la commande suivante | + | # 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:: | ||
- | | + | # If power was restored before the shutdown kicked in, cancel it. |
- | + | pr: | |
- | où **sda** est le nom du périphérique ou grub doit s' | + | |
- | Il est aussi possible d' | ||
- | | ||
- | # grub-install ' | ||
- | où **hd0** indique à grub le premier disque. | + | # Run gettys in standard runlevels |
+ | 1: | ||
+ | 2: | ||
+ | 3: | ||
+ | 4: | ||
+ | 5: | ||
+ | 6: | ||
- | Il est à noter que la première partie du Charger de Démarrage peut également être installé dans un **PBR** (//Partition Boot Record//) dans le cas d'un système dual-boot voire multi-boot au quel cas on parle de **chainloading** : | + | # Run xdm in runlevel 5 |
+ | x: | ||
+ | </ | ||
- | # grub-install /dev/sda1 [Entrée] | + | Dans l' |
- | ou : | + | ^ Champ ^ Nom ^ Description ^ |
+ | | 1 | Identifiant | Identifiant unique de la ligne composé de 1 à 4 caractères | | ||
+ | | 2 | RUNLEVELS | Liste des niveaux d' | ||
+ | | 3 | Action | Méthode utilisé pour lancer la commande se trouvant dans le champ 4 | | ||
+ | | 4 | Commande | Commande à lancer | | ||
- | # grub-install ' | + | Le champ **action** prend une des directives suivantes : |
- | où **(0, | + | ^ Directive ^ Description ^ |
+ | | respawn | Le processus | ||
+ | | mingetty | Assure | ||
+ | | once | Le processus n'est exécuté qu'une fois | | ||
+ | | wait | Le processus n'est exécuté qu'une fois. Init attend | ||
+ | | 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' | ||
+ | | initdefault | Définit le niveau d' | ||
+ | | 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' | ||
+ | | 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 | | ||
- | Le gestionnaire de niveau 1 a pour seul but le lancement du gestionnaire de niveau 2. Le gestionnaire | + | L' |
- | Pour désinstaller grub du MBR, utilisez une disquette DOS pour démarrer | + | ^ Ligne ^ Description ^ |
+ | | id: | ||
+ | | si:: | ||
+ | | l0: | ||
+ | | l1: | ||
+ | | l2: | ||
+ | | l3: | ||
+ | | l4: | ||
+ | | l5: | ||
+ | | l6: | ||
+ | | ca:: | ||
+ | | pf:: | ||
+ | | pr: | ||
+ | | 1: | ||
+ | | 2: | ||
+ | | 3: | ||
+ | | 4: | ||
+ | | 5: | ||
+ | | 6: | ||
+ | | x:5:respawn:/ | ||
- | A> fdisk /mbr [Entrée] | + | ====Scripts de Démarrage==== |
- | ===Configurer GRUB Legacy=== | + | Naviguez à **/ |
- | **grub** se configure grâce au fichier | + | < |
+ | [root@centos5 ~]# cd /etc/rc.d | ||
+ | [root@centos5 rc.d]# ls | ||
+ | init.d | ||
+ | rc rc1.d rc3.d rc5.d rc.local | ||
+ | </ | ||
+ | |||
+ | ===rc.sysinit sous RHEL/CentOS 5=== | ||
+ | |||
+ | D' | ||
+ | |||
+ | ====Répertoire init.d==== | ||
+ | |||
+ | Le répertoire | ||
< | < | ||
- | [root@centos6 ~]# cat /boot/grub/menu.lst | + | [root@centos5 rc.d]# ls init.d/* |
- | # grub.conf generated by anaconda | + | init.d/abrtd |
- | # | + | init.d/acpid |
- | # Note that you do not have to rerun grub after making changes to this file | + | init.d/atd |
- | # NOTICE: | + | init.d/ |
- | # all kernel and initrd paths are relative to /boot/, eg. | + | init.d/ |
- | # root (hd0,0) | + | init.d/avahi-daemon |
- | # kernel | + | init.d/ |
- | # initrd | + | init.d/ |
- | #boot=/dev/sda | + | init.d/cgconfig |
- | default=0 | + | init.d/cgred init.d/ |
- | timeout=5 | + | |
- | splashimage=(hd0, | + | |
- | hiddenmenu | + | |
- | title CentOS Linux (2.6.32-71.29.1.el6.i686) | + | |
- | root (hd0,0) | + | |
- | kernel | + | |
- | initrd | + | |
- | title centos (2.6.32-71.el6.i686) | + | |
- | root (hd0,0) | + | |
- | kernel | + | |
- | initrd | + | |
</ | </ | ||
- | <WRAP center round important> | + | ====Linux Standard Base==== |
- | **Important** : Sous les distributions dérivées de Red Hat, par exemple Fedora, le fichier menu.lst s' | + | |
- | </ | + | |
- | Ce fichier comporte plusieurs sections | + | **[[http:// |
- | + | ||
- | | + | |
- | | + | |
- | ==La Section Globale== | + | Les scripts init qui sont conformes au standard LSB doivent fournir : |
- | ^ Paramètre ^ Explication ^ | + | |
- | | default=0 | Ce paramètre désigne le numéro de l' | + | * des codes retours standardisés, |
- | | timeout=5 | Ce paramètre indique le délai en secondes après lequel l' | + | * des informations sur des dépendances. |
- | | splashimage=(hd0,0)/ | + | |
- | | hiddenmenu | Ce paramètre cache le menu de GRUB Legacy pendant le chargement de l' | + | |
- | | color | Ce paramètre prend la forme de deux pairs de couleurs. Le premier, par exemple white/blue, définit les couleurs de l' | + | |
- | | 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 | | + | |
- | ==Une Section spécifique à un OS== | + | Les scripts init conforment au standard LSB peuvent aussi fournir : |
- | ^ Paramètre ^ Explication ^ | + | |
- | | title CentOS Linux (2.6.32-71.29.1.el6.i686) | Ce paramètre indique le début d'une section de configuration d'une entrée pour un système d' | + | * des messages |
- | | root (hd0,0) | Ce paramètre indique la partition contenant le noyau de Linux. Dans l' | + | |
- | | kernel / | + | |
- | | initrd | Ce paramètre stipule l' | + | |
- | | lock | Ce paramètre indique que que la section est protégée par le mot de passe définit dans les paramètres globaux | + | |
- | | rootnoverify (hd0,1) | Ce paramètre indique une section concernant un système d' | + | |
- | ===Configurer l' | + | Les fonctions proposées par défaut par LSB sont contenues dans le fichier **/ |
- | Grub Legacy peut être protéger par un mot de passe en incluant la directive suivante dans le fichier | + | < |
+ | [root@centos5 ~]# cat /lib/lsb/init-functions | ||
+ | #!/bin/sh | ||
- | password | + | # LSB initscript functions, as defined in the LSB Spec 1.1.0 |
+ | # | ||
+ | # Lawrence Lim < | ||
+ | # Updated to the latest LSB 3.1 spec | ||
+ | # http:// | ||
+ | |||
+ | start_daemon () { | ||
+ | / | ||
+ | } | ||
+ | |||
+ | killproc () { | ||
+ | / | ||
+ | } | ||
+ | |||
+ | pidofproc () { | ||
+ | / | ||
+ | } | ||
+ | |||
+ | log_success_msg () { | ||
+ | / | ||
+ | } | ||
+ | |||
+ | log_failure_msg () { | ||
+ | / | ||
+ | } | ||
+ | |||
+ | log_warning_msg () { | ||
+ | / | ||
+ | } | ||
+ | |||
+ | </code> | ||
- | Le mot de passe doit être chiffré avec MD5 : | + | Ces fonctions sont des scripts se trouvant dans le répertoire **/ |
< | < | ||
- | [root@centos6 | + | [root@centos5 |
- | Password: | + | total 16 |
- | Retype password: | + | -rwxr-xr-x. 1 root root 70 22 févr. |
- | $1$VLOzG$ibdk0my4IHny/ | + | -rwxr-xr-x. |
+ | -rwxr-xr-x. 1 root root 59 22 févr. | ||
+ | -rwxr-xr-x. 1 root root 650 22 févr. | ||
</ | </ | ||
- | Editez ensuite | + | L' |
< | < | ||
- | [root@centos6 | + | [root@centos5 |
- | # grub.conf generated by anaconda | + | #!/bin/bash |
- | # | + | |
- | # Note that you do not have to rerun grub after making changes to this file | + | . /etc/init.d/functions |
- | # NOTICE: | + | |
- | # all kernel and initrd paths are relative to /boot/, eg. | + | LSB=LSB-1.1 killproc $* |
- | # root (hd0,0) | + | exit $? |
- | # kernel | + | [root@centos ~]# |
- | # initrd / | + | [root@centos ~]# cat /etc/redhat-lsb/lsb_pidofproc |
- | #boot=/dev/sda | + | #!/bin/bash |
- | default=0 | + | |
- | timeout=5 | + | . /etc/init.d/functions |
- | password | + | |
- | splashimage=(hd0, | + | pidofproc $* |
- | hiddenmenu | + | exit $? |
- | title CentOS (2.6.32-504.1.3.el6.i686) | + | |
- | lock | + | |
- | root (hd0,0) | + | |
- | kernel / | + | |
- | initrd | + | |
- | title CentOS (2.6.32-358.18.1.el6.i686) | + | |
- | lock | + | |
- | root (hd0,0) | + | |
- | kernel | + | |
- | initrd | + | |
- | title CentOS (2.6.32-358.6.1.el6.i686) | + | |
- | lock | + | |
- | root (hd0,0) | + | |
- | kernel | + | |
- | initrd | + | |
- | title CentOS (2.6.32-279.el6.i686) | + | |
- | lock | + | |
- | root (hd0,0) | + | |
- | kernel / | + | |
- | initrd / | + | |
</ | </ | ||
- | <WRAP center round important> | + | Le fichier |
- | **Important** : Notez l' | + | |
- | </ | + | |
- | ===Modifier la Configuration de GRUB Legacy en Ligne de Commande=== | + | < |
+ | ... | ||
+ | # A function to stop a program. | ||
+ | killproc() { | ||
+ | local RC killlevel= base pid pid_file= delay try binary= | ||
- | Lors du démarrage de GRUB Legacy, il est possible de voir son menu en appuyant sur n' | + | RC=0; delay=3; try=0 |
+ | # Test syntax. | ||
+ | if [ " | ||
+ | echo $" | ||
+ | return 1 | ||
+ | fi | ||
+ | if [ " | ||
+ | pid_file=$2 | ||
+ | shift 2 | ||
+ | fi | ||
+ | if [ " | ||
+ | if [ -z $pid_file ]; then | ||
+ | echo $"-b option can be used only with -p" | ||
+ | echo $" | ||
+ | return 1 | ||
+ | fi | ||
+ | binary=$2 | ||
+ | shift 2 | ||
+ | fi | ||
+ | if [ " | ||
+ | delay=$(echo $2 | awk -v RS=' | ||
+ | if [ " | ||
+ | echo $" | ||
+ | return 1 | ||
+ | fi | ||
+ | shift 2 | ||
+ | ... | ||
+ | </ | ||
- | * la touche **e** pour accéder à l' | + | et |
- | * la touche **c** pour accéder à la ligne de commande. | + | |
- | En mode édition notez l' | + | < |
+ | ... | ||
+ | pidofproc() { | ||
+ | local RC pid pid_file= | ||
- | * **e** : éditer une ligne, | + | # Test syntax. |
- | * **d** : supprimer une ligne, | + | if [ " |
- | * **o** : ajouter une ligne après la ligne courante, | + | echo $" |
- | * **O** : ajouter une ligne avant la ligne courante, | + | |
- | * **b** : démarrer avec la configuration modifiée, | + | fi |
- | * **echap** : abandonner les modifications et retourner à l' | + | if [ " |
+ | pid_file=$2 | ||
+ | shift 2 | ||
+ | fi | ||
+ | fail_code=3 # " | ||
- | ====GRUB 2 sous RHEL/CentOS 7==== | + | # First try "/var/ |
+ | __pids_var_run " | ||
+ | RC=$? | ||
+ | if [ -n " | ||
+ | echo $pid | ||
+ | return 0 | ||
+ | fi | ||
- | GRUB 2 est une ré-écriture complète de GRUB Legacy. Il apporte des améliorations, | + | [ -n " |
+ | __pids_pidof " | ||
+ | } | ||
+ | ... | ||
+ | </ | ||
- | Le lancement de GRUB 2 se fait en trois étapes : | + | ===Codes Retour Standardisés=== |
- | * Etape 1 : Le **boot.img**, | + | Les codes retour standardisés sont : |
- | * Etape 1.5 : Le **core.img**, | + | |
- | * Etape 2 : Contenu dans le répertoire **/ | + | |
- | Dans le cas où le Charger de Démarrage **GRUB | + | ^ 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 | ||
+ | | 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' | ||
+ | | 200-254 | Réservés | | ||
- | # grub2-install / | + | ===Scripts=== |
- | où **périphérique** est le nom du périphérique ou l' | + | LSB stipule un format // |
- | **GRUB 2** lit ses entrées de menus à partir du fichier | + | |
+ | | ||
+ | |||
+ | Par exemple | ||
< | < | ||
- | [root@centos7 | + | [root@centos5 |
+ | #!/bin/bash | ||
# | # | ||
- | # DO NOT EDIT THIS FILE | + | # sshd Start up the OpenSSH server daemon |
# | # | ||
- | # It is automatically generated by grub2-mkconfig using templates | + | # chkconfig: 2345 55 25 |
- | # from /etc/grub.d and settings from / | + | # description: |
+ | # This service starts up the OpenSSH server daemon. | ||
# | # | ||
+ | # processname: | ||
+ | # config: / | ||
+ | # config: / | ||
+ | # config: / | ||
+ | # config: / | ||
+ | # pidfile: / | ||
- | ### BEGIN / | + | ### BEGIN INIT INFO |
- | set pager=1 | + | # Provides: sshd |
+ | # Required-Start: | ||
+ | # Required-Stop: | ||
+ | # Should-Start: | ||
+ | # Should-Stop: | ||
+ | # Default-Start: | ||
+ | # Default-Stop: | ||
+ | # Short-Description: | ||
+ | # Description: | ||
+ | # This service starts up the OpenSSH server daemon. | ||
+ | ### END INIT INFO | ||
- | if [ -s $prefix/grubenv ]; then | + | # source function library |
- | load_env | + | . /etc/ |
- | fi | + | |
- | if [ " | + | |
- | set default=" | + | |
- | set next_entry= | + | |
- | | + | |
- | set boot_once=true | + | |
- | else | + | |
- | set default=" | + | |
- | fi | + | |
- | if [ x" | + | # pull in sysconfig settings |
- | | + | [ -f / |
- | else | + | --Plus--(20%) |
- | menuentry_id_option="" | + | </ |
- | fi | + | |
- | export menuentry_id_option | + | Les lignes se trouvant entre les deux clauses ont un format spécifique : |
- | if [ "${prev_saved_entry}" | + | < |
- | set saved_entry=" | + | # {MotClef}: valeur1 [valeur2...] |
- | save_env saved_entry | + | </ |
- | set prev_saved_entry= | + | |
- | save_env prev_saved_entry | + | |
- | set boot_once=true | + | |
- | fi | + | |
- | function savedefault { | + | <WRAP center round important> |
- | if [ -z " | + | **Important** : Notez qu'à part la deuxième ligne de la description, |
- | | + | </ |
- | save_env saved_entry | + | |
- | fi | + | |
- | } | + | |
- | function load_video { | + | Les Mots Clefs sont : |
- | 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 | + | ^ Mot Clef ^ Description ^ |
- | if [ x$feature_timeout_style = xy ] ; then | + | | Provides | Indique le service -(//boot facilities// |
- | | + | | Required-start | Indique d' |
- | set timeout=5 | + | | Required-Stop | Indique d' |
- | # Fallback normal timeout code in case the timeout_style feature is | + | | Should-Start | Indique d' |
- | # unavailable. | + | | Should-Stop | Indique d' |
- | else | + | | Default-Start | Indique les niveaux d' |
- | set timeout=5 | + | | Default-Stop | Indique les niveaux d' |
- | fi | + | | Short-Description | Indique une description du service en **une seule ligne**. | |
- | ### END /etc/grub.d/00_header ### | + | | Description | Indique une description multi-lignes du service. | |
- | ### BEGIN / | + | Il existe des groupements de services, appelés en anglais des //Virtual Facilities//. Les plus importants sont : |
- | menuentry ' | + | |
- | load_video | + | |
- | set gfxpayload=keep | + | |
- | insmod gzio | + | |
- | insmod part_msdos | + | |
- | insmod xfs | + | |
- | set root=' | + | |
- | if [ x$feature_platform_search_hint = xy ]; then | + | |
- | search --no-floppy --fs-uuid --set=root --hint-bios=hd0, | + | |
- | else | + | |
- | search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 | + | |
- | fi | + | |
- | linux16 | + | |
- | initrd16 | + | |
- | } | + | |
- | menuentry ' | + | |
- | load_video | + | |
- | set gfxpayload=keep | + | |
- | insmod gzio | + | |
- | insmod part_msdos | + | |
- | insmod xfs | + | |
- | set root=' | + | |
- | if [ x$feature_platform_search_hint = xy ]; then | + | |
- | search --no-floppy --fs-uuid --set=root --hint-bios=hd0, | + | |
- | else | + | |
- | search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 | + | |
- | fi | + | |
- | linux16 | + | |
- | initrd16 | + | |
- | } | + | |
- | menuentry ' | + | |
- | load_video | + | |
- | insmod gzio | + | |
- | insmod part_msdos | + | |
- | insmod xfs | + | |
- | set root=' | + | |
- | if [ x$feature_platform_search_hint = xy ]; then | + | |
- | search --no-floppy --fs-uuid --set=root --hint-bios=hd0, | + | |
- | else | + | |
- | search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 | + | |
- | fi | + | |
- | linux16 / | + | |
- | initrd16 / | + | |
- | } | + | |
- | if [ " | + | |
- | ### END / | + | |
- | ### BEGIN /etc/grub.d/20_linux_xen ### | + | ^ Virtual Facility ^ Description ^ |
- | ### END /etc/grub.d/ | + | | $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' | ||
- | ### BEGIN /etc/grub.d/ | + | ====Répertoires rcx.d==== |
- | ### END / | + | |
- | ### BEGIN /etc/grub.d/ | + | Les répertoires **rc0.d** à **rc6.d** contiennent des liens vers les scripts du répertoire **init.d**. |
- | ### END /etc/grub.d/ | + | |
- | ### BEGIN / | + | Pour mieux comprendre, saisissez les commandes suivantes : |
- | # This file provides an easy way to add custom menu entries. | + | |
- | # menu entries you want to add after this comment. | + | |
- | # the 'exec tail' line above. | + | |
- | ### END / | + | |
- | ### BEGIN /etc/grub.d/41_custom ### | + | < |
- | if [ -f ${config_directory}/custom.cfg ]; then | + | [root@centos5 rc.d]# for rep in rc[345].d; do echo "dans $rep :"; ls $rep/S*; done |
- | | + | dans rc3.d : |
- | elif [ -z " | + | rc3.d/S00microcode_ctl |
- | | + | rc3.d/ |
- | fi | + | rc3.d/ |
- | ### END /etc/grub.d/41_custom ### | + | rc3.d/ |
+ | rc3.d/ | ||
+ | dans rc4.d : | ||
+ | rc4.d/ | ||
+ | rc4.d/ | ||
+ | rc4.d/ | ||
+ | rc4.d/ | ||
+ | rc4.d/ | ||
+ | dans rc5.d : | ||
+ | rc5.d/S00microcode_ctl | ||
+ | rc5.d/ | ||
+ | rc5.d/ | ||
+ | rc5.d/ | ||
+ | rc5.d/ | ||
</ | </ | ||
- | Prenons le cas des paramètres de Grub Legacy et comparons-les aux paramètres | + | <WRAP center round important> |
+ | **Important** : Notez que chaque répertoire correspondant à un niveau d' | ||
+ | </ | ||
- | ^ Grub Legacy ^ GRUB 2 ^ | + | Rappelez |
- | | title | Menuentry | | + | |
- | | root (hd0,0) | set root=hd(0, | + | |
- | | kernel | linux | | + | |
- | | initrd | initrd | | + | |
- | | lock | Ce paramètre n' | + | |
- | | rootnoverify (hd0,1) | Ce paramètre n' | + | |
- | 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. La commande grub2-mkconfig prend en argument l' | + | < |
+ | [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/ | ||
+ | rc3.d/ | ||
+ | rc3.d/ | ||
+ | dans rc4.d : | ||
+ | rc4.d/ | ||
+ | rc4.d/ | ||
+ | rc4.d/ | ||
+ | rc4.d/ | ||
+ | dans rc5.d : | ||
+ | rc5.d/ | ||
+ | rc5.d/ | ||
+ | rc5.d/ | ||
+ | rc5.d/ | ||
+ | </ | ||
- | | + | <WRAP center round important> |
- | | + | **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' |
+ | </WRAP> | ||
+ | |||
+ | ===rc.local=== | ||
+ | |||
+ | Le script rc.local est lancé dans les niveaux d' | ||
- | Lors de l' | + | ====La Commande chkconfig==== |
- | ===Le fichier / | + | Pour avoir une vue globale des services lancés par niveau d' |
< | < | ||
- | [root@centos7 ~]# cat / | + | [root@centos5 rc.d]# chkconfig --list |
- | # this device map was generated by anaconda | + | NetworkManager 0: |
- | (hd0) /dev/sda | + | abrtd 0: |
- | (hd1) /dev/sda | + | acpid 0: |
+ | atd 0: | ||
+ | auditd | ||
+ | autofs | ||
+ | avahi-daemon | ||
+ | bluetooth | ||
+ | certmonger | ||
+ | cgconfig | ||
+ | cgred 0: | ||
+ | cpuspeed | ||
+ | crond 0: | ||
+ | cups | ||
+ | dnsmasq | ||
+ | firstboot | ||
+ | haldaemon | ||
+ | httpd 0: | ||
+ | ip6tables | ||
+ | iptables | ||
+ | irqbalance | ||
+ | kdump 0: | ||
+ | lvm2-monitor | ||
+ | mdmonitor | ||
+ | messagebus | ||
+ | microcode_ctl | ||
+ | netconsole | ||
+ | netfs 0: | ||
+ | network | ||
+ | nfs 0: | ||
+ | nfslock | ||
+ | nscd | ||
+ | nslcd 0: | ||
+ | ntpd | ||
+ | ntpdate | ||
+ | oddjobd | ||
+ | portreserve | ||
+ | postfix | ||
+ | psacct | ||
+ | rdisc 0: | ||
+ | restorecond | ||
+ | rpcbind | ||
+ | rpcgssd | ||
+ | rpcidmapd | ||
+ | rpcsvcgssd | ||
+ | rsyslog | ||
+ | saslauthd | ||
+ | smartd | ||
+ | snmpd 0: | ||
+ | snmptrapd | ||
+ | sshd | ||
+ | sssd | ||
+ | sysstat | ||
+ | udev-post | ||
+ | vboxadd | ||
+ | vboxadd-service 0: | ||
+ | vboxadd-x11 | ||
+ | wpa_supplicant 0: | ||
+ | ypbind | ||
</ | </ | ||
- | ===Le fichier / | + | ===Options de la commande=== |
- | Ce fichier contient la configuration par défaut des paramètres | + | Les options |
< | < | ||
- | [root@centos7 | + | [root@centos5 |
- | GRUB_TIMEOUT=5 | + | chkconfig version 1.3.47 - Copyright |
- | GRUB_DISTRIBUTOR=" | + | Ce logiciel peut être librement distribué selon les termes de la licence publique GNU (GPL). |
- | GRUB_DEFAULT=saved | + | |
- | GRUB_DISABLE_SUBMENU=true | + | utilisation : |
- | GRUB_TERMINAL_OUTPUT=" | + | |
- | GRUB_CMDLINE_LINUX=" | + | |
- | GRUB_DISABLE_RECOVERY=" | + | chkconfig --override < |
+ | | ||
</ | </ | ||
+ | Les options les plus importantes sont : | ||
- | <WRAP center round important> | + | ^ Option ^ Description ^ |
- | **Important** : Notez que toute modification de ce fichier nécessite l'exécution | + | | - -add (nom) | Permet d'ajouter un service aux runlevels définis par le service lui-même | |
- | </ | + | | - -del (nom) | Permet |
+ | | %%- -level [niveau] (nom) [on|off|reset]%% | ||
- | Dans ce fichier les directives sont : | + | =====Démarrer RHEL/CentOS 6 avec Upstart===== |
- | ^ Directive | + | **Upstart** est un processus Init mieux adapté aux exigences des périphériques modernes |
- | | GRUB_DEFAULT | Entrée du menu sélectionner par défaut | | + | |
- | | GRUB_TIMEOUT | Durée | + | |
- | | GRUB_DISTRIBUTOR | Ligne de commande qui génère le texte de l' | + | |
- | | 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' | + | |
- | | GRUB_DISABLE_LINUX_RECOVERY | Si **true**, cette directive empêche la génération des entrées | + | |
- | | GRUB_INIT_TUNE | Permet d' | + | |
- | | GRUB_BADRAM | Permet de spécifier | + | |
- | ===Les fichiers du répertoire /etc/grub.d=== | + | ====Inittab==== |
- | Les fichiers | + | Sous Upstart, le fichier / |
< | < | ||
- | [root@centos7 | + | [root@centos6 |
- | total 68 | + | # inittab is only used by upstart for the default runlevel. |
- | -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 | + | # ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM. |
- | -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 | + | # System initialization is started by / |
- | -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 | + | # Individual runlevels are started by / |
- | -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 | + | # Ctrl-Alt-Delete is handled by / |
- | -rw-r--r--. 1 root root | + | # |
+ | # Terminal gettys are handled by / | ||
+ | # with configuration in / | ||
+ | # | ||
+ | # 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: | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | id: | ||
</ | </ | ||
- | * **Le fichier | + | < |
- | * Le fichier **10_Linux** contient des boucles pour rechercher des noyaux Linux, | + | [root@centos6 ~]# cat /etc/inittab |
- | * **Le fichier | + | # inittab is only used by upstart for the default runlevel. |
- | * Ce fichier recherche des éventuels systèmes d' | + | # |
- | * **Les fichiers | + | # ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM. |
- | * Ces deux fichiers sont fournis en tant que modèles à personnaliser. | + | # |
+ | # System initialization is started by /etc/ | ||
+ | # | ||
+ | # Individual runlevels are started by /etc/init/rc.conf | ||
+ | # | ||
+ | # Ctrl-Alt-Delete is handled by /etc/ | ||
+ | # | ||
+ | # Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf, | ||
+ | # with configuration in /etc/ | ||
+ | # | ||
+ | # 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: | ||
+ | </ | ||
- | ===Configurer l' | + | Sous Upstart, les définitions des autres valeurs habituellement incluses dans / |
- | + | ||
- | ==RHEL/ | + | |
- | + | ||
- | Pour configurer l' | + | |
< | < | ||
- | [root@centos7 | + | [root@centos6 |
- | [root@centos7 ~]# chmod 755 /etc/grub.d/ | + | 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 | ||
</ | </ | ||
- | Créez deux mots de passe hashés au format | + | ===Initialisation du Système=== |
+ | |||
+ | L' | ||
< | < | ||
- | [root@centos7 ~]# grub2-mkpasswd-pbkdf2 | + | [root@centos6 init]# cat / |
- | Enter password: pass123 | + | # rcS - runlevel compatibility |
- | Reenter password: pass123 | + | # |
- | PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.0298C1C613A451C46FBC95BB2AC7A41BCEC1C61512EF785BD81E3B65DFF9D57ED4ADF8906C3EF33C22C06FBDD366E1C118FC41110BD646A4D49EF86EFD0573BF.E14A45900096D773BE99BEA9AB8D4FA81431458952798B997D4FC9E0850426F6798979371B8EBD331DB33AE8FEAE25E6773156D42F21B884DBA405546782B3BD | + | # This task runs the old sysv-rc startup scripts. |
- | </ | + | |
- | Editez le fichier **/ | + | start on startup |
- | <file txt / | + | stop on runlevel |
- | #!/bin/sh -e | + | |
- | cat << | + | |
- | set superusers=" | + | |
- | password_pbkdf2 root | + | |
- | grub.pbkdf2.sha512.10000.0298C1C613A451C46FBC95BB2AC7A41BCEC1C61512EF785BD81E3B65DFF9D57ED4ADF8906C3EF33C22C06FBDD366E1C118FC41110BD646A4D49EF86EFD0573BF.E14A45900096D773BE99BEA9AB8D4FA81431458952798B997D4FC9E0850426F6798979371B8EBD331DB33AE8FEAE25E6773156D42F21B884DBA405546782B3BD | + | |
- | EOF | + | |
- | </ | + | |
- | Il est aussi possible d' | + | task |
- | <file txt /etc/grub.d/01_users> | + | # Note: there can be no previous runlevel here, if we have one it's bad |
- | #!/bin/sh -e | + | # information (we enter rc1 not rcS for maintenance). |
- | cat <<EOF | + | # without information so that it defaults to previous=N runlevel=S. |
- | set superusers="root" | + | console output |
- | password root pass123 | + | exec / |
- | EOF | + | post-stop script |
- | </file> | + | if [ " |
+ | [ -f / | ||
+ | [ -z " | ||
+ | for t in $(cat / | ||
+ | case $t in | ||
+ | -s|single|S|s) runlevel="S" | ||
+ | [1-9]) | ||
+ | esac | ||
+ | done | ||
+ | exec telinit $runlevel | ||
+ | fi | ||
+ | end script | ||
+ | </code> | ||
- | Sous RHEL/ | + | ===Runlevels=== |
+ | |||
+ | La gestion des Runlevels est configurée dans le fichier | ||
< | < | ||
- | [root@centos7 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg | + | [root@centos6 init]# cat /etc/init/rc.conf |
- | Generating grub configuration file ... | + | # rc - System V runlevel compatibility |
- | Found linux image: / | + | # |
- | Found initrd image: / | + | # This task runs the old sysv-rc runlevel scripts. It |
- | Found linux image: / | + | # is usually started by the telinit compatibility wrapper. |
- | Found initrd image: / | + | |
- | Found linux image: / | + | |
- | Found initrd image: / | + | |
- | done | + | |
- | </ | + | |
- | <WRAP center round todo> | + | start on runlevel [0123456] |
- | **A faire** : Redémarrez votre VM. Constatez que GRUB 2 demande un nom d' | + | |
- | </ | + | |
- | ==RHEL/ | + | stop on runlevel [!$RUNLEVEL] |
- | Depuis la version 7.2 de RHEL/centOS le fichier **/ | + | task |
- | < | + | export RUNLEVEL |
- | [root@centos7 ~]# cat /etc/grub.d/01_users | + | console output |
- | #!/bin/sh -e | + | exec /etc/rc.d/rc $RUNLEVEL |
- | cat << EOF | + | |
- | if [ -f \${prefix}/ | + | |
- | source \${prefix}/ | + | |
- | if [ -n " | + | |
- | set superusers=" | + | |
- | export superusers | + | |
- | password_pbkdf2 root \${GRUB2_PASSWORD} | + | |
- | fi | + | |
- | fi | + | |
- | EOF | + | |
</ | </ | ||
- | Ce script | + | ===[CTL]-[ALT]-[DEL]=== |
+ | |||
+ | Le comportement associé avec la combinaison de touches [CTL]-[ALT]-[DEL] | ||
< | < | ||
- | ### BEGIN /etc/grub.d/01_users ### | + | [root@centos6 init]# cat /etc/init/control-alt-delete.conf |
- | if [ -f ${prefix}/ | + | # control-alt-delete - emergency keypress handling |
- | | + | # |
- | if [ -n ${GRUB2_PASSWORD} ]; then | + | # This task is run whenever the Control-Alt-Delete key combination is |
- | set superusers=" | + | # pressed. |
- | | + | |
- | password_pbkdf2 root ${GRUB2_PASSWORD} | + | |
- | fi | + | |
- | fi | + | |
- | ### END /etc/grub.d/01_users ### | + | |
- | </ | + | |
- | Ce script : | + | start on control-alt-delete |
- | * teste si le fichier **/boot/grub2/user.cfg** existe puis si c'est le cas, | + | exec /sbin/shutdown -r now " |
- | * teste si la variable $GRUB2_PASSWORD est fixée puis si c'est le cas, | + | </code> |
- | * assigne le mot de passe à root. | + | |
- | Pour créer le contenu du fichier | + | ===mingetty=== |
+ | |||
+ | Le génération des terminaux getty est spécifiée dans les fichiers | ||
< | < | ||
- | [root@centos7 ~]# grub2-setpassword | + | [root@centos6 init]# cat / |
- | Enter password: pass123 | + | # tty - getty |
- | Confirm password: pass123 | + | # |
+ | # This service maintains a getty on the sepcified device. | ||
+ | |||
+ | stop on runlevel [016] | ||
+ | |||
+ | respawn | ||
+ | instance $TTY | ||
+ | exec / | ||
+ | [root@centos rc.d]# cat / | ||
+ | # Automatically start a configured serial console | ||
+ | # | ||
+ | # How this works: | ||
+ | # | ||
+ | # On boot, a udev helper examines / | ||
+ | # primary console (last console on the commandline in grub), | ||
+ | # ' | ||
+ | # triggers this script. It waits for the runlevel to finish, ensures | ||
+ | # the proper port is in / | ||
+ | # | ||
+ | # 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 | ||
+ | # / | ||
+ | |||
+ | start on fedora.serial-console-available DEV=* and stopped rc RUNLEVEL=[2345] | ||
+ | stop on runlevel [016] | ||
+ | |||
+ | instance $DEV | ||
+ | respawn | ||
+ | pre-start exec / | ||
+ | exec / | ||
</ | </ | ||
- | Consultez maintenant le fichier **/boot/grub2/user.cfg** : | + | La configuration des terminaux fait partie du fichier **/etc/sysconfig/init** |
< | < | ||
- | [root@centos7 ~]# cat /boot/grub2/user.cfg | + | [root@centos6 init]# cat /etc/sysconfig/init |
- | GRUB2_PASSWORD=grub.pbkdf2.sha512.10000.3DD268A626FC781A0693D381A5F1BBDE6C834D1D904F023AED8CEF2985304FEC9F0C1C8B975156F5DF534F4B10BCCDC5C187B0C12F55E970A244D9EF2EF962DD.9BB2011598B8E5EFD9A464ED96C0FECB8DCD8FD6942E5114E035AD8A9E2DCFF32A9DC1C222B4226A462B32E7B6D80247F96D79133F18F6524544984837EF4D06 | + | # color => new RH6.0 bootup |
+ | # verbose | ||
+ | # anything else => new style bootup without ANSI colors or positioning | ||
+ | BOOTUP=color | ||
+ | # column to start " | ||
+ | RES_COL=60 | ||
+ | # terminal sequence to move to that column. You could change this | ||
+ | # to something like "tput hpa ${RES_COL}" | ||
+ | MOVE_TO_COL=" | ||
+ | # terminal sequence to set color to a ' | ||
+ | SETCOLOR_SUCCESS=" | ||
+ | # terminal sequence to set color to a ' | ||
+ | SETCOLOR_FAILURE=" | ||
+ | # terminal sequence to set color to a ' | ||
+ | SETCOLOR_WARNING=" | ||
+ | # terminal sequence to reset to the default color. | ||
+ | SETCOLOR_NORMAL=" | ||
+ | # Set to anything other than ' | ||
+ | PROMPT=yes | ||
+ | # Set to ' | ||
+ | AUTOSWAP=no | ||
+ | # What ttys should gettys be started on? | ||
+ | ACTIVE_CONSOLES=/ | ||
+ | # Set to '/ | ||
+ | # Set to '/ | ||
+ | SINGLE=/ | ||
</ | </ | ||
- | <WRAP center round todo> | + | ====Gestion |
- | **A faire** : Redémarrez votre VM. Appuyez sur la touche **e** au début du processus de démarrage. Constatez que GRUB 2 demande un nom d' | + | |
- | </ | + | |
- | Pour pouvoir protéger le démarrage du système, il convient d' | + | 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 |
< | < | ||
- | [root@centos7 | + | [root@centos6 |
- | ... | + | control-alt-delete.conf rcS-sulogin.conf |
- | ### BEGIN /etc/grub.d/ | + | init-system-dbus.conf |
- | menuentry ' | + | kexec-disable.conf |
- | load_video | + | plymouth-shutdown.conf |
- | set gfxpayload=keep | + | prefdm.conf serial.conf |
- | insmod gzio | + | quit-plymouth.conf |
- | insmod part_msdos | + | rc.conf start-ttys.conf |
- | insmod xfs | + | rcS.conf tty.conf |
- | set root=' | + | rcS-emergency.conf |
- | if [ x$feature_platform_search_hint = xy ]; then | + | |
- | | + | |
- | | + | |
- | search | + | |
- | fi | + | |
- | linux16 /vmlinuz-3.10.0-693.21.1.el7.x86_64 root=UUID=e65fe7da-cda8-4f5a-a827-1b5cabe94bed ro rhgb quiet LANG=en_GB.UTF-8 | + | |
- | | + | |
- | } | + | |
- | ... | + | |
</ | </ | ||
- | < | + | Pour créer un fichier job, il convient de respecter un certain format. Par exemple créez le fichier **/etc/init/testjob.conf** : |
- | [root@centos7 ~]# vi / | + | |
- | ... | + | |
- | ### BEGIN /etc/grub.d/10_linux ### | + | |
- | menuentry ' | + | |
- | load_video | + | |
- | set gfxpayload=keep | + | |
- | insmod gzio | + | |
- | insmod part_msdos | + | |
- | insmod xfs | + | |
- | set root=' | + | |
- | if [ x$feature_platform_search_hint = xy ]; then | + | |
- | search --no-floppy --fs-uuid --set=root --hint-bios=hd0, | + | |
- | else | + | |
- | search --no-floppy --fs-uuid --set=root 2d947276-66e8-41f4-8475-b64b67d7a249 | + | |
- | fi | + | |
- | linux16 / | + | |
- | initrd16 / | + | |
- | } | + | |
- | ... | + | |
- | </ | + | |
- | <WRAP center round todo> | + | <file txt testjob.conf> |
- | **A faire** : Redémarrez votre VM. Constatez que GRUB 2 demande un nom d' | + | description "Un job pour tester Upstart" |
- | </WRAP> | + | author "Linux E-Learning" |
+ | start on runlevel [2345] | ||
+ | exec echo Le job test a été lancé | ||
+ | </file> | ||
+ | ===La Commande initctl=== | ||
- | ===Modifier la Configuration | + | Pour obtenir une liste de tous les jobs et leurs états, il convient d' |
- | Lors du démarrage de GRUB 2, trois actions sont possibles à partir du menu : | + | < |
+ | [root@centos6 ~]# initctl list | ||
+ | rc stop/ | ||
+ | tty (/dev/tty3) start/ | ||
+ | tty (/dev/tty2) start/ | ||
+ | tty (/dev/tty6) start/ | ||
+ | tty (/dev/tty5) start/ | ||
+ | tty (/dev/tty4) start/ | ||
+ | plymouth-shutdown stop/ | ||
+ | control-alt-delete stop/ | ||
+ | rcS-emergency stop/ | ||
+ | readahead-collector stop/ | ||
+ | kexec-disable stop/ | ||
+ | quit-plymouth stop/ | ||
+ | testjob stop/ | ||
+ | rcS stop/ | ||
+ | prefdm start/ | ||
+ | init-system-dbus stop/ | ||
+ | readahead stop/ | ||
+ | splash-manager stop/ | ||
+ | start-ttys stop/ | ||
+ | readahead-disable-services stop/ | ||
+ | rcS-sulogin stop/ | ||
+ | serial stop/ | ||
+ | </ | ||
- | * Lancer un système d' | + | ==Option |
- | * Lancer l' | + | |
- | * Lancer l’interface de la ligne de commande GRUB en appuyant sur la touche **c**. | + | |
- | En mode édition notez l' | + | Les options de la commande **initctl** sont : |
- | * **flèches** : se déplacer dans l' | + | < |
- | * **Crtl-X** : démarrer avec la configuration modifiée, | + | [root@centos6 ~]# initctl |
- | * **echap** | + | Usage: initctl [OPTION]... COMMAND [OPTION]... [ARG]... |
- | <WRAP center round important> | + | Options: |
- | **Important** | + | --system |
- | </ | + | --dest=NAME |
+ | -q, --quiet | ||
+ | -v, --verbose | ||
+ | --help | ||
+ | | ||
- | ====Chargeurs de Démarrages Alternatifs==== | + | For a list of commands, try `initctl help'. |
- | ===Systemd-boot=== | + | Report bugs at < |
- | Un Chargeur de Démarrage étroitement lié à Systemd ( voir plus bas ), celui-ci connaît actuellement un gain de popularité. | + | </ |
- | ===U-boot=== | + | ===Jobs=== |
- | Un Chargeur | + | Il existe trois types de jobs sous Upstart : |
- | ===Le Projet Syslinux=== | + | * **task** |
+ | * **service** | ||
+ | * un service job peut fonctionner en arrière plan | ||
+ | * **abstract** | ||
+ | * un abstract job est un service qui fonctionnent jusqu' | ||
- | ==SYSLINUX== | + | ===Événements=== |
- | Un Chargeur de Démarrage | + | Un événement ou //event// en anglais est un signal envoyé vers un job pour déclencher une action. Par exemple |
- | ==EXTLINUX== | + | * **starting** |
+ | * **started** | ||
+ | * **stopping** | ||
+ | * **stopped** | ||
- | Un Chargeur de Démarrage de petite taille qui sait booter des systèmes de fichier, EXT2, EXT3, EXT4 et BRTFS. | + | ===Etats=== |
- | ==ISOLINUX== | + | L' |
- | Un Chargeur | + | * **waiting** - l' |
+ | * **starting** - le job est sur le point de démarrer | ||
+ | * **pre-start** - la section pre-start est chargée | ||
+ | * **spawned** - une section script est sur le point de démarrer | ||
+ | * **post-start** - les opérations détaillées dans la section post-start ont lieu | ||
+ | * **running** - le job est opérationnel | ||
+ | * **pre-stop** - la section pre-stop est chargée | ||
+ | * **stopping** - le job est en cours d'arrêt | ||
+ | * **killed** - le job est arrêté | ||
+ | * **post-stop** - les opérations détaillées dans la section post-stop ont lieu | ||
- | * **isolinux.bin** qui contient l' | + | ===Démarrer |
- | * **isolinux.cfg** qui contient | + | |
- | ==PXELINUX== | + | Compte tenu de la compatibilité avec le système |
- | + | ||
- | Un Chargeur | + | |
- | * **DHCP** pour attribuer une adresse IP à la machine et | + | ==La Commande status== |
- | * **BOOTP** pour charger l' | + | |
- | ===Isodhpfx=== | + | Pour voir le status d'un job spécifique, |
- | Un Chargeur de Démarrage hybride, appelé **isodhpfx.bin**, | + | < |
+ | [root@centos6 ~]# status testjob | ||
+ | testjob stop/ | ||
+ | </ | ||
- | ====Initramfs sous RHEL/CentOS 6==== | + | ==Options de la Commande status== |
- | Un fichier Initramfs //%%INITial Ram File System%%// est une image d'un système minimal initialisée au démarrage du système. | + | Les options de la commande **status** sont : |
- | Ce fichier utilise le système de fichier **cramFS** qui est un système de fichier compressé au format gzip et archivé via cpio. | + | < |
+ | [root@centos6 ~]# status --help | ||
+ | Usage: status [OPTION]... JOB [KEY=VALUE]... | ||
+ | Query status of job. | ||
- | L' | + | Options: |
+ | --system | ||
+ | --dest=NAME | ||
+ | -q, --quiet | ||
+ | -v, --verbose | ||
+ | --help | ||
+ | --version | ||
- | ===Examiner l' | + | 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. | ||
- | Pour examiner une image initramfs, il convient d' | ||
- | <code> | + | Report bugs at <https://launchpad.net/upstart/+bugs> |
- | [root@centos6 ~]# cp /boot/initramfs-2.6.32-71.29.1.el6.i686.img | + | |
- | [root@centos6 ~]# gunzip / | + | |
</ | </ | ||
- | Ensuite il convient d' | + | ==La Commande start== |
< | < | ||
- | [root@centos6 ~]# cd /tmp | + | [root@centos6 ~]# start testjob |
- | [root@centos6 tmp]# mkdir initrd | + | testjob start/running, process 2981 |
- | [root@centos6 tmp]# cd initrd | + | [root@centos ~]# cat / |
- | [root@centos6 initrd]# cpio -cid -I ../custom | + | Le job test a été lancé le Tue Jun 30 15:26:10 CEST 2015 |
- | 59631 blocs | + | |
</ | </ | ||
- | Installez maintenant le paquet | + | ==Options de la Commande start== |
+ | |||
+ | Les options de la commande | ||
< | < | ||
- | [root@centos6 | + | [root@centos6 |
- | </ | + | Usage: start [OPTION]... JOB [KEY=VALUE]... |
+ | Start job. | ||
- | Utilisez maintenant la commande **tree** pour examiner le contenu de l' | + | Options: |
+ | -n, --no-wait | ||
+ | --system | ||
+ | --dest=NAME | ||
+ | -q, --quiet | ||
+ | -v, --verbose | ||
+ | --help | ||
+ | --version | ||
- | < | + | JOB is the name of the job that is to be started, this may be followed by zero |
- | [root@centos6 initrd]# tree | more | + | or more environment variables to be defined in the new job. |
- | . | + | |
- | ├── bin | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | │ | + | |
- | ├── cmdline | + | |
- | --Plus-- | + | |
- | </ | + | |
- | Comme vous pouvez le constater, l' | + | 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:// | ||
- | < | ||
- | [root@centos6 initrd]# ls | ||
- | bin dev emergency | ||
- | cmdline | ||
</ | </ | ||
- | <WRAP center round todo> | + | ==La Commande stop== |
- | **A faire** : Utilisez le manuel de la commande **cpio** pour comprendre les options utilisées. | + | |
- | </ | + | |
- | ===Le script init=== | + | Pour arrêter un job, utilisez la commande **stop**. |
- | Le script | + | ==Options de la Commande stop== |
+ | |||
+ | Les options de la commande | ||
< | < | ||
- | [root@centos6 | + | [root@centos6 |
- | #!/bin/sh | + | Usage: stop [OPTION]... JOB [KEY=VALUE]... |
- | # | + | Stop job. |
- | # Licensed under the GPLv2 | + | |
- | # | + | Options: |
- | # Copyright 2008-2009, Red Hat, Inc. | + | -n, --no-wait |
- | # Harald Hoyer < | + | --system |
- | # Jeremy Katz < | + | --dest=NAME |
+ | -q, --quiet | ||
+ | -v, --verbose | ||
+ | --help | ||
+ | --version | ||
+ | |||
+ | 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. | ||
- | wait_for_loginit() | + | Report bugs at <https://launchpad.net/upstart/+bugs> |
- | { | + | |
- | if getarg rdinitdebug; | + | |
- | set +x | + | |
- | exec 0<>/dev/console 1<>/dev/console 2<>/ | + | |
- | # wait for loginit | + | |
- | i=0 | + | |
- | while [ $i -lt 10 ]; do | + | |
- | j=$(jobs) | + | |
- | [ -z " | + | |
- | [ -z " | + | |
- | sleep 0.1 | + | |
- | i=$(($i+1)) | + | |
- | done | + | |
- | [ $i -eq 10 ] && kill %1 >/ | + | |
- | while pidof -x / | ||
- | for pid in $(pidof -x / | ||
- | kill $HARD $pid >/ | ||
- | done | ||
- | --Plus--(8%) | ||
</ | </ | ||
- | <WRAP center round todo> | + | ==La Commande restart== |
- | **A faire** : Passez en revue le contenu du script. | + | |
- | </ | + | |
- | ===La Commande dracut=== | + | Pour redémarrer un job, utilisez la commande **restart**. |
- | La commande **dracut** permet | + | ==Options |
+ | |||
+ | Les options de la commande | ||
< | < | ||
- | [root@centos6 | + | [root@centos6 |
- | Usage: | + | Usage: |
- | Creates initial ramdisk images for preloading modules | + | Restart job. |
- | -f, --force | + | Options: |
- | -m, --modules [LIST] | + | -n, --no-wait do not wait for job to restart before exiting |
- | call when building the initramfs. Modules are located | + | --system |
- | in / | + | --dest=NAME |
- | -o, --omit [LIST] | + | -q, --quiet |
- | -a, --add [LIST] | + | -v, --verbose |
- | | + | --help |
- | exclusively include in the initramfs. | + | --version |
- | --add-drivers [LIST] | + | |
- | modules | + | |
- | --filesystems [LIST] | + | |
- | modules to exclusively include in the generic | + | |
- | initramfs. | + | |
- | -k, --kmoddir [DIR] | + | |
- | modules | + | |
- | --fwdir [DIR] | + | |
- | firmwares, separated by : | + | |
- | | + | |
- | --no-kernel | + | |
- | --strip | + | |
- | --nostrip | + | |
- | --mdadmconf | + | |
- | --nomdadmconf | + | |
- | | + | |
- | --nolvmconf | + | |
- | -h, --help | + | |
- | --debug | + | |
- | -v, --verbose | + | |
- | -c, --conf [FILE] | + | |
- | | + | |
- | -l, --local | + | |
- | | + | |
- | / | + | |
- | | + | |
- | -H, --hostonly | + | |
- | | + | |
- | -i, --include [SOURCE] [TARGET] | + | |
- | Include the files in the SOURCE directory into the | + | |
- | | + | |
- | -I, --install [LIST] | + | |
- | | + | |
- | </ | + | |
- | Le fichier de configuration de dracut est **/ | + | 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 |
- | [root@centos6 initrd]# cat /etc/dracut.conf | + | decide which of multiple instances will be restarted. |
- | # Sample dracut config file | + | |
- | # Specific list of dracut modules to use | + | Report bugs at < |
- | # | + | |
- | # Dracut modules to omit | + | </ |
- | # | + | |
- | # Dracut modules to add to the default | + | <WRAP center round important> |
- | # | + | Il est aussi possible d' |
+ | </ | ||
- | # additional kernel modules to the default | + | =====Démarrer RHEL/CentOS 7===== |
- | add_drivers+="" | + | |
- | # list of kernel filesystem modules to be included in the generic initramfs | + | RHEL/CentOS 7, comme beaucoup d' |
- | # | + | |
- | # build initrd only to boot current hardware | + | Au lieu de parler de scripts de démarrage et de niveaux d' |
- | # | + | |
- | # | + | |
- | # install local /etc/mdadm.conf | + | * un automount - (.automount), |
- | mdadmconf=" | + | * une périphérique - //Device// - (.device), |
+ | * un montage d'un périphérique - //Mount// - (.mount), | ||
+ | * un chemin - //Path// - (.path) | ||
+ | * un socket - //Socket// - (.socket), | ||
+ | * un service - //Service// - (.service), | ||
+ | * une instantanée - // | ||
+ | * une cible - //Target// - (.target). | ||
- | # install local / | + | <WRAP center round important> |
- | lvmconf=" | + | **Important** : Dans le contexte d'une Unité, le type **cible** regroupe des Unités multiples afin qu' |
- | </file> | + | </WRAP> |
- | Exécutez maintenant la commande suivante afin de générer le fichier **initramfs** : | + | ====La Commande systemctl==== |
- | # dracut | + | Pour visualiser la liste des Unités, il convient d' |
- | Notez la présence de votre nouvelle image **/tmp/initrd/initramfs**. | + | < |
+ | [root@centos7 ~]# systemctl list-units | ||
+ | UNIT | ||
+ | proc-sys-fs-binfmt_misc.automount | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-platform-serial8250-tty-ttyS0.device | ||
+ | sys-devices-platform-serial8250-tty-ttyS1.device | ||
+ | sys-devices-platform-serial8250-tty-ttyS2.device | ||
+ | sys-devices-platform-serial8250-tty-ttyS3.device | ||
+ | sys-module-configfs.device | ||
+ | sys-module-fuse.device | ||
+ | sys-subsystem-net-devices-enp0s3.device | ||
+ | -.mount | ||
+ | boot.mount | ||
+ | dev-hugepages.mount | ||
+ | dev-mqueue.mount | ||
+ | proc-fs-nfsd.mount | ||
+ | run-media-trainee-VBOXADDITIONS_4.3.28_100309.mount | ||
+ | run-user-1000-gvfs.mount | ||
+ | sys-fs-fuse-connections.mount | ||
+ | sys-kernel-config.mount | ||
+ | sys-kernel-debug.mount | ||
+ | var-lib-nfs-rpc_pipefs.mount | ||
+ | brandbot.path | ||
+ | cups.path | ||
+ | systemd-ask-password-plymouth.path | ||
+ | systemd-ask-password-wall.path | ||
+ | session-1.scope | ||
+ | abrt-ccpp.service | ||
+ | abrt-oops.service | ||
+ | abrt-xorg.service | ||
+ | abrtd.service | ||
+ | accounts-daemon.service | ||
+ | alsa-state.service | ||
+ | atd.service | ||
+ | auditd.service | ||
+ | avahi-daemon.service | ||
+ | bluetooth.service | ||
+ | chronyd.service | ||
+ | colord.service | ||
+ | crond.service | ||
+ | cups.service | ||
+ | dbus.service | ||
+ | firewalld.service | ||
+ | gdm.service | ||
+ | gssproxy.service | ||
+ | iscsi-shutdown.service | ||
+ | kdump.service | ||
+ | kmod-static-nodes.service | ||
+ | ksm.service | ||
+ | ksmtuned.service | ||
+ | libstoragemgmt.service | ||
+ | libvirtd.service | ||
+ | lvm2-lvmetad.service | ||
+ | </ | ||
- | Déplacez votre fichier initramfs au répertoire /boot : | + | Pour consulter la liste des Unités inactifs, utilisez la commande suivante |
< | < | ||
- | [root@centos6 initrd]# mv initramfs /boot | + | [root@centos7 ~]# systemctl list-units --all | grep inactive | more |
+ | proc-sys-fs-binfmt_misc.mount | ||
+ | File System | ||
+ | systemd-ask-password-console.path | ||
+ | ole Directory Watch | ||
+ | abrt-vmcore.service | ||
+ | alsa-restore.service | ||
+ | alsa-store.service | ||
+ | apparmor.service | ||
+ | auth-rpcgss-module.service | ||
+ | S | ||
+ | brandbot.service | ||
+ | cpupower.service | ||
+ | gs | ||
+ | dm-event.service | ||
+ | dmraid-activation.service | ||
+ | dracut-shutdown.service | ||
+ | ebtables.service | ||
+ | emergency.service | ||
+ | exim.service | ||
+ | getty@tty1.service | ||
+ | hypervkvpd.service | ||
+ | hypervvssd.service | ||
+ | ip6tables.service | ||
+ | iptables.service | ||
+ | irqbalance.service | ||
+ | iscsi.service | ||
+ | s | ||
+ | iscsid.service | ||
+ | iscsiuio.service | ||
+ | --More-- | ||
</ | </ | ||
- | Editez maintenant votre fichier **/ | + | Pour consulter la liste des fichiers Unités, utilisez la commande suivante : |
- | <file> | + | <code> |
- | ... | + | [root@centos7 ~]# systemctl list-unit-files | more |
- | splashimage=(hd0, | + | UNIT FILE |
- | hiddenmenu | + | proc-sys-fs-binfmt_misc.automount |
- | title CentOS Linux (initramfs) | + | dev-hugepages.mount |
- | root (hd0,0) | + | dev-mqueue.mount static |
- | kernel | + | proc-fs-nfsd.mount static |
- | initrd /initramfs | + | proc-sys-fs-binfmt_misc.mount |
- | title CentOS Linux (2.6.32-71.29.1.el6.i686) | + | sys-fs-fuse-connections.mount |
- | ... | + | sys-kernel-config.mount |
- | </file> | + | sys-kernel-debug.mount static |
+ | tmp.mount | ||
+ | var-lib-nfs-rpc_pipefs.mount static | ||
+ | brandbot.path | ||
+ | cups.path | ||
+ | systemd-ask-password-console.path | ||
+ | systemd-ask-password-plymouth.path | ||
+ | systemd-ask-password-wall.path static | ||
+ | session-1.scope | ||
+ | session-8.scope | ||
+ | abrt-ccpp.service | ||
+ | abrt-oops.service | ||
+ | abrt-pstoreoops.service | ||
+ | abrt-vmcore.service | ||
+ | abrt-xorg.service | ||
+ | abrtd.service | ||
+ | accounts-daemon.service | ||
+ | alsa-restore.service | ||
+ | alsa-state.service | ||
+ | alsa-store.service | ||
+ | anaconda-direct.service | ||
+ | --More-- | ||
+ | </code> | ||
+ | ===Options de la Commande systemctl=== | ||
- | <WRAP center round todo> | + | Les options de la commande |
- | **A faire** : **Re-démarrez votre machine pour tester votre configuration.** | + | |
- | </ | + | |
- | + | ||
- | ====Initramfs sous RHEL/CentOS 7==== | + | |
- | + | ||
- | Le fichier Initramfs //%%INITial Ram File System%%// est une archive au format cpio compressé | + | |
< | < | ||
- | [root@centos7 ~]# cp / | + | [root@centos7 ~]# systemctl |
- | [root@centos7 ~]# cd /tmp | + | systemctl |
- | [root@centos7 tmp]# ls | + | |
- | custom | + | |
- | [root@centos7 tmp]# mv custom custom.gz | + | |
- | [root@centos7 tmp]# gunzip custom.gz | + | |
- | [root@centos7 tmp]# mkdir initramfs | + | |
- | [root@centos7 tmp]# cd initramfs | + | |
- | [root@centos7 initramfs]# cpio -cid -I ../custom | + | |
- | 113591 blocks | + | |
- | [root@centos7 initramfs]# ls | + | |
- | bin dev etc init lib lib64 proc root run sbin shutdown | + | |
- | [root@centos7 initramfs]# ls -l | + | |
- | total 4 | + | |
- | lrwxrwxrwx. | + | |
- | drwxr-xr-x. | + | |
- | drwxr-xr-x. 11 root root 520 Dec 4 11:00 etc | + | |
- | lrwxrwxrwx. | + | |
- | lrwxrwxrwx. | + | |
- | lrwxrwxrwx. | + | |
- | drwxr-xr-x. | + | |
- | drwxr-xr-x. | + | |
- | drwxr-xr-x. | + | |
- | lrwxrwxrwx. | + | |
- | -rwxr-xr-x. | + | |
- | drwxr-xr-x. | + | |
- | drwxr-xr-x. | + | |
- | drwxr-xr-x. | + | |
- | drwxr-xr-x. | + | |
- | drwxr-xr-x. | + | |
- | </ | + | |
- | ===Examiner l' | + | Query or send control commands to the systemd manager. |
- | Pour examiner une image initramfs archivée, il convient d'utiliser la commande **lsinitrd** : | + | -h --help |
+ | | ||
+ | -t --type=TYPE | ||
+ | | ||
+ | -p --property=NAME | ||
+ | -a --all Show all loaded units/ | ||
+ | ones. To list all units installed on the system, use | ||
+ | the 'list-unit-files' | ||
+ | | ||
+ | -l --full | ||
+ | | ||
+ | pending | ||
+ | | ||
+ | cancelled | ||
+ | | ||
+ | When queueing a new job, ignore all its dependencies | ||
+ | | ||
+ | -i --ignore-inhibitors | ||
+ | When shutting down or sleeping, ignore inhibitors | ||
+ | | ||
+ | -s --signal=SIGNAL | ||
+ | -H --host=[USER@]HOST | ||
+ | Show information for remote host | ||
+ | -P --privileged | ||
+ | -q --quiet | ||
+ | | ||
+ | | ||
+ | | ||
+ | configuration | ||
+ | | ||
+ | | ||
+ | | ||
+ | Do not ask for system passwords | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | -f --force | ||
+ | When shutting down, execute action immediately | ||
+ | | ||
+ | -n --lines=INTEGER | ||
+ | -o --output=STRING | ||
+ | verbose, export, json, json-pretty, | ||
+ | | ||
- | < | + | Unit Commands: |
- | [root@centos7 initramfs]# cd .. | + | |
- | [root@centos7 tmp]# lsinitrd custom | + | list-sockets |
- | Image: custom: 56M | + | start [NAME...] Start (activate) one or more units |
- | ======================================================================== | + | stop [NAME...] Stop (deactivate) one or more units |
- | Version: dracut-033-502.el7_4.1 | + | |
+ | restart [NAME...] | ||
+ | try-restart [NAME...] | ||
+ | reload-or-restart [NAME...] | ||
+ | otherwise start or restart | ||
+ | reload-or-try-restart [NAME...] Reload one or more units if possible, | ||
+ | otherwise restart if active | ||
+ | isolate [NAME] | ||
+ | kill [NAME...] | ||
+ | is-active [NAME...] | ||
+ | is-failed [NAME...] | ||
+ | status [NAME...|PID...] | ||
+ | show [NAME...|JOB...] | ||
+ | | ||
+ | set-property [NAME] [ASSIGNMENT...] | ||
+ | Sets one or more properties of a unit | ||
+ | help [NAME...|PID...] | ||
+ | reset-failed [NAME...] Reset failed state for all, one, or more | ||
+ | units | ||
+ | list-dependencies [NAME] | ||
+ | or wanted by this unit or by which this | ||
+ | unit is required or wanted | ||
- | Arguments: -f | + | Unit File Commands: |
+ | list-unit-files | ||
+ | enable [NAME...] | ||
+ | disable [NAME...] | ||
+ | reenable [NAME...] | ||
+ | preset [NAME...] | ||
+ | based on preset configuration | ||
+ | is-enabled [NAME...] | ||
- | dracut modules: | + | mask [NAME...] Mask one or more units |
- | bash | + | |
- | nss-softokn | + | |
- | i18n | + | the search path |
- | network | + | get-default |
- | ifcfg | + | |
- | drm | + | |
- | plymouth | + | |
- | kernel-modules | + | |
- | qemu | + | |
- | resume | + | |
- | rootfs-block | + | |
- | terminfo | + | |
- | udev-rules | + | |
- | biosdevname | + | |
- | systemd | + | |
- | usrmount | + | |
- | base | + | |
- | fs-lib | + | |
- | shutdown | + | |
- | ======================================================================== | + | |
- | drwxr-xr-x | + | |
- | crw-r--r-- | + | |
- | crw-r--r-- | + | |
- | crw-r--r-- | + | |
- | lrwxrwxrwx | + | |
- | drwxr-xr-x | + | |
- | drwxr-xr-x | + | |
- | drwxr-xr-x | + | |
- | drwxr-xr-x | + | |
- | -rw-r--r-- | + | |
- | -rw-r--r-- | + | |
- | -rw-r--r-- | + | |
- | --More-- | + | |
- | </ | + | |
- | Comme vous pouvez le constater, l' | + | Job Commands: |
+ | list-jobs | ||
+ | cancel [JOB...] | ||
- | ===Le script init=== | + | Snapshot Commands: |
+ | snapshot [NAME] | ||
+ | delete [NAME...] | ||
- | Le script **init** est lancé lors du chargement de l' | + | Environment Commands: |
+ | show-environment | ||
+ | set-environment [NAME=VALUE...] Set one or more environment variables | ||
+ | unset-environment [NAME...] | ||
- | < | + | Manager Lifecycle Commands: |
- | [root@centos7 tmp]# lsinitrd custom | grep init | + | |
- | ... | + | |
- | lrwxrwxrwx. | + | |
- | ... | + | System Commands: |
+ | | ||
+ | rescue | ||
+ | emergency | ||
+ | halt Shut down and halt the system | ||
+ | poweroff | ||
+ | reboot | ||
+ | kexec Shut down and reboot the system with kexec | ||
+ | exit Request user instance exit | ||
+ | switch-root [ROOT] [INIT] | ||
+ | suspend | ||
+ | hibernate | ||
+ | hybrid-sleep Hibernate and suspend the system | ||
+ | lines 95-123/123 (END) | ||
</ | </ | ||
- | ===Consulter le contenu d'un fichier dans initramfs=== | + | ====Fichiers de Configuration==== |
- | Pour consulter le contenu d'un fichier inclus | + | Les Cibles et les Unités sont configurées par des fichiers se trouvant |
< | < | ||
- | [root@centos7 | + | [root@centos7 |
- | include ld.so.conf.d/*.conf | + | 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/ | ||
+ | lrwxrwxrwx. 1 root root 41 Mar 8 13:48 dbus-org.fedoraproject.FirewallD1.service -> / | ||
+ | lrwxrwxrwx. 1 root root 44 Mar 8 13:48 dbus-org.freedesktop.Avahi.service -> /usr/ | ||
+ | lrwxrwxrwx. 1 root root 44 Mar 8 13:57 dbus-org.freedesktop.ModemManager1.service -> / | ||
+ | lrwxrwxrwx. 1 root root 46 Mar 8 13:49 dbus-org.freedesktop.NetworkManager.service -> / | ||
+ | lrwxrwxrwx. 1 root root 57 Mar 8 13:49 dbus-org.freedesktop.nm-dispatcher.service -> / | ||
+ | lrwxrwxrwx. 1 root root 36 Mar 8 14:05 default.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 -> / | ||
+ | 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 | ||
</ | </ | ||
- | ===La Commande dracut=== | + | ainsi que par des fichiers se trouvant dans le répertoire **/ |
- | La commande **dracut** permet de créer facilement une image initramfs. Les options de la commande sont : | + | < |
+ | [root@centos7 ~]# ls -l / | ||
+ | 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@centos7 | + | [root@centos7 |
- | Usage: / | + | 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-- | ||
+ | </code> | ||
- | Version: 033-463.el7 | + | Par exemple, sous RHEL/CentOS 7, le service **sshd** est configuré par le fichier **/ |
- | Creates initial ramdisk images for preloading modules | + | < |
+ | [root@centos7 ~]# cat / | ||
+ | [Unit] | ||
+ | Description=OpenSSH server daemon | ||
+ | After=network.target sshd-keygen.service | ||
+ | Wants=sshd-keygen.service | ||
- | --kver [VERSION] | + | [Service] |
- | -f, --force | + | EnvironmentFile=/etc/sysconfig/sshd |
- | -a, --add [LIST] | + | ExecStart=/usr/sbin/sshd -D $OPTIONS |
- | --rebuild | + | ExecReload=/bin/kill -HUP $MAINPID |
- | -m, --modules [LIST] | + | KillMode=process |
- | call when building the initramfs. Modules are located | + | Restart=on-failure |
- | in / | + | RestartSec=42s |
- | -o, --omit [LIST] | + | |
- | --force-add [LIST] | + | |
- | to the default set of modules, when -H is specified. | + | |
- | -d, --drivers [LIST] | + | |
- | | + | |
- | --add-drivers [LIST] | + | |
- | | + | |
- | --omit-drivers [LIST] Specify a space-separated list of kernel | + | |
- | | + | |
- | --filesystems [LIST] | + | |
- | | + | |
- | | + | |
- | -k, --kmoddir [DIR] | + | |
- | | + | |
- | --fwdir [DIR] | + | |
- | | + | |
- | --kernel-only | + | |
- | --no-kernel | + | |
- | --print-cmdline | + | |
- | --early-microcode | + | |
- | --no-early-microcode | + | |
- | --kernel-cmdline [PARAMETERS] Specify default kernel command line parameters | + | |
- | --strip | + | |
- | --nostrip | + | |
- | --prelink | + | |
- | --noprelink | + | |
- | --hardlink | + | |
- | --nohardlink | + | |
- | --prefix [DIR] Prefix initramfs files with [DIR] | + | |
- | --noprefix | + | |
- | --mdadmconf | + | |
- | --nomdadmconf | + | |
- | | + | |
- | | + | |
- | | + | |
- | --nofscks | + | |
- | --ro-mnt | + | |
- | -h, --help | + | |
- | --debug | + | |
- | | + | |
- | -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 | + | |
- | -q, --quiet | + | |
- | -c, --conf [FILE] | + | |
- | | + | |
- | --confdir [DIR] | + | |
- | from. Default: / | + | |
- | --tmpdir [DIR] Temporary directory to be used instead of default | + | |
- | / | + | |
- | -l, --local | + | |
- | | + | |
- | / | + | |
- | | + | |
- | -H, --hostonly | + | |
- | booting the local host instead of a generic host. | + | |
- | -N, --no-hostonly | + | |
- | --hostonly-cmdline | + | |
- | in the initramfs | + | |
- | --no-hostonly-cmdline Do not store kernel command line arguments needed | + | |
- | in the initramfs | + | |
- | --hostonly-i18n | + | |
- | to the host configuration (default). | + | |
- | --no-hostonly-i18n | + | |
- | --persistent-policy [POLICY] | + | |
- | Use [POLICY] to address disks and partitions. | + | |
- | POLICY can be any directory name found in / | + | |
- | E.g. " | + | |
- | --fstab | + | |
- | --add-fstab [FILE] | + | |
- | --mount "[DEV] [MP] [FSTYPE] [FSOPTS]" | + | |
- | Mount device [DEV] on mountpoint [MP] with filesystem | + | |
- | [FSTYPE] and options [FSOPTS] in the initramfs | + | |
- | | + | |
- | -i, --include [SOURCE] [TARGET] | + | |
- | Include the files in the SOURCE directory into the | + | |
- | | + | |
- | If SOURCE is a file, it will be installed to TARGET | + | |
- | in the final initramfs. | + | |
- | -I, --install [LIST] | + | |
- | | + | |
- | --install-optional [LIST] | + | |
- | | + | |
- | --gzip | + | |
- | This will be done by default, unless another | + | |
- | | + | |
- | --bzip2 | + | |
- | Make sure your kernel has bzip2 decompression support | + | |
- | | + | |
- | --lzma | + | |
- | Make sure your kernel has lzma support compiled in, | + | |
- | | + | |
- | --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 | + | |
- | | + | |
- | knows how to decompress the generated initramfs, | + | |
- | | + | |
- | --no-compress | + | |
- | | + | |
- | --list-modules | + | |
- | -M, --show-modules | + | |
- | | + | |
- | --keep | + | |
- | --printsize | + | |
- | --sshkey [SSHKEY] | + | |
- | --logfile [FILE] | + | |
- | + | ||
- | If [LIST] has multiple arguments, then you have to put these in quotes. | + | |
- | + | ||
- | For example: | + | |
- | + | ||
- | # dracut --add-drivers " | + | |
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
</ | </ | ||
- | Le fichier | + | Dans le fichier |
- | < | + | |
- | # PUT YOUR CONFIG HERE OR IN separate files named *.conf | + | * Cette ligne définit l' |
- | # in /etc/dracut.conf.d | + | * **After=network.target sshd-keygen.service**, |
- | # SEE man dracut.conf(5) | + | * Cette ligne indique les services qui devraient être démarrés avant le démarrage de sshd, |
+ | * **WantedBy=multi-user.target**, | ||
+ | * Cette ligne indique la Cible dans laquelle le service doit être démarré, | ||
+ | * **Restart=on-failure**, | ||
+ | * Cette ligne indique quand le service doit être re-démarré. | ||
- | # Sample dracut config file | + | ====Système de Démarrage==== |
- | # | + | **Systemd** utilise des Cibles d'une manière similaire à ce que **SysVinit** utilise des niveaux d' |
- | # | + | |
- | # Exact list of dracut modules to use. | + | * runlevel0.target, |
- | # to be included. | + | * runlevel1.target, |
- | # add_dracutmodules option instead. | + | * runlevel2.target, |
- | # | + | * runlevel3.target, |
+ | * runlevel4.target, | ||
+ | * runlevel5.target, | ||
+ | * runlevel6.target. | ||
- | # dracut modules to omit | + | Ceci étant dans RHEL/CentOS 7 il y principalement deux Cibles finales : |
- | # | + | |
- | # dracut modules to add to the default | + | * **multi-user.target** qui est l' |
- | # | + | * **graphical.target** qui est l' |
- | # additional kernel modules to the default | + | Chaque Cible est décrite par un fichier de configuration : |
- | add_drivers+=" | + | |
- | # list of kernel filesystem modules to be included in the generic initramfs | + | < |
- | #filesystems+="" | + | [root@centos7 ~]# cat / |
- | + | # This file is part of systemd. | |
- | # build initrd only to boot current hardware | + | |
- | # | + | |
# | # | ||
+ | # 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. | ||
- | # install local /etc/mdadm.conf | + | [Unit] |
- | #mdadmconf=" | + | Description=Graphical Interface |
+ | Documentation=man: | ||
+ | Requires=multi-user.target | ||
+ | After=multi-user.target | ||
+ | Conflicts=rescue.target | ||
+ | Wants=display-manager.service | ||
+ | AllowIsolate=yes | ||
- | # install local / | + | [Install] |
- | # | + | Alias=default.target |
+ | </ | ||
- | # A list of fsck tools to install. If it's not specified, module' | + | Dans ce fichier on peut noter la présence des lignes suivantes |
- | # default is used, currently: " | + | |
- | # xfs_repair e2fsck jfs_fsck reiserfsck btrfsck" | + | |
- | # opportunistic, | + | |
- | # | + | |
- | # inhibit installation of any fsck tools | + | * **Requires=multi-user.target**, |
- | #nofscks=" | + | * Cette ligne indique que le **graphical.target** ne peut pas être atteint si le **multi-user.target** n'a pas été atteint aupréalable, |
+ | * **After=multi-user.target**, | ||
+ | * Cette ligne indique le **multi-user.target** doit d' | ||
+ | * **Conflicts=rescue.target**, | ||
+ | * Cette ligne indique la Cible en conflit avec le **graphical.target**, | ||
+ | * **Wants=display-manager.service**, | ||
+ | * Cette ligne indique quel service doit être démarré. | ||
- | # mount / and /usr read-only by default | + | Dernièrement, |
- | # | + | |
- | # set the directory for temporary files | + | < |
- | # default: /var/tmp | + | [root@centos7 ~]# ls -l / |
- | #tmpdir=/tmp | + | lrwxrwxrwx. 1 root root 36 Mar 8 14:05 /etc/systemd/system/ |
- | </file> | + | </code> |
+ | |||
+ | ====La Commande systemd-analyze==== | ||
- | Exécutez maintenant | + | Pour avoir une évaluation du temps de démarrage, il convient d' |
< | < | ||
- | [root@centos7 | + | [root@centos7 |
- | Executing: / | + | Startup finished in 769ms (kernel) + 4.643s (initrd) + 40.147s (userspace) = 45.560s |
- | dracut module ' | + | |
- | dracut module ' | + | |
- | *** 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: qemu *** | + | |
- | *** 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: | + | |
- | *** Including module: usrmount *** | + | |
- | *** Including module: base *** | + | |
- | *** Including module: fs-lib *** | + | |
- | *** Including module: shutdown *** | + | |
- | *** Including modules done *** | + | |
- | *** Installing | + | |
- | *** 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 contents *** | + | |
- | *** Constructing GenuineIntel.bin **** | + | |
- | *** Store current command line parameters *** | + | |
- | *** Creating image file *** | + | |
- | *** Creating microcode section *** | + | |
- | *** Created microcode section *** | + | |
- | *** Creating image file done *** | + | |
- | *** Creating initramfs image file '/ | + | |
</ | </ | ||
- | Notez la présence de votre nouvelle image **/ | + | L' |
< | < | ||
- | [root@centos7 | + | [root@centos7 |
- | -rw-------. 1 root root 16373488 Jun 10 10:23 /tmp/initrd/initramfs | + | 12.274s firewalld.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.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) | ||
</ | </ | ||
- | Déplacez votre fichier initramfs | + | L' |
< | < | ||
- | [root@centos7 | + | [root@centos7 |
+ | The time after the unit is active or started is printed after the " | ||
+ | The time the unit takes to start is printed after the " | ||
+ | |||
+ | 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 | ||
</ | </ | ||
- | Ouvrez votre fichier **/ | + | ===Options de la Commande=== |
+ | |||
+ | Les options de la commande | ||
< | < | ||
- | ... | + | [root@centos7 ~]# systemd-analyze --help |
- | ### BEGIN / | + | systemd-analyze [OPTIONS...] {COMMAND} |
- | menuentry ' | + | |
- | load_video | + | Process systemd profiling information |
- | set gfxpayload=keep | + | |
- | insmod gzio | + | -h --help Show this help |
- | insmod part_msdos | + | --version |
- | insmod xfs | + | --system |
- | set root=' | + | --user |
- | if [ x$feature_platform_search_hint = xy ]; then | + | --order When generating a dependency graph, show only order |
- | search | + | --require |
- | else | + | --from-pattern=GLOB, --to-pattern=GLOB |
- | search | + | When generating a dependency graph, filter only origins |
- | fi | + | or destinations, |
- | linux16 /vmlinuz-3.10.0-229.4.2.el7.x86_64 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto | + | |
- | initrd16 /initramfs-3.10.0-229.4.2.el7.x86_64.img | + | |
- | } | + | |
- | ... | + | 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 | ||
+ | | ||
+ | dot | ||
+ | set-log-level LEVEL Set logging threshold for systemd | ||
+ | | ||
</ | </ | ||
- | Créez maintenant le fichier **/ | + | ====Gestion des Services==== |
- | < | + | Pour obtenir le détail sur un service donné, il convient d'utiliser la commande **systemctl** : |
- | #!/bin/sh -e | + | |
- | cat << EOF | + | |
- | menuentry ' | + | |
- | load_video | + | |
- | set gfxpayload=keep | + | |
- | insmod gzio | + | |
- | insmod part_msdos | + | |
- | insmod xfs | + | |
- | set root=' | + | |
- | if [ x$feature_platform_search_hint = xy ]; then | + | |
- | search --no-floppy --fs-uuid --set=root --hint-bios=hd0, | + | |
- | else | + | |
- | search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 | + | |
- | fi | + | |
- | linux16 / | + | |
- | initrd16 / | + | |
- | } | + | |
- | EOF | + | |
- | </ | + | |
- | Rendez ce fichier exécutable | + | < |
+ | [root@centos7 ~]# systemctl status sshd.service | ||
+ | sshd.service - OpenSSH server daemon | ||
+ | | ||
+ | | ||
+ | Main PID: 1212 (sshd) | ||
+ | | ||
+ | | ||
+ | |||
+ | 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. | ||
+ | </ | ||
+ | |||
+ | Pour arrêter une Unité de service, utilisez la commande suivante | ||
< | < | ||
- | [root@centos7 | + | [root@centos7 |
+ | [root@centos7 ~]# systemctl status sshd.service | ||
+ | sshd.service - OpenSSH server daemon | ||
+ | | ||
+ | | ||
+ | Process: 1212 ExecStart=/usr/ | ||
+ | Main PID: 1212 (code=exited, | ||
+ | |||
+ | 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. | ||
</ | </ | ||
- | Avant de continuer, supprimer le fichier **/ | + | Pour démarrer un service, utilisez la commande suivante |
- | <file> | + | <code> |
- | #!/bin/sh | + | [root@centos7 ~]# systemctl start ssh.service |
- | exec tail -n +3 $0 | + | [root@centos7 ~]# systemctl status sshd.service |
- | # This file provides an easy way to add custom menu entries. | + | sshd.service - OpenSSH server daemon |
- | # menu entries you want to add after this comment. Be careful not to change | + | |
- | # the 'exec tail' line above. | + | Active: active (running) since Thu 2015-06-11 14:00:17 CEST; 6s ago |
- | </file> | + | Main PID: 6624 (sshd) |
+ | CGroup: /system.slice/sshd.service | ||
+ | └─6624 | ||
- | Mettez à jour grub afin que celui-ci prend en compte le nouveau fichier | + | 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. | ||
+ | </ | ||
+ | |||
+ | Pour désactiver un service au prochain démarrage du système, utilisez l' | ||
< | < | ||
- | [root@centos7 | + | [root@centos7 |
- | Generating grub configuration file ... | + | rm '/etc/systemd/system/ |
- | Found linux image: /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64 | + | [root@centos7 ~]# systemctl status sshd.service |
- | Found initrd image: | + | sshd.service - OpenSSH server daemon |
- | Found linux image: / | + | |
- | Found initrd image: / | + | |
- | Found linux image: / | + | Main PID: 6624 (sshd) |
- | Found initrd image: / | + | |
- | done | + | └─6624 |
+ | |||
+ | 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. | ||
</ | </ | ||
- | Controlez le fichier / | + | Pour activer un service au prochain démarrage du système, utilisez l' |
- | <file> | + | <code> |
- | ... | + | [root@centos7 ~]# systemctl enable sshd.service |
- | ### BEGIN /etc/grub.d/09_redhat ### | + | ln -s '/usr/ |
- | menuentry ' | + | [root@centos7 ~]# systemctl status sshd.service |
- | | + | sshd.service |
- | set gfxpayload=keep | + | |
- | | + | |
- | | + | Main PID: 6624 (sshd) |
- | | + | CGroup: / |
- | set root=' | + | └─6624 / |
- | | + | |
- | search --no-floppy --fs-uuid --set=root --hint-bios=hd0, | + | Jun 11 14:00:17 centos7.fenestros.loc systemd[1]: Starting OpenSSH server daemon... |
- | else | + | 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. |
- | </file> | + | Jun 11 14:00:17 centos7.fenestros.loc sshd[6624]: Server listening on :: port 22. |
+ | </code> | ||
- | <WRAP center round todo> | ||
- | **A faire** : **Re-démarrez votre machine pour tester votre configuration.** | ||
- | </ | ||
=====Fichiers Spéciaux===== | =====Fichiers Spéciaux===== | ||
Ligne 3608: | Ligne 4021: | ||
----- | ----- | ||
- | Copyright © 2023 Hugh Norris. | + | Copyright © 2024 Hugh Norris. |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + |