Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
elearning:workbooks:debian:10:junior:l109 [2022/04/29 07:57] – created adminelearning:workbooks:debian:10:junior:l109 [2024/04/22 13:58] (Version actuelle) admin
Ligne 1: Ligne 1:
 ~~PDF:LANDSCAPE~~ ~~PDF:LANDSCAPE~~
  
-Version : **2022.01**+Version : **2024.01**
  
 Dernière mise-à-jour : ~~LASTMOD~~ Dernière mise-à-jour : ~~LASTMOD~~
Ligne 54: Ligne 54:
       * LAB #27 - Créer un Système de Fichiers Chiffré avec encryptfs       * LAB #27 - Créer un Système de Fichiers Chiffré avec encryptfs
       * LAB #28 - Créer un Système de Fichiers Chiffré avec LUKS       * LAB #28 - Créer un Système de Fichiers Chiffré avec LUKS
 +    * Raid Logiciel
 +      * LAB #29 - Mise en Place du RAID 5 Logiciel
 +        * 29.1 - Préparer le disque
 +        * 29.2 - Créer une Unité RAID
 +        * 29.3 - Remplacer une Unité Défaillante
     * Le Swap     * Le Swap
       * Taille du swap       * Taille du swap
Ligne 59: Ligne 64:
       * La Commande swapon       * La Commande swapon
       * La Commande swapoff       * La Commande swapoff
-      * LAB #29 - Créer un Fichier de Swap+      * LAB #30 - Créer un Fichier de Swap
  
 =====Périphériques de stockage===== =====Périphériques de stockage=====
Ligne 157: Ligne 162:
 ====LAB #1 - Partitionnement de votre Disque avec fdisk==== ====LAB #1 - Partitionnement de votre Disque avec fdisk====
  
-Pour procéder au partitionnement de votre disque ou de vos disques, RHEL/CentOS 8 possède l'outil dénommé **fdisk**.+Pour procéder au partitionnement de votre disque ou de vos disques, Debian 11 possède l'outil dénommé **fdisk**.
  
 Lancez fdisk en fournissant en argument le fichier de référence de votre premier disque dur, par exemple : Lancez fdisk en fournissant en argument le fichier de référence de votre premier disque dur, par exemple :
Ligne 681: Ligne 686:
 Afin de mettre en place le LVM, vous avez besoin du paquet **lvm2** et du paquet **device-mapper**.  Afin de mettre en place le LVM, vous avez besoin du paquet **lvm2** et du paquet **device-mapper**. 
  
-Sous Debian 8, installez le paquet lvm2 :+Sous Debian 11, installez le paquet lvm2 :
  
 <code> <code>
Ligne 3664: Ligne 3669:
  
 <code> <code>
-root@debian11:~# apt-get -y install btrfs-tools+root@debian11:~# apt-get -y install btrfs-progs
 </code> </code>
  
Ligne 4326: Ligne 4331:
 **NE PAS FAIRE** : Lors du démarrage de la machine virtuelle, le système vous demandera d'entrer la passphrase **fenestros123456789** pour permettre le montage de /dev/sdc11. **NE PAS FAIRE** : Lors du démarrage de la machine virtuelle, le système vous demandera d'entrer la passphrase **fenestros123456789** pour permettre le montage de /dev/sdc11.
 </WRAP> </WRAP>
 +
 +=====RAID Logiciel=====
 +
 +====LAB #29 - Mise en Place du RAID 5 Logiciel====
 +
 +===29.1 - Préparer le disque===
 +
 +Rappelez-vous avoir modifié les types de 4 partitions du disque **/dev/sdc** en **fd** :
 +
 +<code>
 +root@debian11:~# fdisk -l
 +Disk /dev/sda: 32 GiB, 34359738368 bytes, 67108864 sectors
 +Disk model: QEMU HARDDISK   
 +Units: sectors of 1 * 512 = 512 bytes
 +Sector size (logical/physical): 512 bytes / 512 bytes
 +I/O size (minimum/optimal): 512 bytes / 512 bytes
 +Disklabel type: dos
 +Disk identifier: 0xf2e3a71a
 +
 +Device     Boot    Start      End  Sectors  Size Id Type
 +/dev/sda1  *        2048 65107967 65105920   31G 83 Linux
 +/dev/sda2       65110014 67106815  1996802  975M  5 Extended
 +/dev/sda5       65110016 67106815  1996800  975M 82 Linux swap / Solaris
 +
 +
 +Disk /dev/sdb: 64 GiB, 68719476736 bytes, 134217728 sectors
 +Disk model: QEMU HARDDISK   
 +Units: sectors of 1 * 512 = 512 bytes
 +Sector size (logical/physical): 512 bytes / 512 bytes
 +I/O size (minimum/optimal): 512 bytes / 512 bytes
 +
 +
 +Disk /dev/sdc: 4 GiB, 4294967296 bytes, 8388608 sectors
 +Disk model: QEMU HARDDISK   
 +Units: sectors of 1 * 512 = 512 bytes
 +Sector size (logical/physical): 512 bytes / 512 bytes
 +I/O size (minimum/optimal): 512 bytes / 512 bytes
 +Disklabel type: dos
 +Disk identifier: 0x304308a3
 +
 +Device     Boot   Start     End Sectors  Size Id Type
 +/dev/sdc1          2048  206847  204800  100M 83 Linux
 +/dev/sdc2        206848  411647  204800  100M 83 Linux
 +/dev/sdc3        411648  616447  204800  100M 83 Linux
 +/dev/sdc4        616448 8388607 7772160  3.7G  5 Extended
 +/dev/sdc5        618496 1642495 1024000  500M fd Linux raid autodetect
 +/dev/sdc6       1644544 2054143  409600  200M 8e Linux LVM
 +/dev/sdc7       2056192 2670591  614400  300M 8e Linux LVM
 +/dev/sdc8       2672640 3696639 1024000  500M fd Linux raid autodetect
 +/dev/sdc9       3698688 4517887  819200  400M 8e Linux LVM
 +/dev/sdc10      4519936 5543935 1024000  500M fd Linux raid autodetect
 +/dev/sdc11      5545984 6569983 1024000  500M fd Linux raid autodetect
 +/dev/sdc12      6572032 6981631  409600  200M 83 Linux
 +
 +
 +Disk /dev/mapper/vg0-lv1: 104 MiB, 109051904 bytes, 212992 sectors
 +Units: sectors of 1 * 512 = 512 bytes
 +Sector size (logical/physical): 512 bytes / 512 bytes
 +I/O size (minimum/optimal): 512 bytes / 512 bytes
 +
 +
 +Disk /dev/mapper/vg0-lv2: 112 MiB, 117440512 bytes, 229376 sectors
 +Units: sectors of 1 * 512 = 512 bytes
 +Sector size (logical/physical): 512 bytes / 512 bytes
 +I/O size (minimum/optimal): 65536 bytes / 131072 bytes
 +
 +
 +Disk /dev/mapper/sdc11: 484 MiB, 507510784 bytes, 991232 sectors
 +Units: sectors of 1 * 512 = 512 bytes
 +Sector size (logical/physical): 512 bytes / 512 bytes
 +I/O size (minimum/optimal): 512 bytes / 512 bytes
 +</code>
 +
 +Dans le cas de cet exemple les quatre partitions concernées par la mise en place d'un RAID 5 sont :
 +
 +<file>
 +/dev/sdc5        618496 1642495 1024000  500M fd Linux raid autodetect
 +/dev/sdc8       2672640 3696639 1024000  500M fd Linux raid autodetect
 +/dev/sdc10      4519936 5543935 1024000  500M fd Linux raid autodetect
 +/dev/sdc11      5545984 6569983 1024000  500M fd Linux raid autodetect
 +</file>
 +
 +===29.2 - Créer une Unité RAID===
 +
 +La création d'une unité RAID avec la commande **mdadm** se fait grâce aux options passées en arguments à la commande :
 +
 +<code>
 +mdadm --create <unité RAID> [options] <unités physiques>
 +</code>
 +
 +Sous Debian 11, mdadm n'est pas installé par défaut :
 +
 +<code>
 +root@debian11:~# apt-get -y install mdadm
 +</code>
 +
 +Saisissez maintenant la commande suivante :
 +
 +<code>
 +root@debian11:~# mdadm --create /dev/md1 --level=5 --raid-devices=3 /dev/sdc5 /dev/sdc8 /dev/sdc10
 +mdadm: /dev/sdc8 appears to contain a reiserfs file system
 +       size = 512000K
 +Continue creating array? y
 +mdadm: Defaulting to version 1.2 metadata
 +mdadm: array /dev/md1 started.
 +</code>
 +
 +Les options dans la ligne de commande sont :
 +
 +^ Option Courte ^ Option Longue ^ Description ^
 +| -l | - -level | Le niveau RAID - **linear, 0,1,2,4 ou 5** |
 +| -n | - -raid-devices=<nombre> | Le nombre de périphériques actifs dans le RAID |
 +
 +Les options de la commande **mdadm** sont :
 +
 +<code>
 +root@debian11:~# mdadm --help-options
 +Any parameter that does not start with '-' is treated as a device name
 +or, for --examine-bitmap, a file name.
 +The first such name is often the name of an md device.  Subsequent
 +names are often names of component devices.
 +
 +Some common options are:
 +  --help        -h   : General help message or, after above option,
 +                       mode specific help message
 +  --help-options     : This help message
 +  --version     -V   : Print version information for mdadm
 +  --verbose     -v   : Be more verbose about what is happening
 +  --quiet       -q   : Don't print un-necessary messages
 +  --brief       -b   : Be less verbose, more brief
 +  --export      -Y   : With --detail, --detail-platform or --examine use
 +                       key=value format for easy import into environment
 +  --force       -f   : Override normal checks and be more forceful
 +
 +  --assemble    -A   : Assemble an array
 +  --build       -B   : Build an array without metadata
 +  --create      -C   : Create a new array
 +  --detail      -D   : Display details of an array
 +  --examine     -E   : Examine superblock on an array component
 +  --examine-bitmap -X: Display the detail of a bitmap file
 +  --examine-badblocks: Display list of known bad blocks on device
 +  --monitor     -F   : monitor (follow) some arrays
 +  --grow        -G   : resize/ reshape and array
 +  --incremental -I   : add/remove a single device to/from an array as appropriate
 +  --query       -Q   : Display general information about how a
 +                       device relates to the md driver
 +  --auto-detect      : Start arrays auto-detected by the kernel
 +</code>
 +
 +La commande **mdadm** utilise des sous-commandes ou //mode majeurs// :
 +
 +<code>
 +root@debian11:~# mdadm --help
 +mdadm is used for building, managing, and monitoring
 +Linux md devices (aka RAID arrays)
 +Usage: mdadm --create device options...
 +            Create a new array from unused devices.
 +       mdadm --assemble device options...
 +            Assemble a previously created array.
 +       mdadm --build device options...
 +            Create or assemble an array without metadata.
 +       mdadm --manage device options...
 +            make changes to an existing array.
 +       mdadm --misc options... devices
 +            report on or modify various md related devices.
 +       mdadm --grow options device
 +            resize/reshape an active array
 +       mdadm --incremental device
 +            add/remove a device to/from an array as appropriate
 +       mdadm --monitor options...
 +            Monitor one or more array for significant changes.
 +       mdadm device options...
 +            Shorthand for --manage.
 +Any parameter that does not start with '-' is treated as a device name
 +or, for --examine-bitmap, a file name.
 +The first such name is often the name of an md device.  Subsequent
 +names are often names of component devices.
 +
 + For detailed help on the above major modes use --help after the mode
 + e.g.
 +         mdadm --assemble --help
 + For general help on options use
 +         mdadm --help-options
 +</code>
 +
 +Chaque sous-commande bénéficie d'un aide spécifique, par exemple :
 +
 +<code>
 +root@debian11:~# mdadm --create --help
 +Usage:  mdadm --create device --chunk=X --level=Y --raid-devices=Z devices
 +
 + This usage will initialise a new md array, associate some
 + devices with it, and activate the array.   In order to create an
 + array with some devices missing, use the special word 'missing' in
 + place of the relevant device name.
 +
 + Before devices are added, they are checked to see if they already contain
 + raid superblocks or filesystems.  They are also checked to see if
 + the variance in device size exceeds 1%.
 + If any discrepancy is found, the user will be prompted for confirmation
 + before the array is created.  The presence of a '--run' can override this
 + caution.
 +
 + If the --size option is given then only that many kilobytes of each
 + device is used, no matter how big each device is.
 + If no --size is given, the apparent size of the smallest drive given
 + is used for raid level 1 and greater, and the full device is used for
 + other levels.
 +
 + Options that are valid with --create (-C) are:
 +  --bitmap=          -b : Create a bitmap for the array with the given filename
 +                        : or an internal bitmap if 'internal' is given
 +  --chunk=           -c : chunk size in kibibytes
 +  --rounding=           : rounding factor for linear array (==chunk size)
 +  --level=           -l : raid level: 0,1,4,5,6,10,linear,multipath and synonyms
 +  --parity=          -p : raid5/6 parity algorithm: {left,right}-{,a}symmetric
 +  --layout=             : same as --parity, for RAID10: [fno]NN 
 +  --raid-devices=    -n : number of active devices in array
 +  --spare-devices=   -x : number of spare (eXtra) devices in initial array
 +  --size=            -z : Size (in K) of each drive in RAID1/4/5/6/10 - optional
 +  --data-offset=        : Space to leave between start of device and start
 +                        : of array data.
 +  --force            -f : Honour devices as listed on command line.  Don't
 +                        : insert a missing drive for RAID5.
 +  --run              -R : insist of running the array even if not all
 +                        : devices are present or some look odd.
 +  --readonly         -o : start the array readonly - not supported yet.
 +  --name=            -N : Textual name for array - max 32 characters
 +  --bitmap-chunk=       : bitmap chunksize in Kilobytes.
 +  --delay=           -d : bitmap update delay in seconds.
 +  --write-journal=      : Specify journal device for RAID-4/5/6 array
 +  --consistency-policy= : Specify the policy that determines how the array
 +                     -k : maintains consistency in case of unexpected shutdown.
 +</code>
 +
 +Les //modes majeurs// de la commande **mdadm** peuvent être visualisés grâce à la commande suivante :
 +
 +<code>
 +root@debian8:~# mdadm --help
 +mdadm is used for building, managing, and monitoring
 +Linux md devices (aka RAID arrays)
 +Usage: mdadm --create device options...
 +            Create a new array from unused devices.
 +       mdadm --assemble device options...
 +            Assemble a previously created array.
 +       mdadm --build device options...
 +            Create or assemble an array without metadata.
 +       mdadm --manage device options...
 +            make changes to an existing array.
 +       mdadm --misc options... devices
 +            report on or modify various md related devices.
 +       mdadm --grow options device
 +            resize/reshape an active array
 +       mdadm --incremental device
 +            add/remove a device to/from an array as appropriate
 +       mdadm --monitor options...
 +            Monitor one or more array for significant changes.
 +       mdadm device options...
 +            Shorthand for --manage.
 +Any parameter that does not start with '-' is treated as a device name
 +or, for --examine-bitmap, a file name.
 +The first such name is often the name of an md device.  Subsequent
 +names are often names of component devices.
 +
 + For detailed help on the above major modes use --help after the mode
 + e.g.
 +         mdadm --assemble --help
 + For general help on options use
 +         mdadm --help-options
 +</code>
 +
 +Constatez maintenant les informations concernant le RAID 5 créé :
 +
 +<code>
 +root@debian11:~# cat /proc/mdstat
 +Personalities : [raid6] [raid5] [raid4] 
 +md1 : active raid5 sdc10[3] sdc8[1] sdc5[0]
 +      1019904 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
 +      
 +unused devices: <none>
 +</code>
 +
 +Grâce à la commande mdadm, il est possible d'obtenir d'avantage d'informations :
 +
 +<code>
 +root@debian11:~# mdadm --query /dev/md1
 +/dev/md1: 996.00MiB raid5 3 devices, 0 spares. Use mdadm --detail for more detail.
 +</code>
 +
 +L'option **- -detail** produit le résultat suivant :
 +
 +<code>
 +root@debian11:~# mdadm --detail /dev/md1
 +/dev/md1:
 +           Version : 1.2
 +     Creation Time : Sun May  1 13:27:48 2022
 +        Raid Level : raid5
 +        Array Size : 1019904 (996.00 MiB 1044.38 MB)
 +     Used Dev Size : 509952 (498.00 MiB 522.19 MB)
 +      Raid Devices : 3
 +     Total Devices : 3
 +       Persistence : Superblock is persistent
 +
 +       Update Time : Sun May  1 13:27:53 2022
 +             State : clean 
 +    Active Devices : 3
 +   Working Devices : 3
 +    Failed Devices : 0
 +     Spare Devices : 0
 +
 +            Layout : left-symmetric
 +        Chunk Size : 512K
 +
 +Consistency Policy : resync
 +
 +              Name : debian11: (local to host debian11)
 +              UUID : c0f945a0:f65b2136:b7913f8a:3707ffa2
 +            Events : 18
 +
 +    Number   Major   Minor   RaidDevice State
 +                   37        0      active sync   /dev/sdc5
 +                   40        1      active sync   /dev/sdc8
 +                   42        2      active sync   /dev/sdc10
 +</code>
 +
 +Notez la ligne **Persistence : Superblock is persistent**. En effet, cette implémentation de RAID inscrit les caractéristiques du volume dans un //super bloc// persistant en début de chaque unité de type bloc dans le volume.
 +
 +Cependant, il necéssaire de renseigner le fichier **/etc/mdadm/mdadm.conf** afin que le RAID soit contruit à chaque démarrage :
 +
 +<code>
 +root@debian11:~# cat /etc/mdadm/mdadm.conf
 +# mdadm.conf
 +#
 +# !NB! Run update-initramfs -u after updating this file.
 +# !NB! This will ensure that initramfs has an uptodate copy.
 +#
 +# Please refer to mdadm.conf(5) for information about this file.
 +#
 +
 +# by default (built-in), scan all partitions (/proc/partitions) and all
 +# containers for MD superblocks. alternatively, specify devices to scan, using
 +# wildcards if desired.
 +#DEVICE partitions containers
 +
 +# automatically tag new arrays as belonging to the local system
 +HOMEHOST <system>
 +
 +# instruct the monitoring daemon where to send mail alerts
 +MAILADDR root
 +
 +# definitions of existing MD arrays
 +
 +# This configuration was auto-generated on Sun, 01 May 2022 13:26:29 +0200 by mkconf
 +</code>
 +
 +Ecrasez le contenu de ce fichier avec les informations suivantes :
 +
 +<code>
 +root@debian11:~# echo 'DEVICE /dev/sdc5 /dev/sdc8 /dev/sdc10' > /etc/mdadm/mdadm.conf
 +root@debian11:~# mdadm --detail --scan >> /etc/mdadm/mdadm.conf
 +root@debian11:~# cat /etc/mdadm/mdadm.conf
 +DEVICE /dev/sdc5 /dev/sdc8 /dev/sdc10
 +ARRAY /dev/md1 metadata=1.2 name=debian11:1 UUID=c0f945a0:f65b2136:b7913f8a:3707ffa2
 +</code>
 +
 +Mettez à jour l'initramfs :
 +
 +<code>
 +root@debian11:~# update-initramfs -u
 +update-initramfs: Generating /boot/initrd.img-5.10.0-13-amd64
 +</code>
 +
 +Chaque unité peut être examinée individuellement :
 +
 +<code>
 +root@debian11:~# mdadm --examine /dev/sdc5
 +/dev/sdc5:
 +          Magic : a92b4efc
 +        Version : 1.2
 +    Feature Map : 0x0
 +     Array UUID : c0f945a0:f65b2136:b7913f8a:3707ffa2
 +           Name : debian11: (local to host debian11)
 +  Creation Time : Sun May  1 13:27:48 2022
 +     Raid Level : raid5
 +   Raid Devices : 3
 +
 + Avail Dev Size : 1019904 (498.00 MiB 522.19 MB)
 +     Array Size : 1019904 (996.00 MiB 1044.38 MB)
 +    Data Offset : 4096 sectors
 +   Super Offset : 8 sectors
 +   Unused Space : before=4016 sectors, after=0 sectors
 +          State : clean
 +    Device UUID : 1d34dda2:28775dbb:53d242e9:9acba5dd
 +
 +    Update Time : Sun May  1 13:27:53 2022
 +  Bad Block Log : 512 entries available at offset 16 sectors
 +       Checksum : 31909df9 - correct
 +         Events : 18
 +
 +         Layout : left-symmetric
 +     Chunk Size : 512K
 +
 +   Device Role : Active device 0
 +   Array State : AAA ('A' == active, '.' == missing, 'R' == replacing)
 +</code>
 +
 +===29.3 - Remplacer une Unité Défaillante===
 +
 +A ce stade il est intéressant de noter comment réagir lors d'une défaillance d'un disque. Dans notre cas nous allons indiquer au système que la partition /dev/sdc5 est devenue défaillante :
 +
 +<code>
 +root@debian11:~# mdadm --manage --set-faulty /dev/md1 /dev/sdc5
 +mdadm: set /dev/sdc5 faulty in /dev/md1
 +</code>
 +
 +L'utilisation de la ligne de commande suivante nous confirme le statut de /dev/sdc5 :
 +
 +<code>
 +root@debian11:~# mdadm --detail /dev/md1
 +/dev/md1:
 +           Version : 1.2
 +     Creation Time : Sun May  1 13:27:48 2022
 +        Raid Level : raid5
 +        Array Size : 1019904 (996.00 MiB 1044.38 MB)
 +     Used Dev Size : 509952 (498.00 MiB 522.19 MB)
 +      Raid Devices : 3
 +     Total Devices : 3
 +       Persistence : Superblock is persistent
 +
 +       Update Time : Sun May  1 13:43:24 2022
 +             State : clean, degraded 
 +    Active Devices : 2
 +   Working Devices : 2
 +    Failed Devices : 1
 +     Spare Devices : 0
 +
 +            Layout : left-symmetric
 +        Chunk Size : 512K
 +
 +Consistency Policy : resync
 +
 +              Name : debian11: (local to host debian11)
 +              UUID : c0f945a0:f65b2136:b7913f8a:3707ffa2
 +            Events : 20
 +
 +    Number   Major   Minor   RaidDevice State
 +                    0        0      removed
 +                   40        1      active sync   /dev/sdc8
 +                   42        2      active sync   /dev/sdc10
 +
 +                   37        -      faulty   /dev/sdc5
 +</code>
 +
 +Il est maintenant nécessaire de supprimer /dev/sdc5 de notre RAID 5 :
 +
 +<code>
 +root@debian11:~# mdadm --manage --remove /dev/md1 /dev/sdc5
 +mdadm: hot removed /dev/sdc5 from /dev/md1
 +</code>
 +
 +A l'examen de notre RAID, on constate que /dev/sdc5 a été supprimé :
 +
 +<code>
 +root@debian11:~# mdadm --detail /dev/md1
 +/dev/md1:
 +           Version : 1.2
 +     Creation Time : Sun May  1 13:27:48 2022
 +        Raid Level : raid5
 +        Array Size : 1019904 (996.00 MiB 1044.38 MB)
 +     Used Dev Size : 509952 (498.00 MiB 522.19 MB)
 +      Raid Devices : 3
 +     Total Devices : 2
 +       Persistence : Superblock is persistent
 +
 +       Update Time : Sun May  1 13:44:41 2022
 +             State : clean, degraded 
 +    Active Devices : 2
 +   Working Devices : 2
 +    Failed Devices : 0
 +     Spare Devices : 0
 +
 +            Layout : left-symmetric
 +        Chunk Size : 512K
 +
 +Consistency Policy : resync
 +
 +              Name : debian11: (local to host debian11)
 +              UUID : c0f945a0:f65b2136:b7913f8a:3707ffa2
 +            Events : 21
 +
 +    Number   Major   Minor   RaidDevice State
 +                    0        0      removed
 +                   40        1      active sync   /dev/sdc8
 +                   42        2      active sync   /dev/sdc10
 +</code>
 +
 +Constatez maintenant l'existance de votre RAID :
 +
 +<code>
 +root@debian11:~# cat /proc/mdstat
 +Personalities : [raid6] [raid5] [raid4] 
 +md1 : active raid5 sdc10[3] sdc8[1]
 +      1019904 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [_UU]
 +      
 +unused devices: <none>
 +</code>
 +
 +<WRAP center round important>
 +**iMPORTANT** - Notez que le RAID a 2 unités au lieu de trois.
 +</WRAP>
 +
 +Nous avons déjà utilisé **/dev/sdc11** pour héberger LUKs. Constatez le statut de celui-ci :
 +
 +<code>
 +root@debian11:~# umount /mnt/sdc11
 +
 +root@debian11:~# cryptsetup status sdc11
 +/dev/mapper/sdc11 is active.
 +  type:    LUKS2
 +  cipher:  aes-xts-plain64
 +  keysize: 512 bits
 +  key location: keyring
 +  device:  /dev/sdc11
 +  sector size:  512
 +  offset:  32768 sectors
 +  size:    991232 sectors
 +  mode:    read/write
 +</code>
 +
 +Avant de supprimer LUKs, il convient de supprimer la dernière passphrase :
 +
 +<code>
 +root@debian11:~# cryptsetup luksRemoveKey /dev/sdc11
 +Enter passphrase to be deleted: fenestros123456789
 +
 +WARNING!
 +========
 +This is the last keyslot. Device will become unusable after purging this key.
 +
 +Are you sure? (Type 'yes' in capital letters): YES
 +</code>
 +
 +Supprimez maintenant LUKs :
 +
 +<code>
 +root@debian11:~# cryptsetup remove /dev/mapper/sdc11
 +</code>
 +
 +Vérifiez de nouveau le statut :
 +
 +<code>
 +root@debian11:~# cryptsetup status sdc11
 +/dev/mapper/sdc11 is inactive.
 +
 +root@debian11:~# lsblk
 +NAME        MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
 +sda           8:   0   32G  0 disk  
 +├─sda1        8:1    0   31G  0 part  /
 +├─sda2        8:2    0    1K  0 part  
 +└─sda5        8:5    0  975M  0 part  [SWAP]
 +sdb           8:16     64G  0 disk  
 +sdc           8:32      4G  0 disk  
 +├─sdc1        8:33    100M  0 part  
 +├─sdc2        8:34    100M  0 part  
 +├─sdc3        8:35    100M  0 part  
 +├─sdc4        8:36      1K  0 part  
 +├─sdc5        8:37    500M  0 part  
 +├─sdc6        8:38    200M  0 part  
 +│ └─vg0-lv1 254:0    0  104M  0 lvm   
 +├─sdc7        8:39    300M  0 part  
 +│ └─vg0-lv2 254:1    0  112M  0 lvm   
 +├─sdc8        8:40    500M  0 part  
 +│ └─md1       9:   0  996M  0 raid5 
 +├─sdc9        8:41    400M  0 part  
 +│ └─vg0-lv2 254:1    0  112M  0 lvm   
 +├─sdc10       8:42    500M  0 part  
 +│ └─md1       9:   0  996M  0 raid5 
 +├─sdc11       8:43    500M  0 part  
 +└─sdc12       8:44    200M  0 part  
 +sr0          11:0    1  378M  0 rom   
 +</code>
 +
 +Pour ajouter un autre disque à notre RAID afin de remplacer /dev/sdc5 il convient d'utiliser l'option **--add** :
 +
 +<code>
 +root@debian11:~# mdadm --manage --add /dev/md1 /dev/sdc11
 +mdadm: added /dev/sdc11
 +</code>
 +
 +L'exemen du RAID indique que /dev/sdc11 a été ajouté en tant que //spare// et à l'issu de quelques secondes le RAID 5 a été reconstruite :
 +
 +<code>
 +root@debian11:~# mdadm --detail /dev/md1
 +/dev/md1:
 +           Version : 1.2
 +     Creation Time : Sun May  1 13:27:48 2022
 +        Raid Level : raid5
 +        Array Size : 1019904 (996.00 MiB 1044.38 MB)
 +     Used Dev Size : 509952 (498.00 MiB 522.19 MB)
 +      Raid Devices : 3
 +     Total Devices : 3
 +       Persistence : Superblock is persistent
 +
 +       Update Time : Sun May  1 14:03:05 2022
 +             State : clean, degraded, recovering 
 +    Active Devices : 2
 +   Working Devices : 3
 +    Failed Devices : 0
 +     Spare Devices : 1
 +
 +            Layout : left-symmetric
 +        Chunk Size : 512K
 +
 +Consistency Policy : resync
 +
 +    Rebuild Status : 56% complete
 +
 +              Name : debian11: (local to host debian11)
 +              UUID : c0f945a0:f65b2136:b7913f8a:3707ffa2
 +            Events : 32
 +
 +    Number   Major   Minor   RaidDevice State
 +                   43        0      spare rebuilding   /dev/sdc11
 +                   40        1      active sync   /dev/sdc8
 +                   42        2      active sync   /dev/sdc10
 +
 +root@debian11:~# mdadm --detail /dev/md1
 +/dev/md1:
 +           Version : 1.2
 +     Creation Time : Sun May  1 13:27:48 2022
 +        Raid Level : raid5
 +        Array Size : 1019904 (996.00 MiB 1044.38 MB)
 +     Used Dev Size : 509952 (498.00 MiB 522.19 MB)
 +      Raid Devices : 3
 +     Total Devices : 3
 +       Persistence : Superblock is persistent
 +
 +       Update Time : Sun May  1 14:03:07 2022
 +             State : clean 
 +    Active Devices : 3
 +   Working Devices : 3
 +    Failed Devices : 0
 +     Spare Devices : 0
 +
 +            Layout : left-symmetric
 +        Chunk Size : 512K
 +
 +Consistency Policy : resync
 +
 +              Name : debian11: (local to host debian11)
 +              UUID : c0f945a0:f65b2136:b7913f8a:3707ffa2
 +            Events : 40
 +
 +    Number   Major   Minor   RaidDevice State
 +                   43        0      active sync   /dev/sdc11
 +                   40        1      active sync   /dev/sdc8
 +                   42        2      active sync   /dev/sdc10
 +</code>
 +
 +Vérifiez la prise en compte de la configuration :
 +
 +<code>
 +root@debian11:~# lsblk
 +NAME        MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
 +sda           8:   0   32G  0 disk  
 +├─sda1        8:1    0   31G  0 part  /
 +├─sda2        8:2    0    1K  0 part  
 +└─sda5        8:5    0  975M  0 part  [SWAP]
 +sdb           8:16     64G  0 disk  
 +sdc           8:32      4G  0 disk  
 +├─sdc1        8:33    100M  0 part  
 +├─sdc2        8:34    100M  0 part  
 +├─sdc3        8:35    100M  0 part  
 +├─sdc4        8:36      1K  0 part  
 +├─sdc5        8:37    500M  0 part  
 +├─sdc6        8:38    200M  0 part  
 +│ └─vg0-lv1 254:0    0  104M  0 lvm   
 +├─sdc7        8:39    300M  0 part  
 +│ └─vg0-lv2 254:1    0  112M  0 lvm   
 +├─sdc8        8:40    500M  0 part  
 +│ └─md1       9:   0  996M  0 raid5 
 +├─sdc9        8:41    400M  0 part  
 +│ └─vg0-lv2 254:1    0  112M  0 lvm   
 +├─sdc10       8:42    500M  0 part  
 +│ └─md1       9:   0  996M  0 raid5 
 +├─sdc11       8:43    500M  0 part  
 +│ └─md1       9:   0  996M  0 raid5 
 +└─sdc12       8:44    200M  0 part  
 +sr0          11:0    1  378M  0 rom
 +
 +root@debian11:~# cat /proc/mdstat
 +Personalities : [raid6] [raid5] [raid4] 
 +md1 : active raid5 sdc11[4] sdc10[3] sdc8[1]
 +      1019904 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
 +      
 +unused devices: <none>
 +</code>
 +
 +Dernièrement, il nécessaire de renseigner le fichier **/etc/mdadm/mdadm.conf** du changement afin que le RAID soit construit à chaque démarrage :
 +
 +<code>
 +root@debian11:~# echo 'DEVICE /dev/sdc11 /dev/sdc8 /dev/sdc10' > /etc/mdadm/mdadm.conf
 +root@debian11:~# mdadm --detail --scan >> /etc/mdadm/mdadm.conf
 +root@debian11:~# cat /etc/mdadm/mdadm.conf
 +DEVICE /dev/sdc11 /dev/sdc8 /dev/sdc10
 +ARRAY /dev/md1 metadata=1.2 name=debian11:1 UUID=c0f945a0:f65b2136:b7913f8a:3707ffa2
 +</code>
 +
 +Mettez à jour l'initramfs :
 +
 +<code>
 +root@debian11:~# update-initramfs -u
 +update-initramfs: Generating /boot/initrd.img-5.10.0-13-amd64
 +</code>
  
 =====Le Swap===== =====Le Swap=====
Ligne 4460: Ligne 5179:
 </code> </code>
  
-====LAB #29 - Créer un Fichier de Swap====+====LAB #30 - Créer un Fichier de Swap====
  
 Sous Linux, vous pouvez aussi bien utiliser un fichier de swap qu'une partition. La mise en place de ce fichier est faite en utilisant la commande **dd**.  Sous Linux, vous pouvez aussi bien utiliser un fichier de swap qu'une partition. La mise en place de ce fichier est faite en utilisant la commande **dd**. 
Ligne 4502: Ligne 5221:
 root@debian11:~# swapon /dev/sdc5 root@debian11:~# swapon /dev/sdc5
  
-root@debian11:~# swapon /swap+root@debian11:~# swapon -p 3 /swap
 </code> </code>
  
Ligne 4511: Ligne 5230:
 Filename                                Type            Size    Used    Priority Filename                                Type            Size    Used    Priority
 /dev/sdb5                               partition       998396  0       -2 /dev/sdb5                               partition       998396  0       -2
-/swap                                   file            262140  0       -3+/swap                                   file            262140  0       3
 </code> </code>
  
Ligne 4535: Ligne 5254:
  
 ----- -----
-<html> +Copyright © 2024 Hugh Norris.
-<div align="center"> +
-Copyright © 2022 Hugh Norris.<br><br> +
-</div> +
-</html> +
------ +
Menu