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:lpic:21:450:l103 [2022/10/10 04:37] – admin | elearning:workbooks:lpic:21:450:l103 [2022/11/01 07:24] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 5: | Ligne 5: | ||
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======Topic | + | ======Topic |
- | =====Contenu du Module===== | + | |
- | + | ||
- | | + | |
- | * Contenu du Module | + | |
* Présentation | * Présentation | ||
* BIOS, EFI et OpenFirmware | * BIOS, EFI et OpenFirmware | ||
Ligne 27: | Ligne 24: | ||
* Configurer l' | * Configurer l' | ||
* Modifier la Configuration de GRUB Legacy en Ligne de Commande | * Modifier la Configuration de GRUB Legacy en Ligne de Commande | ||
- | * GRUB 2 sous RHEL/CentOS 7 | + | * GRUB 2 sous Debian 11 |
- | * Le fichier /boot/grub/device.map | + | * Le fichier /boot/grub2/device.map |
* Le fichier / | * Le fichier / | ||
* Les fichiers du répertoire /etc/grub.d | * Les fichiers du répertoire /etc/grub.d | ||
- | * Configurer l' | ||
- | * RHEL/CentOS < 7.2 | ||
- | * RHEL/CentOS >= 7.2 | ||
* Modifier la Configuration de GRUB 2 en Ligne de Commande | * Modifier la Configuration de GRUB 2 en Ligne de Commande | ||
* Chargeurs de Démarrages Alternatifs | * Chargeurs de Démarrages Alternatifs | ||
Ligne 48: | Ligne 42: | ||
* Le script init | * Le script init | ||
* La Commande dracut | * La Commande dracut | ||
- | * Initramfs sous RHEL/CentOS 7 | + | * Initramfs sous Debian 11 |
- | * Examiner l' | + | * LAB #1 - Travailler avec Initramfs |
- | * Le script init | + | * 1.1 - Examiner l' |
- | * Consulter le contenu d'un fichier dans initramfs | + | * 1.2 - La Commande |
- | | + | |
* Processus de Démarrage du Noyau Linux | * Processus de Démarrage du Noyau Linux | ||
* Processus Init | * Processus Init | ||
Ligne 93: | Ligne 86: | ||
* La Commande stop | * La Commande stop | ||
* La Commande restart | * La Commande restart | ||
- | * Démarrer | + | * Démarrer |
- | * La Commande systemctl | + | * LAB #2 - La Commande systemctl |
- | * Fichiers de Configuration | + | * LAB #3 - Fichiers de Configuration |
- | * La Commande systemd-analyze | + | * 3.1 - Fichiers de Configuration par Défaut |
- | * Gestion des Services | + | * 3.2 - Surchargement des Fichiers par Défaut |
- | * Arrêt Système du Système | + | * 3.3 - Les Fichiers d' |
- | * La Commande shutdown | + | * LAB #4 - La Commande systemd-analyze |
- | * La Commande reboot | + | * LAB #5 - Les Cibles |
- | * La Commande halt | + | * 5.1 - Contrôler les dépendances d'une Cible |
- | * La Commande poweroff | + | * 5.2 - La Cible par Défaut |
+ | * LAB #6 - Gestion des Services | ||
+ | * 6.1 - Gestion des Instances Uniques | ||
+ | * 6.2 - Gestion d' | ||
+ | * 6.3 - Interdire la Modification du Statut d'un Service | ||
=====Présentation===== | =====Présentation===== | ||
Ligne 149: | Ligne 146: | ||
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
**Important** : L'UEFI gère parfaitement les **SSD** (//Solid State Drives//) qui utilisent le standard **NVMe** (// | **Important** : L'UEFI gère parfaitement les **SSD** (//Solid State Drives//) qui utilisent le standard **NVMe** (// | ||
</ | </ | ||
Ligne 204: | Ligne 201: | ||
Si le BIOS signale une erreur lorsque LILO essaye de charger une image d' | Si le BIOS signale une erreur lorsque LILO essaye de charger une image d' | ||
- | <WRAP center round important> | + | <WRAP center round important |
**Important** : LILO ne gère pas les systèmes UEFI. | **Important** : LILO ne gère pas les systèmes UEFI. | ||
</ | </ | ||
Ligne 271: | Ligne 268: | ||
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
**Important** : Sous les distributions dérivées de Red Hat, par exemple Fedora, le fichier menu.lst s' | **Important** : Sous les distributions dérivées de Red Hat, par exemple Fedora, le fichier menu.lst s' | ||
</ | </ | ||
Ligne 355: | Ligne 352: | ||
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
**Important** : Notez l' | **Important** : Notez l' | ||
</ | </ | ||
Ligne 375: | Ligne 372: | ||
* **echap** : abandonner les modifications et retourner à l' | * **echap** : abandonner les modifications et retourner à l' | ||
- | ====GRUB 2 sous CentOS 8==== | + | ====GRUB 2 sous Debian 11==== |
GRUB 2 est une ré-écriture complète de GRUB Legacy. Il apporte des améliorations, | GRUB 2 est une ré-écriture complète de GRUB Legacy. Il apporte des améliorations, | ||
Ligne 383: | Ligne 380: | ||
* Etape 1 : Le **boot.img**, | * Etape 1 : Le **boot.img**, | ||
* Etape 1.5 : Le **core.img**, | * Etape 1.5 : Le **core.img**, | ||
- | * Etape 2 : Contenu dans le répertoire **/boot/grub2/**, il lance le menu pour que l' | + | * Etape 2 : Contenu dans le répertoire **/boot/grub/**, il lance le menu pour que l' |
Dans le cas où le Charger de Démarrage **GRUB 2** n'est pas installé, il convient de saisir la commande suivante : | Dans le cas où le Charger de Démarrage **GRUB 2** n'est pas installé, il convient de saisir la commande suivante : | ||
- | # grub2-install / | + | # grub-install / |
où **périphérique** est le nom du périphérique ou l' | où **périphérique** est le nom du périphérique ou l' | ||
- | **GRUB 2** lit ses entrées de menus à partir du fichier **/boot/grub2/ | + | **GRUB 2** lit ses entrées de menus à partir du fichier **/boot/grub/ |
< | < | ||
- | [root@centos8 | + | root@debian11:~# cat /boot/grub/grub.cfg |
# | # | ||
# DO NOT EDIT THIS FILE | # DO NOT EDIT THIS FILE | ||
# | # | ||
- | # It is automatically generated by grub2-mkconfig using templates | + | # It is automatically generated by grub-mkconfig using templates |
# from /etc/grub.d and settings from / | # from /etc/grub.d and settings from / | ||
# | # | ||
### BEGIN / | ### BEGIN / | ||
- | set pager=1 | + | if [ -s $prefix/grubenv ]; then |
- | + | | |
- | if [ -f ${config_directory}/grubenv ]; then | + | |
- | | + | |
- | elif [ -s $prefix/ | + | |
load_env | load_env | ||
fi | fi | ||
Ligne 416: | Ligne 410: | ||
set boot_once=true | set boot_once=true | ||
else | else | ||
- | set default=" | + | set default=" |
fi | fi | ||
Ligne 441: | Ligne 435: | ||
fi | fi | ||
} | } | ||
- | |||
function load_video { | function load_video { | ||
if [ x$feature_all_video_module = xy ]; then | if [ x$feature_all_video_module = xy ]; then | ||
Ligne 456: | Ligne 449: | ||
} | } | ||
- | terminal_output console | + | if [ x$feature_default_font_path |
- | if [ x$feature_timeout_style | + | font=unicode |
- | set timeout_style=menu | + | |
- | set timeout=5 | + | |
- | # Fallback normal timeout code in case the timeout_style feature is | + | |
- | # unavailable. | + | |
else | else | ||
- | set timeout=5 | + | insmod part_msdos |
- | fi | + | insmod ext2 |
- | ### END / | + | set root=' |
- | + | if [ x$feature_platform_search_hint | |
- | ### BEGIN / | + | |
- | set tuned_params="" | + | |
- | set tuned_initrd="" | + | |
- | ### END / | + | |
- | + | ||
- | ### BEGIN / | + | |
- | if [ "${boot_success}" | + | |
- | set last_boot_ok=1 | + | |
else | else | ||
- | set last_boot_ok=0 | + | |
+ | fi | ||
+ | font="/ | ||
fi | fi | ||
- | # Reset boot_indeterminate after a successful boot | + | if loadfont |
- | if [ "${boot_success}" | + | set gfxmode=auto |
- | set boot_indeterminate=0 | + | |
- | # Avoid boot_indeterminate causing the menu to be hidden more then once | + | |
- | elif [ " | + | set locale_dir=$prefix/ |
- | set boot_indeterminate=2 | + | set lang=en_US |
+ | insmod gettext | ||
fi | fi | ||
- | set boot_success=0 | + | terminal_output gfxterm |
- | save_env boot_success boot_indeterminate | + | if [ "${recordfail}" |
- | + | set timeout=30 | |
- | if [ x$feature_timeout_style | + | else |
- | if [ "${menu_show_once}" | + | if [ x$feature_timeout_style = xy ] ; then |
- | unset menu_show_once | + | |
- | save_env menu_show_once | + | |
set timeout_style=menu | set timeout_style=menu | ||
- | set timeout=60 | + | set timeout=5 |
- | | + | # Fallback normal |
- | set orig_timeout_style=${timeout_style} | + | # unavailable. |
- | set orig_timeout=${timeout} | + | else |
- | if [ " | + | set timeout=5 |
- | | + | |
- | set timeout_style=menu | + | |
- | set timeout=0 | + | |
- | else | + | |
- | set timeout_style=hidden | + | |
- | | + | |
- | fi | + | |
fi | fi | ||
fi | fi | ||
- | ### END / | + | ### END / |
- | ### BEGIN / | + | ### BEGIN / |
- | if [ -f ${prefix}/ | + | |
- | source ${prefix}/ | + | |
- | if [ -n " | + | |
- | set superusers=" | + | |
- | export superusers | + | |
- | password_pbkdf2 root ${GRUB2_PASSWORD} | + | |
- | fi | + | |
- | fi | + | |
- | ### END / | + | |
- | + | ||
- | ### BEGIN / | + | |
insmod part_msdos | insmod part_msdos | ||
insmod ext2 | insmod ext2 | ||
set root=' | set root=' | ||
if [ x$feature_platform_search_hint = xy ]; then | if [ x$feature_platform_search_hint = xy ]; then | ||
- | search --no-floppy --fs-uuid --set=root --hint-bios=hd0, | + | search --no-floppy --fs-uuid --set=root --hint-bios=hd0, |
else | else | ||
- | search --no-floppy --fs-uuid --set=root | + | search --no-floppy --fs-uuid --set=root |
fi | fi | ||
- | insmod | + | insmod |
- | insmod ext2 | + | if background_image / |
- | set boot=' | + | set color_normal=white/ |
- | if [ x$feature_platform_search_hint = xy ]; then | + | set color_highlight=black/white |
- | | + | |
else | else | ||
- | | + | set menu_color_normal=cyan/blue |
+ | set menu_color_highlight=white/ | ||
fi | fi | ||
+ | ### END / | ||
- | # This section was generated by a script. Do not modify the generated file - all changes | + | ### BEGIN /etc/grub.d/10_linux ### |
- | # will be lost the next time file is regenerated. Instead edit the BootLoaderSpec files. | + | function gfxmode { |
- | # | + | set gfxpayload=" |
- | # The blscfg command parses the BootLoaderSpec files stored in /boot/loader/ | + | } |
- | # populates the boot menu. Please refer to the Boot Loader Specification documentation | + | set linux_gfx_mode= |
- | # for the files format: https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/. | + | export linux_gfx_mode |
- | + | menuentry ' | |
- | set default_kernelopts="root=UUID=4c0cc28c-0d59-45be-bd73-d292b80be33c ro crashkernel=auto resume=UUID=c8bb3f47-d67f-4b21-b781-766899dc83d4 rhgb quiet " | + | |
+ | insmod gzio | ||
+ | if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi | ||
+ | insmod part_msdos | ||
+ | insmod ext2 | ||
+ | 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 9887a74f-a680-4bde-8f04-db5ae9ea186e | ||
+ | fi | ||
+ | echo ' | ||
+ | | ||
+ | | ||
+ | initrd | ||
+ | } | ||
+ | submenu ' | ||
+ | menuentry ' | ||
+ | load_video | ||
+ | insmod gzio | ||
+ | if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi | ||
+ | insmod part_msdos | ||
+ | insmod ext2 | ||
+ | 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 9887a74f-a680-4bde-8f04-db5ae9ea186e | ||
+ | fi | ||
+ | echo ' | ||
+ | linux /boot/vmlinuz-5.10.0-13-amd64 root=UUID=9887a74f-a680-4bde-8f04-db5ae9ea186e ro quiet | ||
+ | echo ' | ||
+ | initrd | ||
+ | } | ||
+ | | ||
+ | load_video | ||
+ | insmod gzio | ||
+ | if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi | ||
+ | insmod part_msdos | ||
+ | insmod ext2 | ||
+ | set root=' | ||
+ | if [ x$feature_platform_search_hint = xy ]; then | ||
+ | search --no-floppy --fs-uuid --set=root | ||
+ | else | ||
+ | search --no-floppy --fs-uuid --set=root 9887a74f-a680-4bde-8f04-db5ae9ea186e | ||
+ | fi | ||
+ | echo ' | ||
+ | linux / | ||
+ | echo ' | ||
+ | initrd | ||
+ | } | ||
+ | } | ||
- | insmod blscfg | ||
- | blscfg | ||
### END / | ### END / | ||
### BEGIN / | ### BEGIN / | ||
- | ### END / | ||
- | ### BEGIN / | + | ### END / |
- | ### END / | + | |
### BEGIN / | ### BEGIN / | ||
Ligne 589: | Ligne 602: | ||
| rootnoverify (hd0,1) | 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**. La commande | + | Notez que ce fichier ne doit pas être modifié manuellement. En effet, il est généré par la commande **update-grub** ou la commande **grub-mkconfig** |
- | * grub2-mkconfig -o /boot/grub2/grub.cfg, ou | + | * grub-mkconfig -o /boot/grub/grub.cfg |
- | * grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg | + | * grub-mkconfig -o /boot/edi/EFI/debian/grub.cfg |
- | Lors de l' | + | Lors de l' |
===Le fichier / | ===Le fichier / | ||
< | < | ||
- | [root@centos8 | + | root@debian11:~# cat /boot/grub/ |
- | # this device map was generated by anaconda | + | cat: / |
- | (hd0) /dev/sda | + | root@debian11: |
- | (hd1) /dev/sda | + | root@debian11: |
+ | (hd0) | ||
+ | (hd1) | ||
+ | (hd2) / | ||
+ | (hd3) / | ||
+ | (hd4) / | ||
+ | (hd5) / | ||
</ | </ | ||
Ligne 610: | Ligne 629: | ||
< | < | ||
- | [root@centos8 | + | root@debian11:~# cat / |
+ | # If you change this file, run ' | ||
+ | # / | ||
+ | # For full documentation of the options in this file, see: | ||
+ | # info -f grub -n ' | ||
+ | |||
+ | GRUB_DEFAULT=0 | ||
GRUB_TIMEOUT=5 | GRUB_TIMEOUT=5 | ||
- | GRUB_DISTRIBUTOR=" | + | GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` |
- | GRUB_DEFAULT=saved | + | GRUB_CMDLINE_LINUX_DEFAULT="quiet" |
- | GRUB_DISABLE_SUBMENU=true | + | GRUB_CMDLINE_LINUX="" |
- | GRUB_TERMINAL_OUTPUT="console" | + | |
- | GRUB_CMDLINE_LINUX="crashkernel=auto resume=UUID=c8bb3f47-d67f-4b21-b781-766899dc83d4 rhgb quiet" | + | # Uncomment to enable BadRAM filtering, modify to suit your needs |
- | GRUB_DISABLE_RECOVERY=" | + | # This works with Linux (no patch required) and with any kernel that obtains |
- | GRUB_ENABLE_BLSCFG=true | + | # the memory map information from GRUB (GNU Mach, kernel of FreeBSD |
+ | # | ||
+ | |||
+ | # Uncomment to disable graphical terminal (grub-pc only) | ||
+ | # | ||
+ | |||
+ | # The resolution used on graphical terminal | ||
+ | # note that you can use only modes which your graphic card supports via VBE | ||
+ | # you can see them in real GRUB with the command `vbeinfo' | ||
+ | # | ||
+ | |||
+ | # Uncomment if you don't want GRUB to pass "root=UUID=xxx" | ||
+ | # | ||
+ | |||
+ | # Uncomment to disable generation of recovery mode menu entries | ||
+ | #GRUB_DISABLE_RECOVERY=" | ||
+ | |||
+ | # Uncomment to get a beep at grub start | ||
+ | # | ||
</ | </ | ||
- | <WRAP center round important 60%> | + | <WRAP center round important 60% > |
- | **Important** : Notez que toute modification de ce fichier nécessite l' | + | **Important** : Notez que toute modification de ce fichier nécessite l' |
</ | </ | ||
- | Dans ce fichier les directives sont : | + | Dans ce fichier les directives |
^ Directive | ^ Directive | ||
+ | | GRUB_DEFAULT | Entrée du menu sélectionner par défaut | | ||
| GRUB_TIMEOUT | Durée de l' | | GRUB_TIMEOUT | Durée de l' | ||
| GRUB_DISTRIBUTOR | Ligne de commande qui génère le texte de l' | | GRUB_DISTRIBUTOR | Ligne de commande qui génère le texte de l' | ||
- | | GRUB_DEFAULT | + | | GRUB_CMDLINE_LINUX_DEFAULT |
- | | GRUB_DISABLE_SUBMENU | Active ou désactive les sous-menus de GRUB2 | | + | |
- | | GRUB_TERMINAL_OUTPUT | Spécifie | + | |
| GRUB_CMDLINE_LINUX | Paramètres passés au noyau peu importe le type de démarrage | | | GRUB_CMDLINE_LINUX | Paramètres passés au noyau peu importe le type de démarrage | | ||
- | | GRUB_DISABLE_RECOVERY | + | | GRUB_BADRAM |
- | | GRUB_BLSCFG | + | | GRUB_TERMINAL | Si non commentée, cette directive |
+ | | 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 | ||
+ | | GRUB_INIT_TUNE | ||
===Les fichiers du répertoire / | ===Les fichiers du répertoire / | ||
Ligne 642: | Ligne 688: | ||
< | < | ||
- | [root@centos8 | + | root@debian11:~# ls -l / |
- | total 92 | + | total 80 |
- | -rwxr-xr-x. 1 root root | + | -rwxr-xr-x 1 root root 10046 Jul 11 2021 00_header |
- | -rwxr-xr-x. 1 root root | + | -rwxr-xr-x 1 root root |
- | -rwxr-xr-x. 1 root root 232 Mar 2 15:51 01_users | + | -rwxr-xr-x 1 root root 13664 Jul 11 2021 10_linux |
- | -rwxr-xr-x. 1 root root 832 Mar 2 15:51 08_fallback_counting | + | -rwxr-xr-x 1 root root 13726 Jul 11 2021 20_linux_xen |
- | -rwxr-xr-x. 1 root root 14088 Mar 2 15:51 10_linux | + | -rwxr-xr-x 1 root root 12059 Jul 11 2021 30_os-prober |
- | -rwxr-xr-x. 1 root root 830 Mar 2 15:51 10_reset_boot_success | + | -rwxr-xr-x 1 root root |
- | -rwxr-xr-x. 1 root root 889 Mar 2 15:51 12_menu_auto_hide | + | -rwxr-xr-x 1 root root |
- | -rwxr-xr-x. 1 root root 11696 Mar 2 15:51 20_linux_xen | + | -rwxr-xr-x 1 root root |
- | -rwxr-xr-x. 1 root root | + | -rw-r--r-- 1 root root |
- | -rwxr-xr-x. 1 root root 10670 Mar 2 15:51 30_os-prober | + | |
- | -rwxr-xr-x. 1 root root | + | |
- | -rwxr-xr-x. 1 root root | + | |
- | -rwxr-xr-x. 1 root root | + | |
- | -rw-r--r--. 1 root root | + | |
</ | </ | ||
Ligne 666: | Ligne 707: | ||
* **Les fichiers / | * **Les fichiers / | ||
* Ces deux fichiers sont fournis en tant que modèles à personnaliser. | * Ces deux fichiers sont fournis en tant que modèles à personnaliser. | ||
- | |||
- | ===Le Fichier / | ||
- | |||
- | Le fichier **/ | ||
- | |||
- | < | ||
- | [root@centos8 ~]# cat / | ||
- | # GRUB Environment Block | ||
- | saved_entry=de79af4f226d480fa7d3fec4cabbf97a-4.18.0-240.22.1.el8_3.x86_64 | ||
- | kernelopts=root=UUID=4c0cc28c-0d59-45be-bd73-d292b80be33c ro crashkernel=auto resume=UUID=c8bb3f47-d67f-4b21-b781-766899dc83d4 rhgb quiet | ||
- | boot_success=1 | ||
- | boot_indeterminate=0 | ||
- | ########################################################################################################################################## | ||
- | ########################################################################################################################################## | ||
- | ########################################################################################################################################## | ||
- | ########################################################################################################################################## | ||
- | ########################################################################################################################################## | ||
- | ############################################################ | ||
- | </ | ||
===Modifier la Configuration de GRUB 2 en Ligne de Commande=== | ===Modifier la Configuration de GRUB 2 en Ligne de Commande=== | ||
Ligne 699: | Ligne 721: | ||
* **Crtl-X** : démarrer avec la configuration modifiée, | * **Crtl-X** : démarrer avec la configuration modifiée, | ||
* **echap** : abandonner les modifications et retourner à l' | * **echap** : abandonner les modifications et retourner à l' | ||
+ | |||
+ | <WRAP center round important 60% > | ||
+ | **Important** : Certaines distributions, | ||
+ | </ | ||
====Chargeurs de Démarrages Alternatifs==== | ====Chargeurs de Démarrages Alternatifs==== | ||
Ligne 738: | Ligne 764: | ||
Un Chargeur de Démarrage hybride, appelé **isodhpfx.bin**, | Un Chargeur de Démarrage hybride, appelé **isodhpfx.bin**, | ||
- | ====Initramfs sous RHEL/CentOS 6==== | + | =====Initramfs sous RHEL/CentOS 6===== |
Un fichier Initramfs //%%INITial Ram File System%%// est une image d'un système minimal initialisée au démarrage du système. | Un fichier Initramfs //%%INITial Ram File System%%// est une image d'un système minimal initialisée au démarrage du système. | ||
Ligne 814: | Ligne 840: | ||
</ | </ | ||
- | <WRAP center round todo> | + | <WRAP center round todo 60%> |
**A faire** : Utilisez le manuel de la commande **cpio** pour comprendre les options utilisées. | **A faire** : Utilisez le manuel de la commande **cpio** pour comprendre les options utilisées. | ||
</ | </ | ||
Ligne 855: | Ligne 881: | ||
</ | </ | ||
- | <WRAP center round todo> | + | <WRAP center round todo 60%> |
**A faire** : Passez en revue le contenu du script. | **A faire** : Passez en revue le contenu du script. | ||
</ | </ | ||
Ligne 970: | Ligne 996: | ||
- | <WRAP center round todo> | + | <WRAP center round todo 60%> |
**A faire** : **Re-démarrez votre machine pour tester votre configuration.** | **A faire** : **Re-démarrez votre machine pour tester votre configuration.** | ||
</ | </ | ||
- | ====Initramfs sous CentOS 8==== | + | =====Initramfs sous Debian 11===== |
- | Le fichier Initramfs //%%INITial Ram File System%%// est une archive | + | Le fichier Initramfs //%%INITial Ram File System%%// est une image d'un système minimal initialisée |
+ | |||
+ | ====LAB #1 - Travailler avec Initramfs | ||
+ | |||
+ | ===1.1 - Examiner l' | ||
+ | |||
+ | Pour examiner une image initramfs, il convient d' | ||
< | < | ||
- | [root@centos8 | + | root@debian11:~# cp /boot/initrd.img-5.10.0-13-amd64 |
- | [root@centos8 | + | root@debian11:~# gunzip |
- | [root@centos8 tmp]# ls | + | </ |
- | cpio.list | + | |
- | custom | + | |
- | dateref | + | |
- | incremental.tar | + | |
- | mbr.save | + | |
- | systemd-private-9af7a2f7444849578f55b306bfd9f820-chronyd.service-iQiNzF | + | |
- | tblpart.save | + | |
- | test.cpio | + | |
- | test.print | + | |
- | test.tar | + | |
- | tmp.iso | + | |
- | vg0_backup | + | |
- | [root@centos8 tmp]# mv custom custom.gz | + | Ensuite il convient d' |
- | [root@centos8 | + | < |
+ | root@debian11:~# cd /tmp | ||
+ | root@debian11:/ | ||
+ | root@debian11:/ | ||
+ | root@debian11:/ | ||
+ | ... | ||
+ | var | ||
+ | var/cache | ||
+ | var/ | ||
+ | var/ | ||
+ | var/ | ||
+ | var/ | ||
+ | var/ | ||
+ | var/ | ||
+ | 31991 blocks | ||
+ | </ | ||
- | [root@centos8 tmp]# mkdir initramfs | + | Installez maintenant le paquet **tree** : |
- | [root@centos8 | + | < |
+ | root@debian11:/tmp/initrd# apt-get -y install tree | ||
+ | </ | ||
- | [root@centos8 initramfs]# cpio -cid -I ../custom | + | Utilisez maintenant la commande **tree** pour examiner le contenu de l' |
- | 216 blocks | + | |
- | [root@centos8 | + | < |
- | bin dev | + | root@debian11:/ |
+ | . | ||
+ | ├── bin -> usr/bin | ||
+ | ├── conf | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | ├── cryptroot | ||
+ | │ | ||
+ | ├── | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | --More-- | ||
+ | [q] | ||
</ | </ | ||
- | ===Examiner | + | Comme vous pouvez le constater, |
- | Pour examiner une image initramfs archivée, il convient d' | + | < |
+ | root@debian11:/ | ||
+ | total 36 | ||
+ | lrwxrwxrwx | ||
+ | drwxr-xr-x | ||
+ | drwxr-xr-x | ||
+ | drwxr-xr-x 10 root root 4096 Apr 30 11:02 etc | ||
+ | -rwxr-xr-x | ||
+ | lrwxrwxrwx | ||
+ | lrwxrwxrwx | ||
+ | lrwxrwxrwx | ||
+ | lrwxrwxrwx | ||
+ | drwxr-xr-x | ||
+ | lrwxrwxrwx | ||
+ | drwxr-xr-x 10 root root 4096 Apr 30 11:02 scripts | ||
+ | drwxr-xr-x 10 root root 4096 Apr 30 11:02 usr | ||
+ | drwxr-xr-x | ||
+ | </ | ||
+ | |||
+ | Le script | ||
< | < | ||
- | [root@centos8 | + | root@debian11:/tmp/initrd# more init |
- | Image: custom: 25M | + | #!/bin/sh |
- | ======================================================================== | + | |
- | Early CPIO image | + | |
- | ======================================================================== | + | |
- | drwxr-xr-x | + | |
- | -rw-r--r-- | + | |
- | drwxr-xr-x | + | |
- | drwxr-xr-x | + | |
- | drwxr-xr-x | + | |
- | -rw-r--r-- | + | |
- | ======================================================================== | + | |
- | Version: dracut-049-95.git20200804.el8_3.4 | + | |
- | Arguments: -f --kver '4.18.0-240.22.1.el8_3.x86_64' | + | # Default PATH differs between shells, and is not automatically exported |
+ | # by klibc dash. Make it consistent. | ||
+ | export PATH=/ | ||
- | dracut modules: | + | [ -d /dev ] || mkdir -m 0755 /dev |
- | bash | + | [ -d /root ] || mkdir -m 0700 /root |
- | systemd | + | [ -d /sys ] || mkdir /sys |
- | systemd-initrd | + | [ -d /proc ] || mkdir /proc |
- | nss-softokn | + | [ -d /tmp ] || mkdir /tmp |
- | rngd | + | mkdir -p /var/lock |
- | i18n | + | mount -t sysfs -o nodev, |
- | network-legacy | + | mount -t proc -o nodev, |
- | network | + | |
- | ifcfg | + | # shellcheck disable=SC2013 |
- | drm | + | for x in $(cat / |
- | plymouth | + | case $x in |
- | prefixdevname | + | |
- | kernel-modules | + | clear |
- | kernel-modules-extra | + | ;; |
- | kernel-network-modules | + | |
- | resume | + | |
- | rootfs-block | + | ;; |
- | terminfo | + | esac |
- | udev-rules | + | done |
- | biosdevname | + | |
- | dracut-systemd | + | if [ " |
- | usrmount | + | quiet=n |
- | base | + | echo " |
- | fs-lib | + | fi |
- | memstrack | + | export quiet |
- | microcode_ctl-fw_dir_override | + | |
- | shutdown | + | # Note that this only becomes /dev on the real filesystem if udev's scripts |
- | ======================================================================== | + | # are used; which they will be, but it's worth pointing out |
- | drwxr-xr-x | + | mount -t devtmpfs |
- | crw-r--r-- | + | mkdir /dev/pts |
- | crw-r--r-- | + | mount -t devpts |
- | crw-r--r-- 1 root | + | |
- | crw-r--r-- | + | # Export the dpkg architecture |
- | crw-r--r-- 1 root | + | export DPKG_ARCH= |
- | lrwxrwxrwx | + | . /conf/arch.conf |
- | drwxr-xr-x | + | |
- | drwxr-xr-x | + | # Set modprobe env |
- | -rw-r--r-- | + | export MODPROBE_OPTIONS=" |
- | drwxr-xr-x | + | |
- | drwxr-xr-x 2 root | + | # Export relevant variables |
- | -rw-r--r-- | + | export ROOT= |
- | --More-- | + | export ROOTDELAY= |
+ | export ROOTFLAGS= | ||
+ | export ROOTFSTYPE= | ||
+ | export IP= | ||
+ | export DEVICE= | ||
+ | export BOOT= | ||
+ | export BOOTIF= | ||
+ | export UBIMTD= | ||
+ | export break= | ||
+ | export init=/sbin/init | ||
+ | --More--(19%) | ||
</ | </ | ||
- | ===Le script init=== | + | <WRAP center round todo 60%> |
+ | **A faire** : Passez en revue le contenu du script. | ||
+ | </ | ||
+ | |||
+ | ===1.2 - La commande mkinitramfs=== | ||
- | RHEL/CentOS 8 utilise le système de démarrage | + | La commande |
< | < | ||
- | [root@centos8 tmp]# lsinitrd custom | grep usr/ | + | root@debian11:~# mkinitramfs --help |
- | lrwxrwxrwx | + | |
+ | Usage: mkinitramfs [option]... | ||
+ | |||
+ | Options: | ||
+ | -c compress | ||
+ | -d confdir | ||
+ | -k Keep temporary directory used to make the image. | ||
+ | -o outfile | ||
+ | -r root | ||
+ | |||
+ | See mkinitramfs(8) for further details. | ||
</ | </ | ||
- | ===Consulter le contenu d' | + | Le fichier |
- | Pour consulter le contenu d'un fichier inclus dans l'initramfs, il convient d' | + | < |
+ | root@debian11:/ | ||
+ | root@debian11:/ | ||
+ | # List of modules that you want to include in your initramfs. | ||
+ | # They will be loaded at boot time in the order below. | ||
+ | # | ||
+ | # Syntax: | ||
+ | # | ||
+ | # You must run update-initramfs(8) to effect this change. | ||
+ | # | ||
+ | # Examples: | ||
+ | # | ||
+ | # raid1 | ||
+ | # sd_mod | ||
+ | usbcore | ||
+ | uhci | ||
+ | ehci-hcd | ||
+ | usb-ohci | ||
+ | usb-uhci | ||
+ | usb-storage | ||
+ | scsi_mod | ||
+ | sd_mod | ||
+ | </ | ||
+ | |||
+ | Exécutez maintenant | ||
< | < | ||
- | [root@centos8 | + | root@debian11:/tmp/initrd# mkinitramfs |
- | include ld.so.conf.d/ | + | |
</ | </ | ||
- | ====Processus de Démarrage du Noyau Linux==== | + | Notez la présence de votre nouvelle image **/ |
+ | |||
+ | < | ||
+ | root@debian11:/ | ||
+ | -rw-r--r-- 1 root root 47695493 Apr 30 11:12 / | ||
+ | </ | ||
+ | |||
+ | Déplacez votre fichier usbinitramfs au répertoire /boot : | ||
+ | |||
+ | < | ||
+ | root@debian11:/ | ||
+ | </ | ||
+ | |||
+ | Créez maintenant le fichier **/ | ||
+ | |||
+ | < | ||
+ | root@debian11:/ | ||
+ | root@debian11:/ | ||
+ | #!/bin/sh -e | ||
+ | cat << EOF | ||
+ | menuentry ' | ||
+ | load_video | ||
+ | insmod gzio | ||
+ | if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi | ||
+ | insmod part_msdos | ||
+ | insmod ext2 | ||
+ | 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 9887a74f-a680-4bde-8f04-db5ae9ea186e | ||
+ | fi | ||
+ | echo ' | ||
+ | linux / | ||
+ | echo ' | ||
+ | initrd | ||
+ | } | ||
+ | EOF | ||
+ | </ | ||
+ | |||
+ | Rendez ce fichier exécutable : | ||
+ | |||
+ | < | ||
+ | root@debian11:/ | ||
+ | </ | ||
+ | |||
+ | Mettez à jour grub afin que celui-ci prend en compte le nouveau fichier : | ||
+ | |||
+ | < | ||
+ | root@debian11:/ | ||
+ | Generating grub configuration file ... | ||
+ | Found background image: / | ||
+ | Found linux image: / | ||
+ | Found initrd image: / | ||
+ | done | ||
+ | </ | ||
+ | |||
+ | Controlez le fichier / | ||
+ | |||
+ | < | ||
+ | ... | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | menuentry ' | ||
+ | load_video | ||
+ | insmod gzio | ||
+ | if [ x = xxen ]; then insmod xzio; insmod lzopio; fi | ||
+ | insmod part_msdos | ||
+ | insmod ext2 | ||
+ | set root=' | ||
+ | if [ x = xy ]; then | ||
+ | search --no-floppy --fs-uuid --set=root --hint-bios=hd0, | ||
+ | else | ||
+ | search --no-floppy --fs-uuid --set=root 9887a74f-a680-4bde-8f04-db5ae9ea186e | ||
+ | fi | ||
+ | echo ' | ||
+ | linux / | ||
+ | echo ' | ||
+ | initrd | ||
+ | } | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | =====Processus de Démarrage du Noyau Linux===== | ||
Le processus de démarrage du Noyau Linux peut être divisé en 6 étapes : | Le processus de démarrage du Noyau Linux peut être divisé en 6 étapes : | ||
Ligne 1114: | Ligne 1355: | ||
Dans le cas d'un échec à ce stade le message **Kernel Panic** sera affiché. | Dans le cas d'un échec à ce stade le message **Kernel Panic** sera affiché. | ||
- | ====Processus Init==== | + | =====Processus Init===== |
Le premier processus lancé par le noyau est **Init**. L' | Le premier processus lancé par le noyau est **Init**. L' | ||
Ligne 1345: | Ligne 1586: | ||
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
**Important** : Notez que chaque répertoire correspondant à un niveau d' | **Important** : Notez que chaque répertoire correspondant à un niveau d' | ||
</ | </ | ||
Ligne 1370: | Ligne 1611: | ||
</ | </ | ||
- | <WRAP center round important> | + | <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 **/ | **Important** : Ici le principe est le même sauf que la lettre **K** indique au script **rc** que le script dans **/ | ||
</ | </ | ||
Ligne 1827: | Ligne 2068: | ||
# update-rc.d ssh start 20 2 3 4 5 . stop 20 0 1 6 . [Entrée] | # update-rc.d ssh start 20 2 3 4 5 . stop 20 0 1 6 . [Entrée] | ||
- | <WRAP center round important> | + | <WRAP center round important |
**Important** : | **Important** : | ||
Il existe aussi un mot clef : **default**. Ce mot clef indique à **update-rc.d** d' | Il existe aussi un mot clef : **default**. Ce mot clef indique à **update-rc.d** d' | ||
Ligne 1836: | Ligne 2077: | ||
# update-rc.d -f ssh remove [Entrée] | # update-rc.d -f ssh remove [Entrée] | ||
- | <WRAP center round important> | + | <WRAP center round important |
**Important** : | **Important** : | ||
Cette commande laisse le script ssh dans le répertoire / | Cette commande laisse le script ssh dans le répertoire / | ||
Ligne 2080: | Ligne 2321: | ||
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
**Important** : Notez qu'à part la deuxième ligne de la description, | **Important** : Notez qu'à part la deuxième ligne de la description, | ||
</ | </ | ||
Ligne 2597: | Ligne 2838: | ||
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
Il est aussi possible d' | Il est aussi possible d' | ||
</ | </ |