Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
elearning:workbooks:redhat:rh134:l105 [2024/10/21 15:21] – removed admin | elearning:workbooks:redhat:rh134:l105 [2024/10/24 09:58] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ~~PDF: | ||
+ | Version : **2024.01** | ||
+ | |||
+ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
+ | |||
+ | ======RH13406 - Gestion du Démarrage et de l' | ||
+ | |||
+ | =====Contenu du Module===== | ||
+ | |||
+ | * **RH13406 - Gestion du Démarrage et de l' | ||
+ | * Contenu du Module | ||
+ | * Présentation | ||
+ | * BIOS, EFI et OpenFirmware | ||
+ | * Systèmes à base du BIOS | ||
+ | * Charger de Démarrage | ||
+ | * Systèmes à base de l'EFI | ||
+ | * Autres Systèmes | ||
+ | * Gestionnaire d' | ||
+ | * GRUB 2 | ||
+ | * Le fichier / | ||
+ | * Le fichier / | ||
+ | * Les fichiers du répertoire /etc/grub.d | ||
+ | * Configurer l' | ||
+ | * Modifier la Configuration de GRUB 2 en Ligne de Commande | ||
+ | * Chargeurs de Démarrages Alternatifs | ||
+ | * Systemd-boot | ||
+ | * U-boot | ||
+ | * Le Projet Syslinux | ||
+ | * SYSLINUX | ||
+ | * EXTLINUX | ||
+ | * ISOLINUX | ||
+ | * PXELINUX | ||
+ | * Isodhpfx | ||
+ | * Initramfs | ||
+ | * Examiner l' | ||
+ | * Le script init | ||
+ | * Consulter le contenu d'un fichier dans initramfs | ||
+ | * Processus de Démarrage du Noyau Linux | ||
+ | * Processus Init | ||
+ | * Systemd | ||
+ | * LAB #1 - La Commande systemctl | ||
+ | * LAB #2 - Fichiers de Configuration | ||
+ | * 2.1 - Fichiers de Configuration par Défaut | ||
+ | * 2.2 - Surchargement des Fichiers de Configuration par Défaut | ||
+ | * LAB #3 - La Commande systemd-analyze | ||
+ | * LAB #4 - Les Cibles Systemd | ||
+ | * 4.1 - Contrôler les dépendances d'une Cible | ||
+ | * 4.2 - La Cible par Défaut | ||
+ | * Arrêt Système du Système | ||
+ | * La Commande shutdown | ||
+ | * La Commande reboot | ||
+ | * La Commande halt | ||
+ | * La Commande poweroff | ||
+ | |||
+ | =====Présentation===== | ||
+ | |||
+ | Le processus de démarrage de Linux peut être résumé en trois étapes majeurs : | ||
+ | |||
+ | * Le **firmware** ou **micrologiciel** démarre en effectuant un test rapide du matériel, appelé un **Power-On Self Test** ou **POST**, puis recherche le **Charger de Démarrage** (// | ||
+ | * Le Charger de Démarrage est exécuté et il détermine quel noyau Linux à 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. | ||
+ | |||
+ | <WRAP center round tip 60%> | ||
+ | **A retenir** : Il est possible de consulter le défilement des messages lors du démarrage en appuyant sur la touche < | ||
+ | </ | ||
+ | |||
+ | Cette description simpliste résume cependant un processus bien plus compliqué que ce cours va détailler. | ||
+ | |||
+ | =====BIOS, EFI et OpenFirmware===== | ||
+ | |||
+ | ====Systèmes à base du BIOS==== | ||
+ | |||
+ | Au démarrage d'un système à base d'un processeur x86 ou x86-64, le premier programme exécuté a été traditionnellement le BIOS. Le BIOS a pour fonction de : | ||
+ | |||
+ | * Tester les composants et les circuits, | ||
+ | * Faire appel au BIOS de la carte graphique pour initialiser le système d' | ||
+ | * Détecter les périphériques de stockage, | ||
+ | * Lancer le **Charger de Démarrage** du système d' | ||
+ | |||
+ | ===Chargeur de Démarrage=== | ||
+ | |||
+ | La première partie du Chargeur de Démarrage est en règle générale placé dans le MBR du disque. Le format du MBR est le suivant : | ||
+ | |||
+ | * 446 octets pour le Charger de Démarrage, | ||
+ | * 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' | ||
+ | |||
+ | Depuis 2011, le BIOS est en train d' | ||
+ | |||
+ | 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, le micrologiciel (**firmware**) d'EFI doit avoir connaissance de chaque système d' | ||
+ | |||
+ | <WRAP center round tip 60%> | ||
+ | **A retenir** : Sous Linux c'est l' | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : L'UEFI gère les **SSD** (//Solid State Drives//) qui utilisent le standard **NVMe** (// | ||
+ | </ | ||
+ | |||
+ | ====Autres Systèmes==== | ||
+ | |||
+ | Les systèmes utilisant des processeurs autre qu'un x86 ou x86-64 utilisent un logiciel tel **[[http:// | ||
+ | |||
+ | =====Gestionnaires de Démarrage===== | ||
+ | |||
+ | ====GRUB 2==== | ||
+ | |||
+ | GRUB 2 est une ré-écriture complète de GRUB Legacy. Il apporte des améliorations, | ||
+ | |||
+ | Le lancement de GRUB 2 se fait en trois étapes : | ||
+ | |||
+ | * Etape 1 : Le **boot.img**, | ||
+ | * Etape 1.5 : Le **core.img**, | ||
+ | * Etape 2 : Contenu dans le répertoire **/ | ||
+ | |||
+ | Dans le cas où le Charger de Démarrage **GRUB 2** n'est pas installé, il convient de saisir la commande suivante : | ||
+ | |||
+ | # grub2-install / | ||
+ | |||
+ | où **périphérique** est le nom du périphérique ou l' | ||
+ | |||
+ | **GRUB 2** lit ses entrées de menus à partir du fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cat / | ||
+ | # | ||
+ | # DO NOT EDIT THIS FILE | ||
+ | # | ||
+ | # It is automatically generated by grub2-mkconfig using templates | ||
+ | # from /etc/grub.d and settings from / | ||
+ | # | ||
+ | |||
+ | ### BEGIN / | ||
+ | set pager=1 | ||
+ | |||
+ | if [ -f ${config_directory}/ | ||
+ | load_env -f ${config_directory}/ | ||
+ | elif [ -s $prefix/ | ||
+ | load_env | ||
+ | fi | ||
+ | if [ " | ||
+ | set default=" | ||
+ | set next_entry= | ||
+ | | ||
+ | set boot_once=true | ||
+ | else | ||
+ | set default=" | ||
+ | fi | ||
+ | |||
+ | if [ x" | ||
+ | menuentry_id_option=" | ||
+ | else | ||
+ | menuentry_id_option="" | ||
+ | fi | ||
+ | |||
+ | export menuentry_id_option | ||
+ | |||
+ | if [ " | ||
+ | set saved_entry=" | ||
+ | save_env saved_entry | ||
+ | set prev_saved_entry= | ||
+ | save_env prev_saved_entry | ||
+ | set boot_once=true | ||
+ | fi | ||
+ | |||
+ | function savedefault { | ||
+ | if [ -z " | ||
+ | saved_entry=" | ||
+ | save_env saved_entry | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | function load_video { | ||
+ | if [ x$feature_all_video_module = xy ]; then | ||
+ | insmod all_video | ||
+ | else | ||
+ | insmod efi_gop | ||
+ | insmod efi_uga | ||
+ | insmod ieee1275_fb | ||
+ | insmod vbe | ||
+ | insmod vga | ||
+ | insmod video_bochs | ||
+ | insmod video_cirrus | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | terminal_output console | ||
+ | if [ x$feature_timeout_style = xy ] ; then | ||
+ | set timeout_style=menu | ||
+ | set timeout=5 | ||
+ | # Fallback normal timeout code in case the timeout_style feature is | ||
+ | # unavailable. | ||
+ | else | ||
+ | set timeout=5 | ||
+ | fi | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | set tuned_params="" | ||
+ | set tuned_initrd="" | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | if [ -f ${prefix}/ | ||
+ | source ${prefix}/ | ||
+ | if [ -n " | ||
+ | set superusers=" | ||
+ | export superusers | ||
+ | password_pbkdf2 root ${GRUB2_PASSWORD} | ||
+ | fi | ||
+ | fi | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | insmod increment | ||
+ | # Check if boot_counter exists and boot_success=0 to activate this behaviour. | ||
+ | if [ -n " | ||
+ | # if countdown has ended, choose to boot rollback deployment, | ||
+ | # i.e. default=1 on OSTree-based systems. | ||
+ | if [ " | ||
+ | set default=1 | ||
+ | set boot_counter=-1 | ||
+ | # otherwise decrement boot_counter | ||
+ | else | ||
+ | decrement boot_counter | ||
+ | fi | ||
+ | save_env boot_counter | ||
+ | fi | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | 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 6f6c5bb9-30be-4734-bc23-03fed8541616 | ||
+ | fi | ||
+ | insmod part_msdos | ||
+ | insmod xfs | ||
+ | set boot=' | ||
+ | if [ x$feature_platform_search_hint = xy ]; then | ||
+ | search --no-floppy --fs-uuid --set=boot --hint-bios=hd0, | ||
+ | else | ||
+ | search --no-floppy --fs-uuid --set=boot 6f6c5bb9-30be-4734-bc23-03fed8541616 | ||
+ | fi | ||
+ | |||
+ | # This section was generated by a script. Do not modify the generated file - all changes | ||
+ | # will be lost the next time file is regenerated. Instead edit the BootLoaderSpec files. | ||
+ | # | ||
+ | # The blscfg command parses the BootLoaderSpec files stored in / | ||
+ | # populates the boot menu. Please refer to the Boot Loader Specification documentation | ||
+ | # for the files format: https:// | ||
+ | |||
+ | # The kernelopts variable should be defined in the grubenv file. But to ensure that menu | ||
+ | # entries populated from BootLoaderSpec files that use this variable work correctly even | ||
+ | # without a grubenv file, define a fallback kernelopts variable if this has not been set. | ||
+ | # | ||
+ | # The kernelopts variable in the grubenv file can be modified using the grubby tool or by | ||
+ | # executing the grub2-mkconfig tool. For the latter, the values of the GRUB_CMDLINE_LINUX | ||
+ | # and GRUB_CMDLINE_LINUX_DEFAULT options from / | ||
+ | # the kernelopts variable in the grubenv file and the fallback kernelopts variable. | ||
+ | if [ -z " | ||
+ | set kernelopts=" | ||
+ | fi | ||
+ | |||
+ | insmod blscfg | ||
+ | blscfg | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | # Hiding the menu is ok if last boot was ok or if this is a first boot attempt to boot the entry | ||
+ | if [ " | ||
+ | set menu_hide_ok=1 | ||
+ | else | ||
+ | set menu_hide_ok=0 | ||
+ | fi | ||
+ | # Reset boot_indeterminate after a successful boot | ||
+ | if [ " | ||
+ | set boot_indeterminate=0 | ||
+ | # Avoid boot_indeterminate causing the menu to be hidden more than once | ||
+ | elif [ " | ||
+ | set boot_indeterminate=2 | ||
+ | fi | ||
+ | # Reset boot_success for current boot | ||
+ | set boot_success=0 | ||
+ | save_env boot_success boot_indeterminate | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | if [ x$feature_timeout_style = xy ] ; then | ||
+ | if [ " | ||
+ | unset menu_show_once | ||
+ | save_env menu_show_once | ||
+ | set timeout_style=menu | ||
+ | set timeout=60 | ||
+ | elif [ " | ||
+ | set orig_timeout_style=${timeout_style} | ||
+ | set orig_timeout=${timeout} | ||
+ | if [ " | ||
+ | # timeout_style=menu + timeout=0 avoids the countdown code keypress check | ||
+ | set timeout_style=menu | ||
+ | set timeout=0 | ||
+ | else | ||
+ | set timeout_style=hidden | ||
+ | set timeout=1 | ||
+ | fi | ||
+ | fi | ||
+ | fi | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | if [ x$feature_timeout_style = xy ]; then | ||
+ | if [ " | ||
+ | set timeout_style=menu | ||
+ | set timeout=" | ||
+ | unset menu_show_once_timeout | ||
+ | save_env menu_show_once_timeout | ||
+ | fi | ||
+ | fi | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | if [ " | ||
+ | menuentry 'UEFI Firmware Settings' | ||
+ | fwsetup | ||
+ | } | ||
+ | fi | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | # 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 / | ||
+ | if [ -f ${config_directory}/ | ||
+ | source ${config_directory}/ | ||
+ | elif [ -z " | ||
+ | source $prefix/ | ||
+ | fi | ||
+ | ### END / | ||
+ | </ | ||
+ | |||
+ | Notez que ce fichier ne doit pas être modifié manuellement. En effet, il est généré par la commande **grub2-mkconfig**. La commande grub2-mkconfig prend en argument l' | ||
+ | |||
+ | * grub2-mkconfig -o / | ||
+ | * grub2-mkconfig -o / | ||
+ | |||
+ | Lors de l' | ||
+ | |||
+ | ===Le fichier / | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cat / | ||
+ | # this device map was generated by anaconda | ||
+ | (hd0) /dev/sda | ||
+ | </ | ||
+ | |||
+ | ===Le fichier / | ||
+ | |||
+ | Ce fichier contient la configuration par défaut des paramètres de GRUB 2 : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cat / | ||
+ | GRUB_TIMEOUT=5 | ||
+ | GRUB_DISTRIBUTOR=" | ||
+ | GRUB_DEFAULT=saved | ||
+ | GRUB_DISABLE_SUBMENU=true | ||
+ | GRUB_TERMINAL_OUTPUT=" | ||
+ | GRUB_CMDLINE_LINUX=" | ||
+ | GRUB_DISABLE_RECOVERY=" | ||
+ | GRUB_ENABLE_BLSCFG=true | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Notez que toute modification de ce fichier nécessite l' | ||
+ | </ | ||
+ | |||
+ | Dans ce fichier les directives sont : | ||
+ | |||
+ | ^ Directive | ||
+ | | GRUB_TIMEOUT | Durée de l' | ||
+ | | GRUB_DISTRIBUTOR | Ligne de commande qui génère le texte de l' | ||
+ | | GRUB_DEFAULT | Entrée du menu sélectionner par défaut | | ||
+ | | GRUB_DISABLE_SUBMENU | Active ou désactive les sous-menus de GRUB2 | | ||
+ | | GRUB_TERMINAL_OUTPUT | Spécifie le terminal par défaut | | ||
+ | | GRUB_CMDLINE_LINUX | Paramètres passés au noyau peu importe le type de démarrage | | ||
+ | | GRUB_DISABLE_RECOVERY | Active ou désactive la génération des entrées en mode **recovery** | | ||
+ | | GRUB_BLSCFG | Active ou désactive l' | ||
+ | |||
+ | ===Les fichiers du répertoire / | ||
+ | |||
+ | Les fichiers de ce répertoire sont exécutés dans l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# ls -l /etc/grub.d | ||
+ | total 108 | ||
+ | -rwxr-xr-x. 1 root root 9346 Jun 27 12:12 00_header | ||
+ | -rwxr-xr-x. 1 root root 1046 Feb 22 2024 00_tuned | ||
+ | -rwxr-xr-x. 1 root root 236 Jun 27 12:12 01_users | ||
+ | -rwxr-xr-x. 1 root root 835 Jun 27 12:12 08_fallback_counting | ||
+ | -rwxr-xr-x. 1 root root 19665 Jun 27 12:12 10_linux | ||
+ | -rwxr-xr-x. 1 root root 833 Jun 27 12:12 10_reset_boot_success | ||
+ | -rwxr-xr-x. 1 root root 892 Jun 27 12:12 12_menu_auto_hide | ||
+ | -rwxr-xr-x. 1 root root 410 Jun 27 12:12 14_menu_show_once | ||
+ | -rwxr-xr-x. 1 root root 13613 Jun 27 12:12 20_linux_xen | ||
+ | -rwxr-xr-x. 1 root root 2562 Jun 27 12:12 20_ppc_terminfo | ||
+ | -rwxr-xr-x. 1 root root 10869 Jun 27 12:12 30_os-prober | ||
+ | -rwxr-xr-x. 1 root root 1122 Jun 27 12:12 30_uefi-firmware | ||
+ | -rwxr-xr-x. 1 root root 725 Feb 19 2024 35_fwupd | ||
+ | -rwxr-xr-x. 1 root root 218 Jun 27 12:12 40_custom | ||
+ | -rwxr-xr-x. 1 root root 219 Jun 27 12:12 41_custom | ||
+ | -rw-r--r--. 1 root root 483 Jun 27 12:12 README | ||
+ | </ | ||
+ | |||
+ | * **Le fichier / | ||
+ | * Le fichier **10_Linux** contient des boucles pour rechercher des noyaux Linux, | ||
+ | * **Le fichier / | ||
+ | * Ce fichier recherche des éventuels systèmes d' | ||
+ | * **Les fichiers / | ||
+ | * Ces deux fichiers sont fournis en tant que modèles à personnaliser. | ||
+ | |||
+ | ===Le Fichier / | ||
+ | |||
+ | Le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cat / | ||
+ | # GRUB Environment Block | ||
+ | # WARNING: Do not edit this file by tools other than grub-editenv!!! | ||
+ | saved_entry=5a35a3eb625c45cea1d33535723e791f-5.14.0-427.37.1.el9_4.x86_64 | ||
+ | menu_auto_hide=1 | ||
+ | boot_success=1 | ||
+ | boot_indeterminate=0 | ||
+ | ################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################### | ||
+ | </ | ||
+ | |||
+ | ===Modifier la Configuration de GRUB 2 en Ligne de Commande=== | ||
+ | |||
+ | Lors du démarrage de GRUB 2, trois actions sont possibles à partir du menu : | ||
+ | |||
+ | * Lancer un système d' | ||
+ | * Lancer l' | ||
+ | * Lancer l’interface de la ligne de commande GRUB en appuyant sur la touche **c**. | ||
+ | |||
+ | En mode édition notez l' | ||
+ | |||
+ | * **flèches** : se déplacer dans l' | ||
+ | * **Crtl-X** : démarrer avec la configuration modifiée, | ||
+ | * **echap** : abandonner les modifications et retourner à l' | ||
+ | |||
+ | ====Chargeurs de Démarrages Alternatifs==== | ||
+ | |||
+ | ===Systemd-boot=== | ||
+ | |||
+ | Un Chargeur de Démarrage étroitement lié à Systemd ( voir plus bas ), celui-ci connaît actuellement un gain de popularité. | ||
+ | |||
+ | ===U-boot=== | ||
+ | |||
+ | Un Chargeur de Démarrage qui peut booter n' | ||
+ | |||
+ | ===Le Projet Syslinux=== | ||
+ | |||
+ | ==SYSLINUX== | ||
+ | |||
+ | Un Chargeur de Démarrage pour les systèmes qui utilisent le système de fichier FAT. Par exemple le systèmes sur clefs USB. | ||
+ | |||
+ | ==EXTLINUX== | ||
+ | |||
+ | Un Chargeur de Démarrage de petite taille qui sait booter des systèmes de fichier, EXT2, EXT3, EXT4 et BRTFS. | ||
+ | |||
+ | ==ISOLINUX== | ||
+ | |||
+ | Un Chargeur de Démarrage pour booter des LiveCD et LiveDVD. Dans le cas d' | ||
+ | |||
+ | * **isolinux.bin** qui contient l' | ||
+ | * **isolinux.cfg** qui contient les paramètres de configuration. | ||
+ | |||
+ | ==PXELINUX== | ||
+ | |||
+ | Un Chargeur de Démarrage pour booter à partir d'un serveur réseau. Ce système utilise le standard **PXE** (//Pre-boot Execution Environment// | ||
+ | |||
+ | * **DHCP** pour attribuer une adresse IP à la machine et | ||
+ | * **BOOTP** pour charger l' | ||
+ | |||
+ | ===Isodhpfx=== | ||
+ | |||
+ | Un Chargeur de Démarrage hybride, appelé **isodhpfx.bin**, | ||
+ | |||
+ | ====Initramfs==== | ||
+ | |||
+ | Le fichier Initramfs //%%INITial Ram File System%%// est une archive au format cpio : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cp / | ||
+ | |||
+ | [root@redhat9 ~]# cd /tmp | ||
+ | |||
+ | [root@redhat9 tmp]# ls custom | ||
+ | custom | ||
+ | </ | ||
+ | |||
+ | ===Examiner l' | ||
+ | |||
+ | Pour examiner une image initramfs archivée, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# lsinitrd custom | more | ||
+ | Image: custom: 54M | ||
+ | ======================================================================== | ||
+ | Early CPIO image | ||
+ | ======================================================================== | ||
+ | drwxr-xr-x | ||
+ | -rw-r--r-- | ||
+ | drwxr-xr-x | ||
+ | drwxr-xr-x | ||
+ | drwxr-xr-x | ||
+ | -rw-r--r-- | ||
+ | ======================================================================== | ||
+ | Version: dracut-057-53.git20240104.el9 | ||
+ | |||
+ | Arguments: | ||
+ | |||
+ | dracut modules: | ||
+ | bash | ||
+ | systemd | ||
+ | systemd-initrd | ||
+ | systemd-sysusers | ||
+ | nss-softokn | ||
+ | dbus-broker | ||
+ | dbus | ||
+ | i18n | ||
+ | network-manager | ||
+ | network | ||
+ | ifcfg | ||
+ | drm | ||
+ | plymouth | ||
+ | prefixdevname | ||
+ | dm | ||
+ | kernel-modules | ||
+ | kernel-modules-extra | ||
+ | kernel-network-modules | ||
+ | lvm | ||
+ | qemu | ||
+ | qemu-net | ||
+ | resume | ||
+ | rootfs-block | ||
+ | terminfo | ||
+ | udev-rules | ||
+ | virtiofs | ||
+ | dracut-systemd | ||
+ | usrmount | ||
+ | base | ||
+ | fs-lib | ||
+ | microcode_ctl-fw_dir_override | ||
+ | shutdown | ||
+ | ======================================================================== | ||
+ | drwxr-xr-x | ||
+ | crw-r--r-- | ||
+ | crw-r--r-- | ||
+ | crw-r--r-- | ||
+ | crw-r--r-- | ||
+ | crw-r--r-- | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | ===Le script init=== | ||
+ | |||
+ | Red Hat 9 utilise le système de démarrage **systemd**. Pour cette raison le script init est un lien symbolique vers **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# lsinitrd custom | grep usr/ | ||
+ | lrwxrwxrwx | ||
+ | </ | ||
+ | |||
+ | ===Consulter le contenu d'un fichier dans initramfs=== | ||
+ | |||
+ | Pour consulter le contenu d'un fichier inclus dans l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# lsinitrd / | ||
+ | include ld.so.conf.d/ | ||
+ | </ | ||
+ | |||
+ | ====Processus de Démarrage du Noyau Linux==== | ||
+ | |||
+ | Le processus de démarrage du Noyau Linux peut être divisé en 6 étapes : | ||
+ | |||
+ | ^ Etape ^ Description ^ | ||
+ | | Chargement, configuration et exécution du chargeur du noyau | Le fichier **bootsect.s** est chargé en mémoire par le BIOS. Une fois configuré celui-ci charge le reste du noyau en mémoire | | ||
+ | | Configuration des paramètres et bascule vers le mode 32 bits | Le fichier **boot.s** met en place un **[[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 | | ||
+ | |||
+ | La fonction **init_post()** essaie ensuite d' | ||
+ | |||
+ | * /sbin/init ==> / | ||
+ | * /etc/init | ||
+ | * /bin/init | ||
+ | * /bin/sh ==> /bin/bash ==> / | ||
+ | |||
+ | Dans le cas d'un échec à ce stade le message **Kernel Panic** sera affiché. | ||
+ | |||
+ | =====Systemd===== | ||
+ | |||
+ | Les systèmes de démarrage antérieurs à Systemd, **SysVinit** et **Upstart**, | ||
+ | |||
+ | **Systemd** essaie, par contre, de démarrer autant de services en parallèle que possible. Ceci est rendu possible car la majorité d' | ||
+ | |||
+ | Au lieu de parler de scripts de démarrage et de niveaux d' | ||
+ | |||
+ | * **.automount** - active la fonctionalité d' | ||
+ | * **.device** - expose une périphérique dans systemd. | ||
+ | * **.mount** - contrôle quand et comment les systèmes de fichiers sont montés. | ||
+ | * **.path** - active un service quand il y a un accès à un fichier ou répertoire sous surveillance par le système. | ||
+ | * **.service** - démarre, arrête, redémarre ou recharge un service. | ||
+ | * **.scope** - gère des services. | ||
+ | * **.slice** - regroupe des Unités dans une arborescence afin de limiter des ressources en utilisant des CGroups. | ||
+ | * **.snapshot** - un état sauvegardé du gestionnaire Systemd. | ||
+ | * **.socket** - permet aux Unités d' | ||
+ | * **.swap** - encapsule une périphérique ou un fichier swap. | ||
+ | * **.timer** - déclenche l' | ||
+ | * **.target** - regroupe des Unités multiples afin qu' | ||
+ | |||
+ | Une Cible est en quelque sorte une **grande étape** dans le démarrage du système : | ||
+ | |||
+ | * **halt.target** - arrête le système. | ||
+ | * **poweroff.target** - arrête le système et coupe le courant. | ||
+ | * **shutdown.target** - arrête le système. | ||
+ | * **rescue.target** - démarre le système en mode single-user (seul root peut s'y connecter). Tous les systèmes de fichiers sont montés mais le réseau n'est pas démarré. | ||
+ | * **emergency.target** - démarre le système en mode single-user (seul root peut s'y connecter). Uniquement le système de fichiers racine est monté en mode lecture seule. Le réseau n'est pas démarré. | ||
+ | * **multi-user.target** - démarre le système en mode multi-utilisateur avec tous les systèmes de fichiers montés et le service network démarré. | ||
+ | * **graphical.target** - démarre le système en multi-user.target puis démarre l' | ||
+ | * **hibernate.target** - sauvegarde l' | ||
+ | * **reboot.target** - redémarre le système. | ||
+ | |||
+ | **Systemd** utilise des Cibles d'une manière similaire à ce que **SysVinit** utilise des niveaux d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 15 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 13 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 17 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 17 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 17 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 16 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 13 Jul 18 13:00 / | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | </ | ||
+ | |||
+ | ====LAB #1 - La Commande systemctl==== | ||
+ | |||
+ | Pour visualiser la liste des Unités, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# 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-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | 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-devices-virtual-block-dm\x2d0.device | ||
+ | sys-devices-virtual-block-dm\x2d1.device | ||
+ | sys-devices-virtual-block-dm\x2d2.device | ||
+ | sys-devices-virtual-block-dm\x2d3.device | ||
+ | sys-devices-virtual-block-md1.device | ||
+ | sys-devices-virtual-misc-rfkill.device | ||
+ | sys-module-configfs.device | ||
+ | sys-module-fuse.device | ||
+ | sys-subsystem-net-devices-ens18.device | ||
+ | -.mount | ||
+ | boot.mount | ||
+ | dev-hugepages.mount | ||
+ | dev-mqueue.mount | ||
+ | run-credentials-systemd\x2dsysctl.service.mount | ||
+ | run-credentials-systemd\x2dtmpfiles\x2dsetup.service.mount | ||
+ | run-credentials-systemd\x2dtmpfiles\x2dsetup\x2ddev.service.mount | ||
+ | run-user-1000.mount | ||
+ | run-user-42.mount | ||
+ | sys-fs-fuse-connections.mount | ||
+ | sys-kernel-config.mount | ||
+ | sys-kernel-debug.mount | ||
+ | sys-kernel-tracing.mount | ||
+ | cups.path | ||
+ | systemd-ask-password-wall.path | ||
+ | init.scope | ||
+ | session-4.scope | ||
+ | session-c1.scope | ||
+ | accounts-daemon.service | ||
+ | atd.service | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | Pour consulter la liste des Unités inactifs, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemctl list-units --all | grep inactive | more | ||
+ | ● boot.automount | ||
+ | dev-mapper-sdb12.device | ||
+ | ● home.mount | ||
+ | mnt-sdb12.mount | ||
+ | proc-sys-fs-binfmt_misc.mount | ||
+ | ● sysroot.mount | ||
+ | tmp.mount | ||
+ | ● var.mount | ||
+ | systemd-ask-password-console.path | ||
+ | systemd-ask-password-plymouth.path | ||
+ | alsa-restore.service | ||
+ | alsa-state.service | ||
+ | ● auto-cpufreq.service | ||
+ | ● autofs.service | ||
+ | blk-availability.service | ||
+ | cpupower.service | ||
+ | dm-event.service | ||
+ | dnf-makecache.service | ||
+ | dracut-cmdline.service | ||
+ | dracut-initqueue.service | ||
+ | dracut-mount.service | ||
+ | dracut-pre-mount.service | ||
+ | dracut-pre-pivot.service | ||
+ | dracut-pre-trigger.service | ||
+ | dracut-pre-udev.service | ||
+ | dracut-shutdown-onfailure.service | ||
+ | ● ebtables.service | ||
+ | emergency.service | ||
+ | ● fcoe.service | ||
+ | getty@tty1.service | ||
+ | ● httpd-init.service | ||
+ | initrd-cleanup.service | ||
+ | initrd-parse-etc.service | ||
+ | initrd-switch-root.service | ||
+ | initrd-udevadm-cleanup-db.service | ||
+ | insights-client-boot.service | ||
+ | ● ip6tables.service | ||
+ | ● ipset.service | ||
+ | ● iptables.service | ||
+ | iscsi-init.service | ||
+ | iscsi-onboot.service | ||
+ | iscsi-shutdown.service | ||
+ | iscsi-starter.service | ||
+ | iscsid.service | ||
+ | iscsiuio.service | ||
+ | ldconfig.service | ||
+ | logrotate.service | ||
+ | low-memory-monitor.service | ||
+ | ● lvm2-activation-early.service | ||
+ | lvm2-lvmpolld.service | ||
+ | mdadm-last-resort@md1.service | ||
+ | microcode.service | ||
+ | mlocate-updatedb.service | ||
+ | modprobe@configfs.service | ||
+ | modprobe@drm.service | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | Les points noirs au début de certaines lignes dans la sortie ci-dessus sont en réalité des points blancs à l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemctl status ip6tables | ||
+ | Unit ip6tables.service could not be found. | ||
+ | </ | ||
+ | |||
+ | Pour consulter la liste des Unités ainsi que leurs statuts, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemctl list-unit-files | more | ||
+ | UNIT FILE STATE | ||
+ | proc-sys-fs-binfmt_misc.automount | ||
+ | -.mount | ||
+ | boot.mount | ||
+ | dev-hugepages.mount | ||
+ | dev-mqueue.mount | ||
+ | mnt-sdb12.mount | ||
+ | proc-sys-fs-binfmt_misc.mount | ||
+ | run-vmblock\x2dfuse.mount | ||
+ | sys-fs-fuse-connections.mount | ||
+ | sys-kernel-config.mount | ||
+ | sys-kernel-debug.mount | ||
+ | sys-kernel-tracing.mount | ||
+ | tmp.mount | ||
+ | cups.path | ||
+ | insights-client-results.path | ||
+ | ostree-finalize-staged.path | ||
+ | systemd-ask-password-console.path | ||
+ | systemd-ask-password-plymouth.path | ||
+ | systemd-ask-password-wall.path | ||
+ | session-4.scope | ||
+ | session-c1.scope | ||
+ | accounts-daemon.service | ||
+ | alsa-restore.service | ||
+ | alsa-state.service | ||
+ | arp-ethers.service | ||
+ | atd.service | ||
+ | auditd.service | ||
+ | autovt@.service | ||
+ | avahi-daemon.service | ||
+ | bar.service | ||
+ | blk-availability.service | ||
+ | bluetooth.service | ||
+ | bolt.service | ||
+ | brltty.service | ||
+ | canberra-system-bootup.service | ||
+ | canberra-system-shutdown-reboot.service | ||
+ | canberra-system-shutdown.service | ||
+ | chrony-wait.service | ||
+ | chronyd-restricted.service | ||
+ | chronyd.service | ||
+ | cni-dhcp.service | ||
+ | cockpit-motd.service | ||
+ | cockpit-wsinstance-http.service | ||
+ | cockpit-wsinstance-https-factory@.service | ||
+ | cockpit-wsinstance-https@.service | ||
+ | cockpit.service | ||
+ | colord.service | ||
+ | configure-printer@.service | ||
+ | console-getty.service | ||
+ | container-getty@.service | ||
+ | cpupower.service | ||
+ | crond.service | ||
+ | cups-browsed.service | ||
+ | cups.service | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | Pour visualiser les Unités d'un type spécifique, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemctl list-unit-files -t mount | ||
+ | UNIT FILE | ||
+ | -.mount | ||
+ | boot.mount | ||
+ | dev-hugepages.mount | ||
+ | dev-mqueue.mount | ||
+ | mnt-sdb12.mount | ||
+ | proc-sys-fs-binfmt_misc.mount disabled | ||
+ | run-vmblock\x2dfuse.mount | ||
+ | sys-fs-fuse-connections.mount static | ||
+ | sys-kernel-config.mount | ||
+ | sys-kernel-debug.mount | ||
+ | sys-kernel-tracing.mount | ||
+ | tmp.mount | ||
+ | |||
+ | 12 unit files listed. | ||
+ | </ | ||
+ | |||
+ | Dans la colonne STATE on voit les mots **static** et **generated**. | ||
+ | |||
+ | * STATE = static | ||
+ | * Ceci implique que l' | ||
+ | |||
+ | * STATE = generated | ||
+ | * Ceci implique que le fichier a été généré automatiquement en utilisant les informations dans le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# ls -l / | ||
+ | -rwxr-xr-x. 1 root root 57696 Jul 18 13:01 / | ||
+ | </ | ||
+ | |||
+ | Il existe aussi d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# ls -l / | ||
+ | total 396 | ||
+ | -rwxr-xr-x. 1 root root 541 Jul 24 06:08 kdump-dep-generator.sh | ||
+ | -rwxr-xr-x. 1 root root 15832 May 17 18:27 ostree-system-generator | ||
+ | lrwxrwxrwx. 1 root root 31 Aug 8 10:54 podman-system-generator -> ../ | ||
+ | -rwxr-xr-x. 1 root root 1005 Feb 19 2024 selinux-autorelabel-generator.sh | ||
+ | -rwxr-xr-x. 1 root root 15624 Jul 18 13:01 systemd-bless-boot-generator | ||
+ | -rwxr-xr-x. 1 root root 40920 Jul 18 13:01 systemd-cryptsetup-generator | ||
+ | -rwxr-xr-x. 1 root root 24312 Jul 18 13:01 systemd-debug-generator | ||
+ | -rwxr-xr-x. 1 root root 57696 Jul 18 13:01 systemd-fstab-generator | ||
+ | -rwxr-xr-x. 1 root root 24096 Jul 18 13:01 systemd-getty-generator | ||
+ | -rwxr-xr-x. 1 root root 36496 Jul 18 13:01 systemd-gpt-auto-generator | ||
+ | -rwxr-xr-x. 1 root root 16096 Jul 18 13:01 systemd-hibernate-resume-generator | ||
+ | -rwxr-xr-x. 1 root root 24240 Jul 18 13:01 systemd-integritysetup-generator | ||
+ | -rwxr-xr-x. 1 root root 15632 Jul 18 13:01 systemd-rc-local-generator | ||
+ | -rwxr-xr-x. 1 root root 24296 Jul 18 13:01 systemd-run-generator | ||
+ | -rwxr-xr-x. 1 root root 15824 Jul 18 13:01 systemd-system-update-generator | ||
+ | -rwxr-xr-x. 1 root root 36424 Jul 18 13:01 systemd-sysv-generator | ||
+ | -rwxr-xr-x. 1 root root 36872 Jul 18 13:01 systemd-veritysetup-generator | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **systemctl** sont : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemctl --help | ||
+ | systemctl [OPTIONS...] COMMAND ... | ||
+ | |||
+ | Query or send control commands to the system manager. | ||
+ | |||
+ | Unit Commands: | ||
+ | list-units [PATTERN...] | ||
+ | list-automounts [PATTERN...] | ||
+ | ordered by path | ||
+ | list-sockets [PATTERN...] | ||
+ | ordered by address | ||
+ | list-timers [PATTERN...] | ||
+ | ordered by next elapse | ||
+ | is-active PATTERN... | ||
+ | is-failed PATTERN... | ||
+ | status [PATTERN...|PID...] | ||
+ | show [PATTERN...|JOB...] | ||
+ | units/jobs or the manager | ||
+ | cat PATTERN... | ||
+ | help PATTERN...|PID... | ||
+ | list-dependencies [UNIT...] | ||
+ | or wanted by the units or by which those | ||
+ | units are required or wanted | ||
+ | start UNIT... | ||
+ | stop UNIT... | ||
+ | reload UNIT... | ||
+ | restart UNIT... | ||
+ | try-restart UNIT... | ||
+ | reload-or-restart UNIT... | ||
+ | otherwise start or restart | ||
+ | try-reload-or-restart UNIT... | ||
+ | if supported, otherwise restart | ||
+ | isolate UNIT Start one unit and stop all others | ||
+ | kill UNIT... | ||
+ | clean UNIT... | ||
+ | configuration of unit | ||
+ | freeze PATTERN... | ||
+ | thaw PATTERN... | ||
+ | set-property UNIT PROPERTY=VALUE... Sets one or more properties of a unit | ||
+ | bind UNIT PATH [PATH] | ||
+ | unit's namespace | ||
+ | mount-image UNIT PATH [PATH [OPTS]] Mount an image from the host into a | ||
+ | unit's namespace | ||
+ | service-log-level SERVICE [LEVEL] | ||
+ | service-log-target SERVICE [TARGET] Get/set logging target for service | ||
+ | reset-failed [PATTERN...] | ||
+ | units | ||
+ | Unit File Commands: | ||
+ | list-unit-files [PATTERN...] | ||
+ | enable [UNIT...|PATH...] | ||
+ | disable UNIT... | ||
+ | reenable UNIT... | ||
+ | preset UNIT... | ||
+ | based on preset configuration | ||
+ | preset-all | ||
+ | preset configuration | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | ====LAB #2 - Fichiers de Configuration==== | ||
+ | |||
+ | ===2.1 - Fichiers de Configuration par Défaut=== | ||
+ | |||
+ | Les fichiers de configuration des Cibles et fichiers de configuration des Unités installés par des paquets se trouvent dans le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# pkg-config systemd --variable=systemdsystemunitdir | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# ls -l / | ||
+ | total 1640 | ||
+ | -rw-r--r--. 1 root root 729 Feb 24 2022 accounts-daemon.service | ||
+ | -rw-r--r--. 1 root root 480 Jan 16 2024 alsa-restore.service | ||
+ | -rw-r--r--. 1 root root 465 Jan 16 2024 alsa-state.service | ||
+ | -rw-r--r--. 1 root root 275 Aug 10 2021 arp-ethers.service | ||
+ | -rw-r--r--. 1 root root 274 Apr 4 2022 atd.service | ||
+ | -rw-r--r--. 1 root root 1771 Nov 8 2023 auditd.service | ||
+ | lrwxrwxrwx. 1 root root 14 Jul 18 13:00 autovt@.service -> getty@.service | ||
+ | -rw-r--r--. 1 root root 1044 Nov 8 2023 avahi-daemon.service | ||
+ | -rw-r--r--. 1 root root 870 Nov 8 2023 avahi-daemon.socket | ||
+ | -rw-r--r--. 1 root root 224 Oct 23 14:00 bar.service | ||
+ | -rw-r--r--. 1 root root 964 Jul 18 13:00 basic.target | ||
+ | drwxr-xr-x. 2 root root 6 Jul 18 13:00 basic.target.wants | ||
+ | -r--r--r--. 1 root root 384 Feb 3 2024 blk-availability.service | ||
+ | -rw-r--r--. 1 root root 449 Oct 31 2022 blockdev@.target | ||
+ | -rw-r--r--. 1 root root 707 Jun 14 2022 bluetooth.service | ||
+ | -rw-r--r--. 1 root root 435 Oct 31 2022 bluetooth.target | ||
+ | -rw-r--r--. 1 root root 642 Jan 16 2023 bolt.service | ||
+ | -rw-r--r--. 1 root root 463 Oct 31 2022 boot-complete.target | ||
+ | -rw-r--r--. 1 root root 217 Aug 9 2021 brltty.service | ||
+ | -rw-r--r--. 1 root root 491 Jul 13 2023 canberra-system-bootup.service | ||
+ | -rw-r--r--. 1 root root 509 Jul 13 2023 canberra-system-shutdown-reboot.service | ||
+ | -rw-r--r--. 1 root root 466 Jul 13 2023 canberra-system-shutdown.service | ||
+ | -rw-r--r--. 1 root root 1811 Jan 23 2024 chronyd-restricted.service | ||
+ | -rw-r--r--. 1 root root 1468 Jan 23 2024 chronyd.service | ||
+ | -rw-r--r--. 1 root root 1082 Jan 23 2024 chrony-wait.service | ||
+ | -rw-r--r--. 1 root root 277 Jul 23 09:37 cni-dhcp.service | ||
+ | -rw-r--r--. 1 root root 302 Dec 4 2023 cni-dhcp.socket | ||
+ | -rw-r--r--. 1 root root 222 Apr 2 2024 cockpit-motd.service | ||
+ | -rw-r--r--. 1 root root 720 Apr 2 2024 cockpit.service | ||
+ | -rw-r--r--. 1 root root 349 Apr 2 2024 cockpit.socket | ||
+ | -rw-r--r--. 1 root root 221 Apr 2 2024 cockpit-wsinstance-http.service | ||
+ | -rw-r--r--. 1 root root 165 Apr 2 2024 cockpit-wsinstance-https-factory@.service | ||
+ | -rw-r--r--. 1 root root 244 Apr 2 2024 cockpit-wsinstance-https-factory.socket | ||
+ | -rw-r--r--. 1 root root 215 Apr 2 2024 cockpit-wsinstance-http.socket | ||
+ | -rw-r--r--. 1 root root 264 Apr 2 2024 cockpit-wsinstance-https@.service | ||
+ | -rw-r--r--. 1 root root 478 Apr 2 2024 cockpit-wsinstance-https@.socket | ||
+ | -rw-r--r--. 1 root root 295 Aug 9 2021 colord.service | ||
+ | -rw-r--r--. 1 root root 154 Aug 11 2021 configure-printer@.service | ||
+ | -rw-r--r--. 1 root root 1102 Jul 18 13:00 console-getty.service | ||
+ | -rw-r--r--. 1 root root 1254 Jul 18 13:00 container-getty@.service | ||
+ | -rw-r--r--. 1 root root 294 Sep 13 18:49 cpupower.service | ||
+ | -rw-r--r--. 1 root root 371 Nov 30 2023 crond.service | ||
+ | -rw-r--r--. 1 root root 473 Oct 31 2022 cryptsetup-pre.target | ||
+ | -rw-r--r--. 1 root root 420 Oct 31 2022 cryptsetup.target | ||
+ | lrwxrwxrwx. 1 root root 13 Jul 18 13:00 ctrl-alt-del.target -> reboot.target | ||
+ | -rw-r--r--. 1 root root 234 Jan 7 2021 cups-browsed.service | ||
+ | -rw-r--r--. 1 root root 142 Jun 19 11:00 cups.path | ||
+ | -rw-r--r--. 1 root root 298 Jun 19 11:00 cups.service | ||
+ | drwxr-xr-x. 2 root root 25 Sep 25 12:03 cups.service.d | ||
+ | -rw-r--r--. 1 root root 148 Jun 19 11:00 cups.socket | ||
+ | -rw-r--r--. 1 root root 529 Aug 23 2022 dbus-broker.service | ||
+ | -rw-r--r--. 1 root root 560 Jun 12 2023 dbus-daemon.service | ||
+ | lrwxrwxrwx. 1 root root 25 Jul 18 13:00 dbus-org.freedesktop.hostname1.service -> systemd-hostnamed.service | ||
+ | lrwxrwxrwx. 1 root root 23 Jul 18 13:00 dbus-org.freedesktop.locale1.service -> systemd-localed.service | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | Certains fichiers de configuration sont créés à la volée dans le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# ls -l / | ||
+ | total 0 | ||
+ | </ | ||
+ | |||
+ | Les fichiers de configuration des Unités crées par les utilisateurs doivent être mis dans le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# pkg-config systemd --variable=systemduserunitdir | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : De cette façon les fichiers dans **/ | ||
+ | </ | ||
+ | |||
+ | Prenons le cas du service **sshd** qui est configuré par le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# cat / | ||
+ | [Unit] | ||
+ | Description=OpenSSH server daemon | ||
+ | Documentation=man: | ||
+ | After=network.target sshd-keygen.target | ||
+ | Wants=sshd-keygen.target | ||
+ | |||
+ | [Service] | ||
+ | Type=notify | ||
+ | EnvironmentFile=-/ | ||
+ | ExecStart=/ | ||
+ | ExecReload=/ | ||
+ | KillMode=process | ||
+ | Restart=on-failure | ||
+ | RestartSec=42s | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
+ | |||
+ | Dans le fichier on peut noter la présence des lignes suivantes dans la section **[Unit]** : | ||
+ | |||
+ | * **Description=OpenSSH server daemon**, | ||
+ | * Cette directive est utilisée pour donner une courte description des fonctionnalités de l' | ||
+ | * **Documentation=man: | ||
+ | * Cette directive stipule les chapitres des manuels et les URLs contenant de l' | ||
+ | * **After=network.target sshd-keygen.target**, | ||
+ | * Cette directive indique les cibles qui devraient être atteintes et les Unités qui devraient être démarrées avant l' | ||
+ | * **Wants=sshd-keygen.target**, | ||
+ | * Cette directive stipule une dépendance douce. Autrement dit, Systemd essayera de démarrer l' | ||
+ | |||
+ | Dans le fichier on peut aussi noter la présence des lignes suivantes dans la section **[Service]** : | ||
+ | |||
+ | * **Type=notify**, | ||
+ | * Cette directive indique que le service informera Systemd quand son démarrage a terminé, | ||
+ | * **ExecStart=/ | ||
+ | * Cette directive définit l' | ||
+ | * **ExecReload=/ | ||
+ | * Cette directive indique la commande necéssaire pour redémarrer le service, | ||
+ | * **KillMode=process**, | ||
+ | * Cette directive indique comment les processus du service doivent être arrêtés. La valeur de **process** implique l' | ||
+ | * **Restart=on-failure**, | ||
+ | * Cette ligne indique que le service doit être re-démarré en cas d' | ||
+ | * **RestartSec=42s**, | ||
+ | * Cette directive stipule le temps d' | ||
+ | |||
+ | Dernièrement on note la présence de la ligne suivante dans la section **[Install]** : | ||
+ | |||
+ | * **WantedBy=multi-user.target**, | ||
+ | * Cette directive indique la Cible dans laquelle le service doit être démarré. La présence de cette directive crée un lien symbolique dans le répertoire **/ | ||
+ | |||
+ | Pour consulter **l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemctl show sshd | ||
+ | Type=notify | ||
+ | ExitType=main | ||
+ | Restart=on-failure | ||
+ | NotifyAccess=main | ||
+ | RestartUSec=42s | ||
+ | TimeoutStartUSec=1min 30s | ||
+ | TimeoutStopUSec=1min 30s | ||
+ | TimeoutAbortUSec=1min 30s | ||
+ | TimeoutStartFailureMode=terminate | ||
+ | TimeoutStopFailureMode=terminate | ||
+ | RuntimeMaxUSec=infinity | ||
+ | RuntimeRandomizedExtraUSec=0 | ||
+ | WatchdogUSec=0 | ||
+ | WatchdogTimestampMonotonic=0 | ||
+ | RootDirectoryStartOnly=no | ||
+ | RemainAfterExit=no | ||
+ | GuessMainPID=yes | ||
+ | MainPID=1175 | ||
+ | ControlPID=0 | ||
+ | FileDescriptorStoreMax=0 | ||
+ | NFileDescriptorStore=0 | ||
+ | StatusErrno=0 | ||
+ | Result=success | ||
+ | ReloadResult=success | ||
+ | CleanResult=success | ||
+ | UID=[not set] | ||
+ | GID=[not set] | ||
+ | NRestarts=0 | ||
+ | OOMPolicy=stop | ||
+ | ReloadSignal=1 | ||
+ | ExecMainStartTimestamp=Thu 2024-10-24 09:29:16 CEST | ||
+ | ExecMainStartTimestampMonotonic=38779836 | ||
+ | ExecMainExitTimestampMonotonic=0 | ||
+ | ExecMainPID=1175 | ||
+ | ExecMainCode=0 | ||
+ | ExecMainStatus=0 | ||
+ | ExecStart={ path=/ | ||
+ | ExecStartEx={ path=/ | ||
+ | ExecReload={ path=/ | ||
+ | ExecReloadEx={ path=/ | ||
+ | Slice=system.slice | ||
+ | ControlGroup=/ | ||
+ | ControlGroupId=4041 | ||
+ | MemoryCurrent=5337088 | ||
+ | MemoryAvailable=infinity | ||
+ | CPUUsageNSec=63348000 | ||
+ | TasksCurrent=1 | ||
+ | IPIngressBytes=[no data] | ||
+ | IPIngressPackets=[no data] | ||
+ | IPEgressBytes=[no data] | ||
+ | IPEgressPackets=[no data] | ||
+ | IOReadBytes=18446744073709551615 | ||
+ | IOReadOperations=18446744073709551615 | ||
+ | IOWriteBytes=18446744073709551615 | ||
+ | IOWriteOperations=18446744073709551615 | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | Pour consulter la liste des dépendances d'une Unité, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemctl list-dependencies sshd.service | ||
+ | sshd.service | ||
+ | ● ├─system.slice | ||
+ | ● ├─sshd-keygen.target | ||
+ | ○ │ ├─sshd-keygen@ecdsa.service | ||
+ | ○ │ ├─sshd-keygen@ed25519.service | ||
+ | ○ │ └─sshd-keygen@rsa.service | ||
+ | ● └─sysinit.target | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ○ | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ○ | ||
+ | ○ | ||
+ | ● | ||
+ | ○ | ||
+ | ○ | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ○ | ||
+ | ○ | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ● │ └─systemd-cryptsetup@sdb12.service | ||
+ | ● | ||
+ | ● | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | ===2.2 - Surchargement des Fichiers de Configuration par Défaut=== | ||
+ | |||
+ | Les fichiers de configuration par défaut peuvent aussi être surchargés par des fichiers dans d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# pkg-config systemd --variable=systemdsystemunitpath | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# ls -l / | ||
+ | total 8 | ||
+ | drwxr-xr-x. 2 root root 65 Oct 19 2023 basic.target.wants | ||
+ | drwxr-xr-x. 2 root root 31 Oct 19 2023 bluetooth.target.wants | ||
+ | lrwxrwxrwx. 1 root root 37 Oct 19 2023 ctrl-alt-del.target -> / | ||
+ | lrwxrwxrwx. 1 root root 41 Oct 19 2023 dbus-org.bluez.service -> / | ||
+ | lrwxrwxrwx. 1 root root 41 Oct 19 2023 dbus-org.fedoraproject.FirewallD1.service -> / | ||
+ | lrwxrwxrwx. 1 root root 44 Oct 19 2023 dbus-org.freedesktop.Avahi.service -> / | ||
+ | lrwxrwxrwx. 1 root root 44 Oct 19 2023 dbus-org.freedesktop.ModemManager1.service -> / | ||
+ | lrwxrwxrwx. 1 root root 57 Oct 19 2023 dbus-org.freedesktop.nm-dispatcher.service -> / | ||
+ | lrwxrwxrwx. 1 root root 43 Oct 19 2023 dbus.service -> / | ||
+ | lrwxrwxrwx. 1 root root 40 Oct 19 2023 default.target -> / | ||
+ | drwxr-xr-x. 2 root root 45 Oct 19 2023 default.target.wants | ||
+ | drwxr-xr-x. 2 root root 38 Oct 19 2023 ' | ||
+ | lrwxrwxrwx. 1 root root 35 Oct 19 2023 display-manager.service -> / | ||
+ | drwxr-xr-x. 2 root root 32 Oct 19 2023 getty.target.wants | ||
+ | drwxr-xr-x. 2 root root 181 Oct 19 2023 graphical.target.wants | ||
+ | drwxr-xr-x. 2 root root 36 Oct 19 2023 local-fs.target.wants | ||
+ | drwxr-xr-x. 2 root root 4096 Oct 24 08:02 multi-user.target.wants | ||
+ | drwxr-xr-x. 2 root root 48 Oct 19 2023 network-online.target.wants | ||
+ | drwxr-xr-x. 2 root root 26 Oct 19 2023 printer.target.wants | ||
+ | drwxr-xr-x. 2 root root 27 Oct 19 2023 remote-fs.target.wants | ||
+ | drwxr-xr-x. 2 root root 186 Oct 19 2023 sockets.target.wants | ||
+ | drwxr-xr-x. 2 root root 4096 Sep 25 12:08 sysinit.target.wants | ||
+ | drwxr-xr-x. 2 root root 27 Oct 23 13:09 sysstat-collect.timer.d | ||
+ | drwxr-xr-x. 2 root root 64 Oct 23 12:58 sysstat.service.wants | ||
+ | drwxr-xr-x. 2 root root 27 Oct 21 16:32 systemd-tmpfiles-clean.timer.d | ||
+ | drwxr-xr-x. 2 root root 86 Oct 19 2023 timers.target.wants | ||
+ | drwxr-xr-x. 2 root root 29 Oct 19 2023 vmtoolsd.service.requires | ||
+ | </ | ||
+ | |||
+ | ====LAB #3 - La Commande systemd-analyze==== | ||
+ | |||
+ | Pour avoir une évaluation du temps de démarrage, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemd-analyze | ||
+ | Startup finished in 1.361s (kernel) + 4.348s (initrd) + 1min 21.082s (userspace) = 1min 26.792s | ||
+ | graphical.target reached after 53.162s in userspace. | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemd-analyze blame | ||
+ | 44.601s kdump.service | ||
+ | 18.590s systemd-cryptsetup@sdb12.service | ||
+ | 16.592s plymouth-quit-wait.service | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemd-analyze critical-chain sshd.service | ||
+ | The time when unit became active or started is printed after the " | ||
+ | The time the unit took to start is printed after the " | ||
+ | |||
+ | sshd.service +348ms | ||
+ | └─network.target @33.014s | ||
+ | └─wpa_supplicant.service @49.199s +119ms | ||
+ | └─basic.target @27.729s | ||
+ | └─dbus-broker.service @26.718s +1.007s | ||
+ | └─dbus.socket @26.682s | ||
+ | └─sysinit.target @26.678s | ||
+ | └─systemd-update-utmp.service @26.658s +19ms | ||
+ | └─auditd.service @26.278s +369ms | ||
+ | └─systemd-tmpfiles-setup.service @25.954s +313ms | ||
+ | └─local-fs.target @25.942s | ||
+ | └─run-user-1000.mount @1min 19.309s | ||
+ | └─local-fs-pre.target @6.742s | ||
+ | └─systemd-tmpfiles-setup-dev.service @3.994s +1.040s | ||
+ | └─kmod-static-nodes.service @3.795s +53ms | ||
+ | └─systemd-journald.socket | ||
+ | └─system.slice | ||
+ | └─-.slice | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **systemd-analyze** sont : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemd-analyze --help | ||
+ | systemd-analyze [OPTIONS...] COMMAND ... | ||
+ | |||
+ | Profile systemd, show unit dependencies, | ||
+ | |||
+ | Commands: | ||
+ | [time] | ||
+ | blame Print list of running units ordered by | ||
+ | time to init | ||
+ | critical-chain [UNIT...] | ||
+ | of units | ||
+ | plot | ||
+ | | ||
+ | dot [UNIT...] | ||
+ | dump [PATTERN...] | ||
+ | | ||
+ | cat-config | ||
+ | unit-files | ||
+ | unit-paths | ||
+ | exit-status [STATUS...] | ||
+ | capability [CAP...] | ||
+ | syscall-filter [NAME...] | ||
+ | filesystems [NAME...] | ||
+ | condition CONDITION... | ||
+ | compare-versions VERSION1 [OP] VERSION2 | ||
+ | | ||
+ | verify FILE... | ||
+ | calendar SPEC... | ||
+ | | ||
+ | timestamp TIMESTAMP... | ||
+ | timespan SPAN... | ||
+ | security [UNIT...] | ||
+ | inspect-elf FILE... | ||
+ | |||
+ | Options: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | of built-in one | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | with either --table or --json= | ||
+ | | ||
+ | | ||
+ | | ||
+ | -H --host=[USER@]HOST | ||
+ | -M --machine=CONTAINER | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | ====LAB #4 - Les Cibles Systemd==== | ||
+ | |||
+ | Chaque Cible est décrite par un fichier de configuration : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# cat / | ||
+ | # SPDX-License-Identifier: | ||
+ | # | ||
+ | # This file is part of systemd. | ||
+ | # | ||
+ | # systemd is free software; you can redistribute it and/or modify it | ||
+ | # under the terms of the GNU Lesser General Public License as published by | ||
+ | # the Free Software Foundation; either version 2.1 of the License, or | ||
+ | # (at your option) any later version. | ||
+ | |||
+ | [Unit] | ||
+ | Description=Graphical Interface | ||
+ | Documentation=man: | ||
+ | Requires=multi-user.target | ||
+ | Wants=display-manager.service | ||
+ | Conflicts=rescue.service rescue.target | ||
+ | After=multi-user.target rescue.service rescue.target display-manager.service | ||
+ | AllowIsolate=yes | ||
+ | </ | ||
+ | |||
+ | Dans ce fichier on peut noter la présence des lignes suivantes : | ||
+ | |||
+ | * **Requires=multi-user.target**, | ||
+ | * Cette ligne indique que le **graphical.target** ne peut pas être atteint si le **multi-user.target** n'a pas été atteint au préalable, | ||
+ | * **After=multi-user.target rescue.service rescue.target display-manager.service**, | ||
+ | * Cette ligne indique le **multi-user.target** et **rescue.target** doivent d' | ||
+ | * **Conflicts=rescue.service rescue.target**, | ||
+ | * Cette ligne indique la Cible et le service en conflits avec le **graphical.target**, | ||
+ | * **Wants=display-manager.service**, | ||
+ | * Cette ligne indique quel service doit être démarré. | ||
+ | |||
+ | ===4.1 - Contrôler les dépendances d'une Cible=== | ||
+ | |||
+ | Les dépendances d'une Cible peuvent être consultées en utilisant la commande **systemctl list-dependencies** : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemctl list-dependencies multi-user.target | ||
+ | multi-user.target | ||
+ | ● ├─atd.service | ||
+ | ● ├─auditd.service | ||
+ | ● ├─avahi-daemon.service | ||
+ | ● ├─bar.service | ||
+ | ● ├─crond.service | ||
+ | ● ├─cups.path | ||
+ | ● ├─cups.service | ||
+ | ● ├─firewalld.service | ||
+ | ● ├─foo.service | ||
+ | ● ├─httpd.service | ||
+ | ○ ├─insights-client-boot.service | ||
+ | ● ├─irqbalance.service | ||
+ | ● ├─kdump.service | ||
+ | ● ├─libstoragemgmt.service | ||
+ | ● ├─mcelog.service | ||
+ | ● ├─mdmonitor.service | ||
+ | ● ├─ModemManager.service | ||
+ | ● ├─NetworkManager.service | ||
+ | ○ ├─ostree-readonly-sysroot-migration.service | ||
+ | ● ├─plymouth-quit-wait.service | ||
+ | ○ ├─plymouth-quit.service | ||
+ | ● ├─psacct.service | ||
+ | ● ├─rhsmcertd.service | ||
+ | ● ├─rsyslog.service | ||
+ | ○ ├─smartd.service | ||
+ | ● ├─sshd.service | ||
+ | ○ ├─sssd.service | ||
+ | ● ├─sysstat.service | ||
+ | ● ├─systemd-ask-password-wall.path | ||
+ | ● ├─systemd-logind.service | ||
+ | ○ ├─systemd-update-utmp-runlevel.service | ||
+ | ● ├─systemd-user-sessions.service | ||
+ | ○ ├─vmtoolsd.service | ||
+ | ● ├─basic.target | ||
+ | ● │ ├─-.mount | ||
+ | ○ │ ├─low-memory-monitor.service | ||
+ | ○ │ ├─microcode.service | ||
+ | ● │ ├─paths.target | ||
+ | ● │ ├─slices.target | ||
+ | ● │ │ ├─-.slice | ||
+ | ● │ │ └─system.slice | ||
+ | ● │ ├─sockets.target | ||
+ | ● │ │ ├─avahi-daemon.socket | ||
+ | ● │ │ ├─cups.socket | ||
+ | ● │ │ ├─dbus.socket | ||
+ | ● │ │ ├─dm-event.socket | ||
+ | ● │ │ ├─iscsid.socket | ||
+ | ● │ │ ├─iscsiuio.socket | ||
+ | ○ │ │ ├─multipathd.socket | ||
+ | ● │ │ ├─sssd-kcm.socket | ||
+ | ● │ │ ├─systemd-coredump.socket | ||
+ | ● │ │ ├─systemd-initctl.socket | ||
+ | ● │ │ ├─systemd-journald-dev-log.socket | ||
+ | ● │ │ ├─systemd-journald.socket | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | Les points noirs au début de chaque ligne dans la sortie ci-dessus peuvent être de trois couleurs différentes : | ||
+ | |||
+ | * **Vert** implique que le service, la cible ou l' | ||
+ | * **Blanc** implique le service, la cible ou l' | ||
+ | * **Rouge** implique que le service, la cible ou l' | ||
+ | |||
+ | Pour visualiser les Unités en état d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemctl --failed | ||
+ | UNIT LOAD ACTIVE SUB DESCRIPTION | ||
+ | 0 loaded units listed. | ||
+ | </ | ||
+ | |||
+ | Les dépendances sont créés sous la forme de liens symboliques dans les répertoires **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# ls -l / | ||
+ | total 0 | ||
+ | lrwxrwxrwx. 1 root root 35 Oct 19 2023 atd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 38 Oct 19 2023 auditd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 44 Oct 19 2023 avahi-daemon.service -> / | ||
+ | lrwxrwxrwx. 1 root root 35 Oct 23 14:01 bar.service -> / | ||
+ | lrwxrwxrwx. 1 root root 37 Oct 19 2023 crond.service -> / | ||
+ | lrwxrwxrwx. 1 root root 33 Oct 19 2023 cups.path -> / | ||
+ | lrwxrwxrwx. 1 root root 36 Oct 19 2023 cups.service -> / | ||
+ | lrwxrwxrwx. 1 root root 41 Oct 19 2023 firewalld.service -> / | ||
+ | lrwxrwxrwx. 1 root root 35 Oct 23 13:59 foo.service -> / | ||
+ | lrwxrwxrwx. 1 root root 37 Oct 22 10:15 httpd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 52 Oct 19 2023 insights-client-boot.service -> / | ||
+ | lrwxrwxrwx. 1 root root 42 Oct 19 2023 irqbalance.service -> / | ||
+ | lrwxrwxrwx. 1 root root 37 Oct 19 2023 kdump.service -> / | ||
+ | lrwxrwxrwx. 1 root root 46 Oct 19 2023 libstoragemgmt.service -> / | ||
+ | lrwxrwxrwx. 1 root root 38 Oct 19 2023 mcelog.service -> / | ||
+ | lrwxrwxrwx. 1 root root 41 Oct 19 2023 mdmonitor.service -> / | ||
+ | lrwxrwxrwx. 1 root root 44 Oct 19 2023 ModemManager.service -> / | ||
+ | lrwxrwxrwx. 1 root root 46 Oct 19 2023 NetworkManager.service -> / | ||
+ | lrwxrwxrwx. 1 root root 38 Oct 22 15:41 psacct.service -> / | ||
+ | lrwxrwxrwx. 1 root root 40 Oct 19 2023 remote-fs.target -> / | ||
+ | lrwxrwxrwx. 1 root root 41 Oct 19 2023 rhsmcertd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 39 Oct 19 2023 rsyslog.service -> / | ||
+ | lrwxrwxrwx. 1 root root 38 Oct 19 2023 smartd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 36 Oct 19 2023 sshd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 36 Oct 19 2023 sssd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 39 Oct 23 12:58 sysstat.service -> / | ||
+ | lrwxrwxrwx. 1 root root 40 Oct 19 2023 vmtoolsd.service -> / | ||
+ | |||
+ | [root@redhat9 tmp]# ls -l / | ||
+ | total 0 | ||
+ | lrwxrwxrwx. 1 root root 15 Jul 18 13:00 getty.target -> ../ | ||
+ | lrwxrwxrwx. 1 root root 44 May 17 18:27 ostree-readonly-sysroot-migration.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 24 Jul 14 2023 plymouth-quit.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 29 Jul 14 2023 plymouth-quit-wait.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 33 Jul 18 13:00 systemd-ask-password-wall.path -> ../ | ||
+ | lrwxrwxrwx. 1 root root 25 Jul 18 13:00 systemd-logind.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 39 Jul 18 13:00 systemd-update-utmp-runlevel.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 32 Jul 18 13:00 systemd-user-sessions.service -> ../ | ||
+ | </ | ||
+ | |||
+ | ===4.2 - La Cible par Défaut=== | ||
+ | |||
+ | ==Consulter la Cible par Défaut== | ||
+ | |||
+ | Pour consulter la cible par défaut, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemctl get-default | ||
+ | graphical.target | ||
+ | </ | ||
+ | |||
+ | La Cible par défaut est représentée par le lien symbolique **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 40 Oct 19 2023 / | ||
+ | </ | ||
+ | |||
+ | ==Modifier la Cible par Défaut== | ||
+ | |||
+ | Pour modifier la Cible par défaut avec une prise en compte lors du **prochain** démarrage, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemctl get-default | ||
+ | graphical.target | ||
+ | |||
+ | [root@redhat9 tmp]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 40 Oct 19 2023 / | ||
+ | |||
+ | [root@redhat9 tmp]# systemctl set-default multi-user.target | ||
+ | Removed "/ | ||
+ | Created symlink / | ||
+ | |||
+ | [root@redhat9 tmp]# systemctl get-default | ||
+ | multi-user.target | ||
+ | |||
+ | [root@redhat9 tmp]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 41 Oct 24 11:47 / | ||
+ | |||
+ | [root@redhat9 tmp]# systemctl set-default graphical.target | ||
+ | Removed "/ | ||
+ | Created symlink / | ||
+ | |||
+ | [root@redhat9 tmp]# systemctl get-default | ||
+ | graphical.target | ||
+ | |||
+ | [root@redhat9 tmp]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 40 Oct 24 11:47 / | ||
+ | </ | ||
+ | |||
+ | ==Modifier la Cible en Cours== | ||
+ | |||
+ | Il est possible de modifier la cible actuellement en cours en utilisant la commande **systemctl isolate** : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemctl isolate rescue | ||
+ | |||
+ | [root@redhat9 tmp]# systemctl list-units --type target | egrep " | ||
+ | rescue.target | ||
+ | |||
+ | [root@redhat9 tmp]# runlevel | ||
+ | 5 1 | ||
+ | |||
+ | [root@redhat9 tmp]# who -r | ||
+ | | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# systemctl isolate graphical | ||
+ | |||
+ | [root@redhat9 tmp]# systemctl list-units --type target | egrep " | ||
+ | graphical.target | ||
+ | |||
+ | [root@redhat9 tmp]# runlevel | ||
+ | 1 5 | ||
+ | |||
+ | [root@redhat9 tmp]# who -r | ||
+ | | ||
+ | </ | ||
+ | |||
+ | =====Arrêt du Système===== | ||
+ | |||
+ | Sous Red Hat 9 les commandes **halt**, **poweroff**, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 16 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 16 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 16 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 16 Jul 18 13:00 / | ||
+ | </ | ||
+ | |||
+ | La manière recommendée d' | ||
+ | |||
+ | * systemctl halt | ||
+ | * systemctl poweroff | ||
+ | * systemctl reboot | ||
+ | * systemctl shutdown | ||
+ | |||
+ | Il est cependant toujours possibles d' | ||
+ | |||
+ | ====La Commande shutdown==== | ||
+ | |||
+ | Lors de l' | ||
+ | |||
+ | * Il previent les utilisateurs, | ||
+ | * Il arrête tous les services, | ||
+ | * Il inscrit toutes les données sur disque, | ||
+ | * Il démonte les systèmes de fichiers. | ||
+ | |||
+ | La commande utilisée pour arrêter le système est la commande **shutdown** : | ||
+ | |||
+ | shutdown [-t sec] [-HPrhkc] heure [message] | ||
+ | |||
+ | ===Options de la commande=== | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# shutdown --help | ||
+ | shutdown [OPTIONS...] [TIME] [WALL...] | ||
+ | |||
+ | Shut down the system. | ||
+ | |||
+ | Options: | ||
+ | | ||
+ | -H --halt | ||
+ | -P --poweroff | ||
+ | -r --reboot | ||
+ | -h | ||
+ | -k | ||
+ | | ||
+ | -c | ||
+ | | ||
+ | |||
+ | See the shutdown(8) man page for details. | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | ^ Valeur ^ Description ^ | ||
+ | | hh:mm | L' | ||
+ | | +m | Nombre de minutes avant que l' | ||
+ | | now | L' | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Si l' | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# date && shutdown -t 60 -k | ||
+ | Thu Oct 24 11:53:34 AM CEST 2024 | ||
+ | Shutdown scheduled for Thu 2024-10-24 11:54:34 CEST, use ' | ||
+ | </ | ||
+ | |||
+ | ==== La Commande reboot==== | ||
+ | |||
+ | Cette commande redémarre le système. | ||
+ | |||
+ | ===Options de la commande=== | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# reboot --help | ||
+ | reboot [OPTIONS...] [ARG] | ||
+ | |||
+ | Reboot the system. | ||
+ | |||
+ | Options: | ||
+ | | ||
+ | | ||
+ | -p --poweroff | ||
+ | | ||
+ | -f --force | ||
+ | -w --wtmp-only Don't halt/ | ||
+ | -d --no-wtmp | ||
+ | | ||
+ | |||
+ | See the halt(8) man page for details. | ||
+ | </ | ||
+ | |||
+ | ==== La Commande halt==== | ||
+ | |||
+ | Cette commande arrête le système. | ||
+ | |||
+ | ===Options de la commande=== | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# halt --help | ||
+ | halt [OPTIONS...] | ||
+ | |||
+ | Halt the system. | ||
+ | |||
+ | Options: | ||
+ | | ||
+ | | ||
+ | -p --poweroff | ||
+ | | ||
+ | -f --force | ||
+ | -w --wtmp-only Don't halt/ | ||
+ | -d --no-wtmp | ||
+ | | ||
+ | |||
+ | See the halt(8) man page for details. | ||
+ | </ | ||
+ | |||
+ | ==== La Commande poweroff==== | ||
+ | |||
+ | Cette commande arrête le système et coupe l' | ||
+ | |||
+ | ===Options de la commande=== | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# poweroff --help | ||
+ | poweroff [OPTIONS...] | ||
+ | |||
+ | Power off the system. | ||
+ | |||
+ | Options: | ||
+ | | ||
+ | | ||
+ | -p --poweroff | ||
+ | | ||
+ | -f --force | ||
+ | -w --wtmp-only Don't halt/ | ||
+ | -d --no-wtmp | ||
+ | | ||
+ | |||
+ | See the halt(8) man page for details. | ||
+ | </ | ||
+ | |||
+ | ----- | ||
+ | Copyright © 2024 Hugh Norris. |