Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
elearning:workbooks:redhat:rh134:l104 [2024/09/26 13:24] – created admin | elearning:workbooks:redhat:rh134:l104 [2024/10/24 12:57] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
- | Version : **2021.01** | + | Version : **2024.01** |
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======LRF607 | + | ======RH13405 |
=====Contenu du Module===== | =====Contenu du Module===== | ||
- | * **LRF607 | + | * **RH13405 |
* Contenu du Module | * Contenu du Module | ||
- | * System Hardening Manuel | + | * Périphériques de stockage |
- | * Les compilateurs | + | * Partitions |
- | * Les paquets | + | * Partitionnement |
- | * Les démons | + | * LAB #1 - Partitionnement de votre Disque avec fdisk |
- | * Les fichiers .rhosts | + | * LAB #2 - Modifier les Drapeaux des Partitions avec fdisk |
- | * Les fichiers et les repertoires sans proprietaire | + | * Logical Volume Manager (LVM) |
- | * Interdire | + | * LAB #3 - Volumes Logiques Linéaires |
- | * Limiter le delai d' | + | * Physical Volume (PV) |
- | * Renforcer la securite | + | * Volume Group (VG) et Physical Extent (PE) |
- | * Les Distributions SysVInit | + | * Logical Volumes (LV) |
- | * Les Distributions Upstart | + | * LAB #4 - Étendre un Volume Logique à Chaud |
- | * Renforcer la sécurité | + | * LAB #5 - Snapshots |
- | * La commande sysctl | + | * LAB #6 - Suppression des Volumes |
- | * LAB #1 - System Hardening à l'aide de l'outil Bastille | + | * LAB #7 - Volumes Logiques en Miroir |
+ | * LAB #8 - Modifier | ||
+ | * LAB #9 - Volumes Logiques en Bandes | ||
+ | * LAB #10 - Gérer | ||
+ | * Raid Logiciel | ||
+ | * Concepts RAID | ||
+ | * Disques en miroir | ||
+ | * Bandes de données | ||
+ | * Types de RAID | ||
+ | * RAID 0 - Concaténation | ||
+ | * RAID 0 - Striping | ||
+ | * RAID 1 - Miroir | ||
+ | * RAID 1+0 - Striping en Miroir | ||
+ | * RAID 2 - Miroir avec Contrôle | ||
+ | * RAID 3 et 4 - Striping avec Parité | ||
+ | * RAID 5 - Striping avec Parité Distribuée | ||
+ | * Au délà de RAID 5 | ||
+ | * LAB #11 - Mise en Place du RAID 5 Logiciel | ||
+ | * 11.1 - Préparer le disque | ||
+ | * 11.2 - Créer une Unité RAID | ||
+ | * 11.3 - Remplacer une Unité Défaillante | ||
+ | * LAB #12 - Travailler avec Stratis | ||
+ | * 12.1 - Présentation | ||
+ | * Concepts clés de Stratis | ||
+ | * Gestion simplifiée | ||
+ | * Avantages de Stratis | ||
+ | * Stratis vs ZFS/Btrfs | ||
+ | * 12.2 - Travailler avec Stratis | ||
+ | * Installation | ||
+ | * Création d'un Pool | ||
+ | * Création d'un Système | ||
+ | * Montage du System de Fichiers | ||
+ | * Croissance Dynamique du Système de Fichiers | ||
+ | * Création d'un Snapshot | ||
+ | * Suppression des Systèmes de Fichiers | ||
+ | * Systèmes de Fichiers Journalisés | ||
* Présentation | * Présentation | ||
- | * Installation | + | * LAB #13 - Ext3 |
- | * Utilisation | + | * 13.1 - Gestion d'Ext3 |
- | * LAB #2 - Mise en place de SELinux pour sécuriser le serveur | + | * 13.2 - Convertir un Système |
- | * Introducton | + | * 13.3 - Convertir un Système de Fichiers Ext2 en Ext3 |
- | * Définitions | + | * 13.4 - Placer le Journal sur un autre Partition |
- | * Security Context | + | * 13.5 - Modifier la Fréquence de Vérification du Système de Fichiers Ext3 |
- | * Domains et Types | + | * LAB #14 - Ext4 |
- | * Roles | + | * 14.1 - Créer un Système de Fichiers Ext4 |
- | * Politiques | + | * 14.2 - Ajouter une Étiquette au Système |
- | * Langage | + | * 14.3 - Convertir un Système |
- | * allow | + | * LAB #15 - XFS |
- | * type | + | * 15.1 - Créer un Système de Fichiers XFS |
- | * type_transition | + | * 15.2 - Ajouter une Étiquette au Système de Fichiers XFS |
- | * Décisions | + | * Autres Systèmes |
- | * Décisions d' | + | * ReiserFS |
- | * Décisions de Transition | + | * JFS |
- | * Commandes | + | * Btrfs |
- | * Les Etats de SELinux | + | * Comparaison des Commandes |
- | * Booléens | + | * LAB #16 - Système |
- | * LAB #3 - Travailler avec SELinux | + | * 16.1 - La Commande mkisofs |
- | * Copier et Déplacer des Fichiers | + | * LAB #17 - Systèmes de Fichiers Chiffrés |
- | * Vérifier les SC des Processus | + | * 17.1 - Créer un Système de Fichiers |
- | * Visualiser la SC d'un Utilisateur | + | * Présentation |
- | * Vérifier la SC d'un fichier | + | * Mise en Place |
- | * Troubleshooting SELinux | + | * Ajouter une deuxième Passphrase |
- | * La commande chcon | + | * Supprimer une Passphrase |
- | * La commande restorecon | + | * Supprimer LUKS |
- | * Le fichier /.autorelabel | + | * LAB #18 - Le Swap |
- | * La commande semanage | + | * 18.1 - Taille du swap |
- | * La commande audit2allow | + | * 18.2 - Partitions de swap |
+ | * 18.3 - La Commande swapon | ||
+ | * 18.4 - La Commande swapoff | ||
+ | * 18.5 - Créer un Fichier de Swap | ||
- | =====System Hardening Manuel===== | + | =====Périphériques de stockage===== |
- | ====Les compilateurs==== | + | Les unités de stockage sous Linux sont référencées par un des fichiers se trouvant dans le répertoire **/dev** : |
- | Afin d' | + | * hd[a-d] |
+ | * Les disques IDE et les lecteurs ATAPI | ||
+ | * sd[a-z] | ||
+ | * Les disques SCSI et SATA | ||
+ | * mmcblk[0-7] | ||
+ | * Les cartes SD/MMC | ||
+ | * scd[0-7] | ||
+ | * Les CDRoms SCSI | ||
+ | * xd[a-d] | ||
+ | * Les premiers disques | ||
+ | * fd[0-7] | ||
+ | * Les lecteurs de disquettes | ||
+ | * st[0-7] | ||
+ | * Les lecteurs de bandes SCSI/SATA qui **supportent** le rembobinage | ||
+ | * nst[0-7] | ||
+ | * Les lecteurs de bandes SCSI/SATA qui ne supportent **pas** le rembobinage | ||
+ | * ht[0-7] | ||
+ | * Les lecteurs de bandes PATA qui **supportent** le rembobinage | ||
+ | * nht[0-7] | ||
+ | * Les lecteurs de bandes PATA qui ne supportent **pas** le rembobinage | ||
+ | * rmt8, rmt16, tape-d, tape-reset | ||
+ | * Les lecteurs QIC-80 | ||
+ | * ram[0-15] | ||
+ | * Les disques virtuels. Ils sont supprimés à l' | ||
+ | * Périphériques **loop** | ||
+ | * Il existe 16 unités loop qui sont utilisés pour accèder en mode bloc à un système de fichiers contenu dans un fichier, par exemple, une image **iso** | ||
+ | * md[x] | ||
+ | * Un volume **RAID** logiciel | ||
+ | * vg[x] | ||
+ | * Un groupe de volumes | ||
+ | * lv[x] | ||
+ | * Un volume logique | ||
- | ====Les paquets==== | + | =====Partitions===== |
- | Il convient dans ce cas de passer en revue la liste des paquets installes puis de supprimer ceux qui sont juges être inutiles | + | Un PC comportent en règle générale 2 **contrôleurs** de disque, chacun capable de gérer 2 disques, un **maître** et un **esclave**. Les disques attachés à ces contrôleurs comportent des noms différents pour pouvoir les distinguer : |
+ | |||
+ | * Contrôleur 0 | ||
+ | * Maître | ||
+ | * **hda** - disque IDE | ||
+ | * **sda** - disque SATA ou SCSI | ||
+ | * Esclave | ||
+ | * **hdb** - disque IDE | ||
+ | * **sdb** - disque SATA ou SCSI | ||
+ | * Contrôleur 1 | ||
+ | * Maître | ||
+ | * **hdc** - disque IDE | ||
+ | * **sdc** - disque SATA ou SCSI | ||
+ | * Esclave | ||
+ | * **hdd** - disque IDE | ||
+ | * **sdd** - disque SATA ou SCSI | ||
+ | |||
+ | Un disque peut comporter trois types de partitions : | ||
+ | |||
+ | * **Partitions primaires**, | ||
+ | * Maximum de **4**. En effet, la Table des Partitions est grande de 64 octets. | ||
+ | * **Partitions Etendues**, | ||
+ | * Généralement une seule partition étendue par disque. Elle contient des **Lecteurs Logiques** aussi appelés des partitions, | ||
+ | * **Lecteurs Logiqiques**. | ||
+ | |||
+ | Les 4 partitions primaires sont numérotées de 1 à 4. Par exemple : | ||
+ | |||
+ | * **hda1**, **hda2**, **hda3** et **hda4** pour le premier disque **IDE** sur le premier contrôleur de disque, | ||
+ | * **sda1**, **sda2**, **sda3** et **sda4** pour le premier disque **SCSI** ou **SATA** sur le premier contrôleur de disque. | ||
+ | |||
+ | {{free: | ||
+ | |||
+ | Une partition étendue prend la place d'une partition primaire et les lecteurs logiques qui s'y trouvent commencent à partir de **hda5** ou de **sda5**. | ||
+ | |||
+ | Pour clarifier ceci, considérons un disque **SATA** contenant deux partitions primaires, une seule partition étendue et 3 lecteurs logiques. Dans ce cas, les deux premières partitions sont **sda1** et **sda2**, la partition étendue prend la place de la troisième partition primaire, la **sda3** et s' | ||
+ | |||
+ | Les lecteurs logiques commençant à **sda5**, nous obtenons | ||
+ | |||
+ | {{free: | ||
+ | |||
+ | Le nombre de partitions sur un disque est limité : | ||
+ | |||
+ | * **IDE**, | ||
+ | * Jusqu' | ||
+ | * **SCSI**, | ||
+ | * Jusqu' | ||
+ | * **Disques utilisant l'API libata**, | ||
+ | * Jusqu' | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Ces limites peuvent être dépassées en utilisant la gestion **LVM** (//Logical Volume Management// | ||
+ | </ | ||
+ | |||
+ | =====Partitionnement===== | ||
+ | |||
+ | Le schéma de partitionnement **Master Boot Record** (MBR) est la norme sur les systèmes qui utilisent le BIOS. Ce schéma prend en charge un maximum de quatre partitions primaires. Sur les systèmes Linux, avec des partitions étendues et logiques, vous pouvez créer jusqu' | ||
+ | |||
+ | La limite | ||
+ | |||
+ | Pour les systèmes | ||
+ | |||
+ | Le partitionnement GPT offre des fonctionnalités et des avantages supplémentaires par rapport au MBR. GPT utilise un identifiant unique (GUID) pour identifier chaque disque et chaque partition. GPT rend la table de partition redondante avec le GPT primaire en tête de disque et un GPT secondaire de sauvegarde à la fin du disque. GPT utilise une somme de contrôle pour détecter les erreurs dans l' | ||
+ | |||
+ | ====LAB #1 - Partitionnement de votre Disque sous RedHat 9 avec fdisk==== | ||
+ | |||
+ | Pour procéder au partitionnement de votre disque ou de vos disques, RedHat 9 possède l' | ||
+ | |||
+ | Lancez fdisk en fournissant en argument le fichier de référence de votre premier disque dur, par exemple | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | libtalloc-2.1.9-1.el7.x86_64 | + | |
- | gnome-contacts-3.22.1-1.el7.x86_64 | + | |
- | lrzsz-0.12.20-36.el7.x86_64 | + | |
- | NetworkManager-team-1.8.0-11.el7_4.x86_64 | + | |
- | opus-1.0.2-6.el7.x86_64 | + | |
- | libsss_certmap-1.15.2-50.el7_4.11.x86_64 | + | |
- | m17n-db-1.6.4-3.el7.noarch | + | |
- | expat-2.1.0-10.el7_3.x86_64 | + | |
- | gvfs-mtp-1.30.4-3.el7.x86_64 | + | |
- | hypervfcopyd-0-0.30.20161211git.el7.x86_64 | + | |
- | perl-parent-0.225-244.el7.noarch | + | |
- | libreport-centos-2.1.11-38.el7.centos.x86_64 | + | |
- | pixman-0.34.0-1.el7.x86_64 | + | |
- | alsa-plugins-pulseaudio-1.1.1-1.el7.x86_64 | + | |
- | libreoffice-graphicfilter-5.0.6.2-15.el7_4.x86_64 | + | |
- | libreport-rhel-anaconda-bugzilla-2.1.11-38.el7.centos.x86_64 | + | |
- | libXext-1.3.3-3.el7.x86_64 | + | |
- | libtool-ltdl-2.4.2-22.el7_3.x86_64 | + | |
- | NetworkManager-ppp-1.8.0-11.el7_4.x86_64 | + | |
- | osinfo-db-20170423-2.el7.noarch | + | |
- | fftw-libs-double-3.3.3-8.el7.x86_64 | + | |
- | kernel-tools-libs-3.10.0-693.21.1.el7.x86_64 | + | |
- | e2fsprogs-libs-1.42.9-10.el7.x86_64 | + | |
- | --More-- | + | |
- | </code> | + | |
- | ====Les démons et services==== | + | Welcome to fdisk (util-linux 2.37.4). |
+ | Changes will remain in memory only, until you decide to write them. | ||
+ | Be careful before using the write command. | ||
- | Il convient dans ce cas de passer en revue la liste des démons et services actives puis de supprimer ceux qui sont juges être inutiles; | + | Device does not contain a recognized partition table. |
+ | Created a new DOS disklabel with disk identifier 0x23a56c2e. | ||
- | * ps aux | + | Command (m for help): |
- | * chkconfig --list | + | </ |
- | * systemctl list-unit-files | + | |
+ | Tapez ensuite la lettre **m** puis < | ||
< | < | ||
- | [root@centos7 ~]# ps aux | more | + | Command (m for help): m |
- | USER PID %CPU %MEM VSZ | + | |
- | root | + | Help: |
- | ched-root --system --deserialize 21 | + | |
- | root | + | DOS (MBR) |
- | root | + | a |
- | root | + | b |
- | root | + | |
- | root | + | |
- | root | + | |
- | root | + | |
- | root 10 0.0 0.0 0 0 ? S 14:58 | + | F list free unpartitioned space |
- | root 12 0.0 0.0 0 0 ? S 14:58 0:00 [kdevtmpfs] | + | l |
- | root 13 0.0 0.0 0 0 ? S< | + | n add a new partition |
- | root 14 0.0 0.0 0 0 ? S 14:58 | + | p print the partition table |
- | root 15 0.0 0.0 0 0 ? S< | + | t |
- | root 16 0.0 0.0 0 0 ? S< | + | v |
- | root 17 0.0 0.0 0 0 ? S< | + | i print information about a partition |
- | root 18 0.0 0.0 0 0 ? S< | + | |
- | root 19 0.0 0.0 0 0 ? S< | + | |
- | root 25 0.0 0.0 0 0 ? S 14:58 | + | m |
- | root 26 0.0 0.0 0 0 ? SN | + | u |
- | root 27 0.0 0.0 0 0 ? S< | + | x |
- | root 35 0.0 0.0 0 0 ? S< | + | |
- | --More-- | + | |
+ | | ||
+ | O | ||
+ | |||
+ | | ||
+ | | ||
+ | q | ||
+ | |||
+ | | ||
+ | | ||
+ | G | ||
+ | o | ||
+ | s | ||
+ | |||
+ | |||
+ | Command (m for help): | ||
</ | </ | ||
+ | |||
+ | Pour créer une nouvelle partition, vous devez utiliser la commande **n**. | ||
+ | |||
+ | Créez donc les partitions suivantes sur votre disque : | ||
+ | |||
+ | ^ Partition ^ Type ^ Taille de la Partition ^ | ||
+ | | /dev/sdb1 | Primaire | 100 Mo | | ||
+ | | /dev/sdb2 | Primaire | 100 Mo | | ||
+ | | /dev/sdb3 | Primaire | 100 Mo | | ||
+ | | /dev/sdb4 | Extended | Du premier secteur disponible au dernier secteur du disque | | ||
+ | | /dev/sdb5 | Logique | 500 Mo | | ||
+ | | /dev/sdb6 | Logique | 200 Mo | | ||
+ | | /dev/sdb7 | Logique | 300 Mo | | ||
+ | | /dev/sda8 | Logique | 500 Mo | | ||
+ | | /dev/sdb9 | Logique | 400 Mo | | ||
+ | | /dev/sdb10 | Logique | 500 Mo | | ||
+ | | /dev/sdb11 | Logique | 500 Mo | | ||
+ | | /dev/sdb12 | Logique | 200 Mo | | ||
+ | |||
+ | Créez d' | ||
< | < | ||
- | [root@centos7 ~]# chkconfig --list | + | Command (m for help): n |
+ | Partition type | ||
+ | | ||
+ | | ||
+ | Select (default p): | ||
- | Note: This output shows SysV services only and does not include native | + | Using default response p. |
- | | + | Partition number (1-4, default 1): |
- | | + | First sector (2048-67108863, |
+ | Last sector, +/-sectors or +/ | ||
- | If you want to list systemd services use 'systemctl list-unit-files' | + | Created a new partition 1 of type 'Linux' |
- | To see services enabled on particular target use | + | |
- | ' | + | |
- | livesys | + | Command (m for help): n |
- | livesys-late 0:off 1:off 2:off 3: | + | Partition type |
- | netconsole | + | |
- | network | + | |
- | snortd | + | Select (default p): |
+ | |||
+ | Using default response p. | ||
+ | Partition number (2-4, default 2): | ||
+ | First sector (206848-67108863, | ||
+ | Last sector, +/-sectors or +/-size{K, | ||
+ | |||
+ | Created a new partition | ||
+ | |||
+ | Command (m for help): n | ||
+ | Partition type | ||
+ | | ||
+ | | ||
+ | Select (default p): | ||
+ | |||
+ | Using default response p. | ||
+ | Partition number (3,4, default 3): | ||
+ | First sector (411648-67108863, | ||
+ | Last sector, +/-sectors or +/ | ||
+ | |||
+ | Created a new partition | ||
+ | |||
+ | Command (m for help): | ||
</ | </ | ||
+ | |||
+ | Créez ensuite la partition étendue : | ||
< | < | ||
- | [root@centos7 ~]# systemctl list-unit-files | + | Command (m for help): n |
- | UNIT FILE | + | Partition type |
- | proc-sys-fs-binfmt_misc.automount | + | |
- | dev-hugepages.mount | + | e |
- | dev-mqueue.mount | + | Select (default e): |
- | proc-fs-nfsd.mount static | + | |
- | proc-sys-fs-binfmt_misc.mount | + | Using default response e. |
- | sys-fs-fuse-connections.mount | + | Selected partition 4 |
- | sys-kernel-config.mount | + | First sector (616448-67108863, default 616448): |
- | sys-kernel-debug.mount | + | Last sector, +/-sectors or +/-size{K, |
- | tmp.mount | + | |
- | var-lib-nfs-rpc_pipefs.mount static | + | Created a new partition 4 of type ' |
- | brandbot.path | + | |
- | cups.path | + | Command (m for help): |
- | systemd-ask-password-console.path | + | |
- | systemd-ask-password-plymouth.path | + | |
- | systemd-ask-password-wall.path | + | |
- | session-33.scope | + | |
- | abrt-ccpp.service | + | |
- | abrt-oops.service | + | |
- | abrt-pstoreoops.service | + | |
- | abrt-vmcore.service | + | |
- | abrt-xorg.service | + | |
- | abrtd.service | + | |
- | lines 1-23 | + | |
</ | </ | ||
- | ====Les fichiers .rhosts==== | + | Créez maintenant les autres partitions l'une après l' |
- | Le systeme rhosts presente une faille de securite importante pour un serveur Linux. Pour cette raison, il convient de supprimer les fichiers **.rhosts** des utilisateurs. Utilisez la commande suivante: | + | < |
+ | Command (m for help): n | ||
+ | All primary partitions are in use. | ||
+ | Adding logical partition 5 | ||
+ | First sector (618496-67108863, default 618496): | ||
+ | Last sector, +/-sectors or +/ | ||
- | # find / -name "\.rhosts" | + | Created a new partition 5 of type ' |
- | ====Les fichiers et les repertoires sans proprietaire==== | + | Command (m for help): n |
+ | All primary partitions are in use. | ||
+ | Adding logical partition 6 | ||
+ | First sector (1644544-67108863, | ||
+ | Last sector, +/-sectors or +/ | ||
- | Afin de dresser la liste des fichiers et des groupes sans proprietaires sur le serveur, il convient d'utiliser les deux commandes suivantes: | + | Created a new partition 6 of type 'Linux' and of size 200 MiB. |
- | # find / -nouser | + | Command (m for help): n |
+ | All primary partitions are in use. | ||
+ | Adding logical partition 7 | ||
+ | First sector (2056192-67108863, | ||
+ | Last sector, +/-sectors or +/-size{K,M,G,T,P} (2056192-67108863, | ||
- | # find / -nogroup -exec ls -l \{\} \; 2>> sans_pro.txt[Entree] | + | Created a new partition 7 of type ' |
- | Ces commandes produiront une liste éventuelle dans le fichier **sans_pro.txt**. | + | Command (m for help): n |
+ | All primary partitions are in use. | ||
+ | Adding logical partition 8 | ||
+ | First sector (2672640-67108863, | ||
+ | Last sector, +/-sectors or +/ | ||
- | L'examen de cette liste pourrait dévoiler des anomalies au quel cas il conviendrait de: | + | Created a new partition 8 of type 'Linux' and of size 500 MiB. |
- | * modifier le propriétaire a root | + | Command (m for help): n |
- | * modifier le groupe a root | + | All primary partitions are in use. |
- | * modifier les permissions a 700 | + | Adding logical partition 9 |
+ | First sector (3698688-67108863, | ||
+ | Last sector, +/-sectors or +/ | ||
- | ====Interdire les connexions de root via le reseau==== | + | Created a new partition 9 of type ' |
- | Le fichier de configuration des connexions de root est **/etc/securetty** : | + | Command (m for help): n |
+ | All primary partitions are in use. | ||
+ | Adding logical partition 10 | ||
+ | First sector (4519936-67108863, | ||
+ | Last sector, +/-sectors or +/-size{K, | ||
+ | |||
+ | Created a new partition 10 of type ' | ||
+ | |||
+ | Command (m for help): n | ||
+ | All primary partitions are in use. | ||
+ | Adding logical partition 11 | ||
+ | First sector (5545984-67108863, | ||
+ | Last sector, +/-sectors or +/ | ||
+ | |||
+ | Created a new partition 11 of type ' | ||
+ | |||
+ | Command (m for help): n | ||
+ | All primary partitions are in use. | ||
+ | Adding logical partition 12 | ||
+ | First sector (6572032-67108863, | ||
+ | Last sector, +/-sectors or +/ | ||
+ | |||
+ | Created a new partition 12 of type ' | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | Tapez ensuite la lettre | ||
< | < | ||
- | [root@centos7 ~]# cat /etc/securetty | + | Command (m for help): p |
- | console | + | Disk /dev/sdb: 32 GiB, 34359738368 bytes, 67108864 sectors |
- | vc/1 | + | Disk model: QEMU HARDDISK |
- | vc/2 | + | Units: sectors of 1 * 512 = 512 bytes |
- | vc/3 | + | Sector size (logical/physical): 512 bytes / 512 bytes |
- | vc/4 | + | I/O size (minimum/ |
- | vc/5 | + | Disklabel type: dos |
- | vc/6 | + | Disk identifier: 0x23a56c2e |
- | vc/7 | + | |
- | vc/8 | + | Device |
- | vc/9 | + | /dev/sdb1 2048 |
- | vc/10 | + | /dev/ |
- | vc/11 | + | /dev/ |
- | tty1 | + | /dev/ |
- | tty2 | + | /dev/ |
- | tty3 | + | /dev/ |
- | tty4 | + | /dev/ |
- | tty5 | + | /dev/ |
- | tty6 | + | / |
- | tty7 | + | / |
- | tty8 | + | /dev/ |
- | tty9 | + | / |
- | tty10 | + | |
- | tty11 | + | Command (m for help): |
- | ttyS0 | + | |
- | ttysclp0 | + | |
- | sclp_line0 | + | |
- | 3270/tty1 | + | |
- | hvc0 | + | |
- | hvc1 | + | |
- | hvc2 | + | |
- | hvc3 | + | |
- | hvc4 | + | |
- | hvc5 | + | |
- | hvc6 | + | |
- | hvc7 | + | |
- | hvsi0 | + | |
- | hvsi1 | + | |
- | hvsi2 | + | |
- | xvc0 | + | |
</ | </ | ||
- | Afin d' | + | Ecrivez la table des partitions sur disque |
- | ====Limiter le delai d' | + | < |
+ | Command (m for help): w | ||
+ | The partition table has been altered. | ||
+ | Calling ioctl() to re-read partition table. | ||
+ | Syncing disks. | ||
- | Une session de shell laissee ouverte inutilement et d'une maniere sans surveillance est un risque de securite. Verifiez donc le contenu du fichier | + | [root@redhat9 ~]# partprobe |
+ | [root@redhat9 ~]# | ||
+ | </ | ||
+ | |||
+ | Lancez fdisk puis tapez ensuite la lettre | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | # / | + | |
- | # System wide environment and startup programs, for login setup | + | Welcome to fdisk (util-linux 2.37.4). |
- | # Functions and aliases go in /etc/bashrc | + | Changes will remain |
+ | Be careful before using the write command. | ||
- | # It's NOT a good idea to change this file unless you know what you | ||
- | # are doing. It's much better to create a custom.sh shell script in | ||
- | # / | ||
- | # will prevent the need for merging in future updates. | ||
- | pathmunge | + | Command |
- | case ":${PATH}:" in | + | Disk /dev/sdb: 32 GiB, 34359738368 bytes, 67108864 sectors |
- | *:"$1":*) | + | Disk model: QEMU HARDDISK |
- | ;; | + | Units: sectors of 1 * 512 = 512 bytes |
- | *) | + | Sector size (logical/ |
- | if [ " | + | I/O size (minimum/ |
- | PATH=$PATH:$1 | + | Disklabel type: dos |
- | | + | Disk identifier: 0x23a56c2e |
- | PATH=$1:$PATH | + | |
- | fi | + | |
- | esac | + | |
- | } | + | |
+ | Device | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
- | if [ -x /usr/bin/id ]; then | + | Command (m for help): |
- | if [ -z " | + | </code> |
- | # ksh workaround | + | |
- | EUID=`/usr/bin/id -u` | + | |
- | UID=`/ | + | |
- | fi | + | |
- | USER=" | + | |
- | LOGNAME=$USER | + | |
- | MAIL="/ | + | |
- | fi | + | |
- | # Path manipulation | + | Pour supprimer une partition, utilisez la commande **d** puis < |
- | if [ " | + | |
- | pathmunge | + | |
- | pathmunge / | + | |
- | else | + | |
- | pathmunge / | + | |
- | pathmunge /usr/sbin after | + | |
- | fi | + | |
- | HOSTNAME=`/ | + | <code> |
- | HISTSIZE=1000 | + | Command (m for help): d |
- | if [ " | + | Partition number (1-12, default 12): 12 |
- | export HISTCONTROL=ignoreboth | + | |
- | else | + | |
- | export HISTCONTROL=ignoredups | + | |
- | fi | + | |
- | export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL | + | Partition 12 has been deleted. |
- | # By default, we want umask to get set. This sets it for login shell | + | Command (m for help): p |
- | # Current threshold for system reserved uid/gids is 200 | + | Disk /dev/sdb: 32 GiB, 34359738368 bytes, 67108864 sectors |
- | # You could check uidgid reservation validity in | + | Disk model: QEMU HARDDISK |
- | # / | + | Units: sectors of 1 * 512 = 512 bytes |
- | if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then | + | Sector size (logical/physical): 512 bytes / 512 bytes |
- | umask 002 | + | I/O size (minimum/optimal): 512 bytes / 512 bytes |
- | else | + | Disklabel type: dos |
- | umask 022 | + | Disk identifier: 0x23a56c2e |
- | fi | + | |
- | for i in /etc/profile.d/*.sh ; do | + | Device |
- | if [ -r " | + | /dev/sdb1 2048 |
- | | + | /dev/ |
- | . " | + | / |
- | | + | / |
- | . " | + | / |
- | fi | + | /dev/sdb6 |
- | fi | + | / |
- | done | + | / |
+ | / | ||
+ | / | ||
+ | / | ||
- | unset i | + | Command (m for help): |
- | unset -f pathmunge | + | |
</ | </ | ||
- | A ce fichier doivent etre ajoutées les deux lignes suivantes: | + | A ce stade, la partition n'a **pas** été réellement supprimée. En effet, vous avez la possibilité de sortir de fdisk en utilisant la commande **q**. |
- | < | + | Tapez donc q pour sortir de fdisk puis relancez fdisk. Vous obtiendrez un résultat similaire à celui-ci : |
- | Readonly TMOUT=300 | + | |
- | Export TMOUT | + | |
- | </ | + | |
- | Par cette action, vous définissez le délai d’inactivité d'une session shell a une durée de 5 minutes. | + | < |
+ | Command (m for help): q | ||
- | Dernièrement, | + | [root@redhat9 ~]# fdisk /dev/sdb |
- | ====Renforcer la securite d' | + | Welcome to fdisk (util-linux 2.37.4). |
+ | Changes will remain in memory only, until you decide to write them. | ||
+ | Be careful before using the write command. | ||
- | ===Les Distributions SysVInit=== | ||
- | Le fichier **/etc/inittab** est utilise pour configurer le démarrage de votre serveur. | + | Command (m for help): p |
+ | Disk /dev/sdb: 32 GiB, 34359738368 bytes, 67108864 sectors | ||
+ | Disk model: QEMU HARDDISK | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disklabel type: dos | ||
+ | Disk identifier: 0x23a56c2e | ||
- | La première modification à effectuer est de spécifier le niveau d’exécution par défaut a 3 au lieu de 5. Ceci permet de ne pas lancer les sessions graphiques sur une serveur de production. Cherchez donc la ligne suivante: | + | Device |
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
- | < | + | Command (m for help): |
- | id: | + | </code> |
- | </file> | + | |
- | Modifiez-la en: | + | ====LAB #2 - Modifier les Drapeaux des Partitions avec fdisk==== |
- | < | + | Afin de mettre en place un RAID logiciel ou un volume logique, il est nécessaire de modifier les types de systèmes de fichiers sur les partitions créées. |
- | id: | + | |
- | </ | + | |
- | Le mode **single user** de démarrage de Linux n'est pas habituellement protégé par un mot de passe. Afin de remédier a cela, ajoutez les lignes suivantes: | + | Modifiez donc les nouvelles partitions à l'aide de la commande |
- | < | + | ^ Taille de la Partition ^ Type de Système de Fichiers ^ |
- | # Single user mode | + | | 500 Mo | RAID (fd) | |
- | ~~: | + | | 200 Mo | Linux LVM (8e) | |
- | </ | + | | 300 Mo | Linux LVM (8e) | |
+ | | 500 Mo | RAID (fd) | | ||
+ | | 400 Mo | Linux LVM (8e) | | ||
+ | | 500 Mo | RAID (fd) | | ||
+ | | 500 Mo | RAID (fd) | | ||
+ | | 200 Mo | Inchangé | | ||
- | Dernièrement, | + | Vous obtiendrez un résultat similaire |
- | <file> | + | <code> |
- | # ca::ctrlaltdel:/ | + | Command (m for help): t |
- | </ | + | Partition number (1-12, default 12): 5 |
+ | Hex code or alias (type L to list all): fd | ||
- | ===Les Distributions Upstart=== | + | Changed type of partition ' |
- | Afin d' | + | Command (m for help): t |
+ | Partition number (1-12, default 12): 6 | ||
+ | Hex code or alias (type L to list all): 8e | ||
- | < | + | Changed type of partition ' |
- | exec / | + | |
- | </ | + | |
- | en | + | Command (m for help): t |
+ | Partition number (1-12, default 12): 7 | ||
+ | Hex code or alias (type L to list all): 8e | ||
- | < | + | Changed type of partition ' |
- | #exec / | + | |
- | </ | + | |
- | ====Renforcer la sécurité du Noyau==== | + | Command (m for help): t |
+ | Partition number (1-12, default 12): 8 | ||
+ | Hex code or alias (type L to list all): fd | ||
- | ===La commande sysctl=== | + | Changed type of partition ' |
- | Les fichiers dans le répertoire **/ | + | Command (m for help): t |
+ | Partition number (1-12, default 12): 9 | ||
+ | Hex code or alias (type L to list all): 8e | ||
- | La commande **sysctl** applique les règles consignés dans le fichier **/ | + | Changed type of partition ' |
- | Saisissez la commande | + | Command (m for help): t |
+ | Partition number (1-12, default 12): 10 | ||
+ | Hex code or alias (type L to list all): fd | ||
- | < | + | Changed type of partition ' |
- | [root@centos7 ~]# cat / | + | |
- | # System default settings live in / | + | |
- | # To override those settings, enter new settings here, or in an / | + | |
- | # | + | |
- | # For more information, | + | |
- | [root@centos7 ~]# cat / | + | Command (m for help): t |
- | # Kernel sysctl configuration file | + | Partition number (1-12, default 12): 11 |
- | # | + | Hex code or alias (type L to list all): fd |
- | # For binary values, 0 is disabled, 1 is enabled. | + | |
- | # sysctl.conf(5) for more details. | + | |
- | # Disable netfilter on bridges. | + | Changed type of partition ' |
- | net.bridge.bridge-nf-call-ip6tables = 0 | + | |
- | net.bridge.bridge-nf-call-iptables = 0 | + | |
- | net.bridge.bridge-nf-call-arptables = 0 | + | |
- | # Controls the maximum shared segment size, in bytes | + | Command (m for help): |
- | kernel.shmmax = 4294967295 | + | </ |
- | # Controls the maximum number of shared memory segments, in pages | + | A l'issu des modifications, vous obtiendrez un résultat similaire à celui-ci : |
- | [root@centos7 ~]# ls -l /etc/ | + | < |
- | total 0 | + | Command (m for help): p |
- | lrwxrwxrwx. | + | Disk /dev/sdb: 32 GiB, 34359738368 bytes, 67108864 sectors |
+ | Disk model: QEMU HARDDISK | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disklabel type: dos | ||
+ | Disk identifier: 0x23a56c2e | ||
- | [root@centos7 ~]# cat /etc/sysctl.d/99-sysctl.conf | + | Device |
- | # System default settings live in /usr/lib/sysctl.d/00-system.conf. | + | /dev/sdb1 2048 |
- | # To override those settings, enter new settings here, or in an /etc/sysctl.d/< | + | /dev/ |
- | # | + | /dev/sdb3 411648 |
- | # For more information, | + | /dev/sdb4 616448 67108863 66492416 31.7G 5 Extended |
+ | /dev/sdb5 618496 | ||
+ | /dev/ | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | |||
+ | Command | ||
</ | </ | ||
- | ==Options de la commande== | + | Pour écrire la nouvelle table des partitions sur disque, vous devez utilisez la commande **w** puis la commande |
- | Les options de la commande | + | < |
+ | Command (m for help): w | ||
+ | The partition table has been altered. | ||
+ | Calling ioctl() to re-read partition table. | ||
+ | Syncing disks. | ||
+ | |||
+ | [root@redhat9 ~]# partprobe | ||
+ | [root@redhat9 ~]# | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Pour créer des partition GPT, RedHat 9 possède l' | ||
+ | </ | ||
+ | |||
+ | ====Options de la Commande fdisk==== | ||
+ | |||
+ | Les options de cette commande | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
Usage: | Usage: | ||
- | sysctl | + | fdisk [options] |
+ | | ||
+ | |||
+ | Display or manipulate a disk partition table. | ||
Options: | Options: | ||
- | | + | -b, --sector-size < |
- | -A alias of -a | + | -B, --protect-boot |
- | -X alias of -a | + | -c, --compatibility[=< |
- | --deprecated | + | -L, --color[=< |
- | -b, --binary | + | |
- | -e, --ignore | + | -l, --list display partitions and exit |
- | -N, --names print variable names without values | + | -x, --list-details |
- | -n, --values | + | -n, --noauto-pt |
- | -p, --load[=<file>] read values from file | + | -o, --output < |
- | -f | + | -t, --type < |
- | --system | + | -u, --units[=<unit>] |
- | -r, --pattern | + | -s, --getsz |
- | | + | |
- | -q, --quiet | + | |
- | -w, --write enable writing a value to variable | + | -w, --wipe < |
- | -o does nothing | + | -W, --wipe-partitions < |
- | | + | |
- | | + | |
- | -h, --help | + | -C, --cylinders < |
- | -V, --version | + | -H, --heads < |
+ | -S, --sectors < | ||
- | For more details see sysctl(8). | + | -h, --help |
+ | -V, --version | ||
+ | |||
+ | Available output columns: | ||
+ | gpt: Device Start End Sectors Size Type Type-UUID Attrs Name UUID | ||
+ | dos: Device Start End Sectors Cylinders Size Type Id Attrs Boot End-C/H/S Start-C/ | ||
+ | bsd: Slice Start End Sectors Cylinders Size Type Bsize Cpg Fsize | ||
+ | sgi: Device Start End Sectors Cylinders Size Type Id Attrs | ||
+ | sun: Device Start End Sectors Cylinders Size Type Id Flags | ||
+ | |||
+ | For more details see fdisk(8). | ||
</ | </ | ||
- | <WRAP center round important 50%> | + | =====Logical Volume Manager (LVM)===== |
- | **Important** : Consultez la page de la traduction du manuel de **sysctl** **[[http:// | + | |
- | </ | + | |
- | =====LAB #1 - System Hardening à l'aide de l' | + | ====LAB #3 - Volumes Logiques Linéaires==== |
- | ====Présentation==== | + | Afin de mettre en place le LVM, vous avez besoin du paquet **lvm2** et du paquet **device-mapper**. |
- | Bastille Linux est un script interactif de renforcement de la sécurité pour certaines distributions de Linux dont %%RHEL%%, %%CentOS%% et Debian. | + | Nous allons travailler sous RedHat 9 avec les partitions suivantes : |
- | ====Installation==== | + | < |
+ | / | ||
+ | / | ||
+ | / | ||
+ | </ | ||
- | Installez | + | Pour initialiser |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | [root@centos7 ~]# rpm -ivh epel-release-latest-7.noarch.rpm | + | Found volume group " |
</ | </ | ||
- | Commencez par installer la dépendance | + | Les options |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | vgscan - Search for all volume groups | ||
+ | |||
+ | vgscan | ||
+ | [ --ignorelockingfailure ] | ||
+ | [ --mknodes ] | ||
+ | [ --notifydbus ] | ||
+ | [ --reportformat basic|json|json_std ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Common options for lvm: | ||
+ | [ -d|--debug ] | ||
+ | [ -h|--help ] | ||
+ | [ -q|--quiet ] | ||
+ | [ -v|--verbose ] | ||
+ | [ -y|--yes ] | ||
+ | [ -t|--test ] | ||
+ | [ --commandprofile String ] | ||
+ | [ --config String ] | ||
+ | [ --driverloaded y|n ] | ||
+ | [ --nolocking ] | ||
+ | [ --lockopt String ] | ||
+ | [ --longhelp ] | ||
+ | [ --profile String ] | ||
+ | [ --version ] | ||
+ | [ --devicesfile String ] | ||
+ | [ --devices PV ] | ||
+ | [ --nohints ] | ||
+ | [ --journal String ] | ||
+ | |||
+ | Common variables for lvm: | ||
+ | Variables in option or position args are capitalized, | ||
+ | e.g. PV, VG, LV, Size, Number, String, Tag. | ||
+ | |||
+ | PV | ||
+ | Physical Volume name, a device path under /dev. | ||
+ | For commands managing physical extents, a PV positional arg | ||
+ | generally accepts a suffix indicating a range (or multiple ranges) | ||
+ | of PEs. When the first PE is omitted, it defaults to the start of | ||
+ | the device, and when the last PE is omitted it defaults to the end. | ||
+ | PV[: | ||
+ | PV[: | ||
+ | |||
+ | LV | ||
+ | Logical Volume name. See lvm(8) for valid names. An LV positional | ||
+ | arg generally includes the VG name and LV name, e.g. VG/LV. | ||
+ | LV followed by _< | ||
+ | required. (raid represents raid< | ||
+ | The _new suffix indicates that the LV name is new. | ||
+ | |||
+ | Tag | ||
+ | Tag name. See lvm(8) for information about tag names and using | ||
+ | tags in place of a VG, LV or PV. | ||
+ | |||
+ | Select | ||
+ | Select indicates that a required positional arg can be omitted | ||
+ | if the --select option is used. No arg appears in this position. | ||
+ | |||
+ | Size[UNIT] | ||
+ | Size is an input number that accepts an optional unit. | ||
+ | Input units are always treated as base two values, regardless of | ||
+ | capitalization, | ||
+ | The default input unit is specified by letter, followed by |UNIT. | ||
+ | UNIT represents other possible input units: BbBsSkKmMgGtTpPeE. | ||
+ | (This should not be confused with the output control --units, where | ||
+ | capital letters mean multiple of 1000.) | ||
</ | </ | ||
- | Téléchargez et installez Bastille | + | ===Physical Volume (PV)=== |
+ | |||
+ | Pour créer le **PV** il convient d' | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | Physical volume "/ | ||
+ | Physical volume "/ | ||
+ | Physical volume "/ | ||
</ | </ | ||
+ | |||
+ | Les options de la commande **pvcreate** sont : | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | pvcreate - Initialize physical volume(s) for use by LVM | ||
+ | |||
+ | pvcreate PV ... | ||
+ | [ -f|--force ] | ||
+ | [ -M|--metadatatype lvm2 ] | ||
+ | [ -u|--uuid String ] | ||
+ | [ -Z|--zero y|n ] | ||
+ | [ --dataalignment Size[k|UNIT] ] | ||
+ | [ --dataalignmentoffset Size[k|UNIT] ] | ||
+ | [ --bootloaderareasize Size[m|UNIT] ] | ||
+ | [ --labelsector Number ] | ||
+ | [ --pvmetadatacopies 0|1|2 ] | ||
+ | [ --metadatasize Size[m|UNIT] ] | ||
+ | [ --metadataignore y|n ] | ||
+ | [ --norestorefile ] | ||
+ | [ --setphysicalvolumesize Size[m|UNIT] ] | ||
+ | [ --reportformat basic|json|json_std ] | ||
+ | [ --restorefile String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Common options for lvm: | ||
+ | [ -d|--debug ] | ||
+ | [ -h|--help ] | ||
+ | [ -q|--quiet ] | ||
+ | [ -v|--verbose ] | ||
+ | [ -y|--yes ] | ||
+ | [ -t|--test ] | ||
+ | [ --commandprofile String ] | ||
+ | [ --config String ] | ||
+ | [ --driverloaded y|n ] | ||
+ | [ --nolocking ] | ||
+ | [ --lockopt String ] | ||
+ | [ --longhelp ] | ||
+ | [ --profile String ] | ||
+ | [ --version ] | ||
+ | [ --devicesfile String ] | ||
+ | [ --devices PV ] | ||
+ | [ --nohints ] | ||
+ | [ --journal String ] | ||
+ | |||
+ | Common variables for lvm: | ||
+ | Variables in option or position args are capitalized, | ||
+ | e.g. PV, VG, LV, Size, Number, String, Tag. | ||
+ | |||
+ | PV | ||
+ | Physical Volume name, a device path under /dev. | ||
+ | For commands managing physical extents, a PV positional arg | ||
+ | generally accepts a suffix indicating a range (or multiple ranges) | ||
+ | of PEs. When the first PE is omitted, it defaults to the start of | ||
+ | the device, and when the last PE is omitted it defaults to the end. | ||
+ | PV[: | ||
+ | PV[: | ||
+ | |||
+ | LV | ||
+ | Logical Volume name. See lvm(8) for valid names. An LV positional | ||
+ | arg generally includes the VG name and LV name, e.g. VG/LV. | ||
+ | LV followed by _< | ||
+ | required. (raid represents raid< | ||
+ | The _new suffix indicates that the LV name is new. | ||
+ | |||
+ | Tag | ||
+ | Tag name. See lvm(8) for information about tag names and using | ||
+ | tags in place of a VG, LV or PV. | ||
+ | |||
+ | Select | ||
+ | Select indicates that a required positional arg can be omitted | ||
+ | if the --select option is used. No arg appears in this position. | ||
+ | |||
+ | Size[UNIT] | ||
+ | Size is an input number that accepts an optional unit. | ||
+ | Input units are always treated as base two values, regardless of | ||
+ | capitalization, | ||
+ | The default input unit is specified by letter, followed by |UNIT. | ||
+ | UNIT represents other possible input units: BbBsSkKmMgGtTpPeE. | ||
+ | (This should not be confused with the output control --units, where | ||
+ | capital letters mean multiple of 1000.) | ||
</ | </ | ||
- | Dernièrement créez un lien symbolique | + | Pour visualiser les PVs il convient d' |
< | < | ||
- | [root@centos7 /]# ln -s /usr/lib/Bastille | + | [root@redhat9 ~]# pvdisplay /dev/sdb6 /dev/sdb7 /dev/sdb9 |
+ | "/ | ||
+ | | ||
+ | PV Name /dev/sdb6 | ||
+ | VG Name | ||
+ | PV Size | ||
+ | Allocatable | ||
+ | PE Size | ||
+ | Total PE 0 | ||
+ | Free PE 0 | ||
+ | Allocated PE 0 | ||
+ | PV UUID | ||
+ | |||
+ | "/dev/sdb7" is a new physical volume of " | ||
+ | --- NEW Physical volume --- | ||
+ | PV Name /dev/sdb7 | ||
+ | VG Name | ||
+ | PV Size | ||
+ | Allocatable | ||
+ | PE Size | ||
+ | Total PE 0 | ||
+ | Free PE 0 | ||
+ | Allocated PE 0 | ||
+ | PV UUID | ||
+ | |||
+ | "/ | ||
+ | --- NEW Physical volume --- | ||
+ | PV Name / | ||
+ | VG Name | ||
+ | PV Size | ||
+ | Allocatable | ||
+ | PE Size | ||
+ | Total PE 0 | ||
+ | Free PE 0 | ||
+ | Allocated PE 0 | ||
+ | PV UUID | ||
</ | </ | ||
- | ===Utilisation=== | + | Les options de la commande **pvdisplay** sont : |
- | Pour démarrez bastille en mode texte, saisissez la commande suivante : | + | < |
+ | [root@redhat9 ~]# pvdisplay --longhelp | ||
+ | pvdisplay - Display various attributes of physical volume(s) | ||
- | | + | |
+ | [ -a|--all ] | ||
+ | [ -c|--colon ] | ||
+ | [ -C|--columns ] | ||
+ | [ -m|--maps ] | ||
+ | [ -o|--options String ] | ||
+ | [ -S|--select String ] | ||
+ | [ -s|--short ] | ||
+ | [ -O|--sort String ] | ||
+ | [ --aligned ] | ||
+ | [ --binary ] | ||
+ | [ --configreport log|vg|lv|pv|pvseg|seg ] | ||
+ | [ --foreign ] | ||
+ | [ --ignorelockingfailure ] | ||
+ | [ --logonly ] | ||
+ | [ --noheadings ] | ||
+ | [ --nosuffix ] | ||
+ | [ --readonly ] | ||
+ | [ --reportformat basic|json|json_std ] | ||
+ | [ --separator String ] | ||
+ | [ --shared ] | ||
+ | [ --unbuffered ] | ||
+ | [ --units [Number]r|R|h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | | ||
- | Pour démarrez bastille en mode graphique, saisissez la commande suivante | + | Common options for lvm: |
+ | [ -d|--debug ] | ||
+ | [ -h|--help ] | ||
+ | [ -q|--quiet ] | ||
+ | [ -v|--verbose ] | ||
+ | [ -y|--yes ] | ||
+ | [ -t|--test ] | ||
+ | [ --commandprofile String ] | ||
+ | [ --config String ] | ||
+ | [ --driverloaded y|n ] | ||
+ | [ --nolocking ] | ||
+ | [ --lockopt String ] | ||
+ | [ --longhelp ] | ||
+ | [ --profile String ] | ||
+ | [ --version ] | ||
+ | [ --devicesfile String ] | ||
+ | [ --devices PV ] | ||
+ | [ --nohints ] | ||
+ | [ --journal String ] | ||
- | | + | |
+ | Variables in option or position args are capitalized, | ||
+ | e.g. PV, VG, LV, Size, Number, String, Tag. | ||
- | <WRAP center round todo 50%> | + | PV |
- | **A Faire** - Lancez Bastille et répondez aux questions posées. Ré-amorcez votre machine virtuelle et testez le résultat. | + | |
- | </ | + | For commands managing physical extents, a PV positional arg |
+ | generally accepts a suffix indicating a range (or multiple ranges) | ||
+ | of PEs. When the first PE is omitted, it defaults to the start of | ||
+ | the device, and when the last PE is omitted it defaults to the end. | ||
+ | PV[:PE-PE]... is start and end range (inclusive), | ||
+ | | ||
- | =====LAB #2 - Mise en place de SELinux pour sécuriser le serveur===== | + | LV |
+ | Logical Volume name. See lvm(8) for valid names. An LV positional | ||
+ | arg generally includes the VG name and LV name, e.g. VG/LV. | ||
+ | LV followed by _< | ||
+ | required. (raid represents raid< | ||
+ | The _new suffix indicates that the LV name is new. | ||
- | ====Introducton==== | + | Tag |
+ | Tag name. See lvm(8) for information about tag names and using | ||
+ | tags in place of a VG, LV or PV. | ||
- | L' | + | Select |
- | ur | + | |
- | ^ Type de Sécurité ^ Nom ^ Description ^ | + | if the --select option is used. No arg appears in this position. |
- | | TE | //Type enforcement// | + | |
- | | RBAC | //Role Based Access Control// | + | |
- | | MAC | //Mandatory Access Control// | + | |
- | | MLS | // | + | |
- | Même quand le modèle %%SELinux%% de sécurité est actif, la sécurité type DAC est toujours active. Cependant dans le cas où la sécurité du type DAC autorise une action, %%SELinux%% va évaluer cette action par rapport à ses propres règles avant de l'autoriser. | + | Size[UNIT] |
+ | Size is an input number that accepts an optional unit. | ||
+ | Input units are always treated as base two values, regardless of | ||
+ | capitalization, | ||
+ | The default input unit is specified by letter, followed by |UNIT. | ||
+ | UNIT represents other possible input units: BbBsSkKmMgGtTpPeE. | ||
+ | (This should not be confused with the output control --units, where | ||
+ | capital letters mean multiple of 1000.) | ||
+ | </ | ||
- | %%SELinux%% évalue toujours des **// | + | ===Volume Group (VG) et Physical Extent (PE)=== |
- | Dans le contexte de %%SELinux%% | + | Pour créer un Volume Group dénommé **vg0**, il convient d' |
- | * un **//sujet//** est toujours un **processus**, | + | < |
- | * un **//objet//** peut être un fichier, un répertoire, | + | [root@redhat9 ~]# vgcreate -s 8M vg0 /dev/sdb6 /dev/sdb7 /dev/sdb9 |
- | | + | |
+ | </code> | ||
- | Chaque **//classe d' | + | Les options |
- | ====Définitions==== | + | < |
+ | [root@redhat9 ~]# vgcreate --help | ||
+ | vgcreate - Create a volume group | ||
- | ===Security Context=== | + | vgcreate VG_new PV ... |
+ | [ -A|--autobackup y|n ] | ||
+ | [ -c|--clustered y|n ] | ||
+ | [ -l|--maxlogicalvolumes Number ] | ||
+ | [ -p|--maxphysicalvolumes Number ] | ||
+ | [ -M|--metadatatype lvm2 ] | ||
+ | [ -s|--physicalextentsize Size[m|UNIT] ] | ||
+ | [ -f|--force ] | ||
+ | [ -Z|--zero y|n ] | ||
+ | [ --addtag Tag ] | ||
+ | [ --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit ] | ||
+ | [ --metadataprofile String ] | ||
+ | [ --labelsector Number ] | ||
+ | [ --metadatasize Size[m|UNIT] ] | ||
+ | [ --pvmetadatacopies 0|1|2 ] | ||
+ | [ --vgmetadatacopies all|unmanaged|Number ] | ||
+ | [ --reportformat basic|json|json_std ] | ||
+ | [ --dataalignment Size[k|UNIT] ] | ||
+ | [ --dataalignmentoffset Size[k|UNIT] ] | ||
+ | [ --shared ] | ||
+ | [ --systemid String ] | ||
+ | [ --locktype sanlock|dlm|none ] | ||
+ | [ --setautoactivation y|n ] | ||
+ | [ COMMON_OPTIONS ] | ||
- | %%SELinux%% associe un //Security Context// (SC) à chaque **// | + | Common options for lvm: |
+ | [ -d|--debug ] | ||
+ | [ -h|--help ] | ||
+ | [ -q|--quiet ] | ||
+ | [ -v|--verbose ] | ||
+ | [ -y|--yes ] | ||
+ | [ -t|--test ] | ||
+ | [ --commandprofile String ] | ||
+ | [ --config String ] | ||
+ | [ --driverloaded y|n ] | ||
+ | [ --nolocking ] | ||
+ | [ --lockopt String ] | ||
+ | [ --longhelp ] | ||
+ | [ --profile String ] | ||
+ | [ --version ] | ||
+ | [ --devicesfile String ] | ||
+ | [ --devices PV ] | ||
+ | [ --nohints ] | ||
+ | [ --journal String ] | ||
- | Un SC prend la forme **identité: | + | Use --longhelp to show all options and advanced commands. |
+ | </ | ||
- | ^ Nom ^ Descriptions ^ | + | Pour afficher les informations concernant |
- | | Identité | Le nom du propriétaire de l' | + | |
- | | Rôle | Essentiellement appliqué aux processus, le rôle est appelé une domaine. Dans le cas d'un rôle de fichier, celui-ci est toujours **object_r**. Un rôle se termine généralement par **_r**. | | + | |
- | | Type | Définit | + | |
- | | Niveau | Un niveau est un attribut de MLS et MCS. Une plage MLS est une paire de niveaux exprimée en utilisant la syntaxe // | + | |
- | Sous RHEL/CentOS 7, le fichier **/etc/selinux/targeted/setrans.conf** contient la correspondance entre les niveaux et leurs valeurs compréhensibles par l' | + | < |
+ | [root@redhat9 ~]# vgdisplay vg0 | ||
+ | --- Volume group --- | ||
+ | VG Name vg0 | ||
+ | System ID | ||
+ | Format | ||
+ | Metadata Areas 3 | ||
+ | Metadata Sequence No 1 | ||
+ | VG Access | ||
+ | VG Status | ||
+ | MAX LV 0 | ||
+ | Cur LV 0 | ||
+ | Open LV 0 | ||
+ | Max PV 0 | ||
+ | Cur PV 3 | ||
+ | Act PV 3 | ||
+ | VG Size | ||
+ | PE Size 8.00 MiB | ||
+ | Total PE 110 | ||
+ | Alloc PE / Size | ||
+ | Free PE / Size | ||
+ | VG UUID | ||
+ | </ | ||
+ | |||
+ | Les options de la commande | ||
< | < | ||
- | [root@centos7 /]# cat / | + | [root@redhat9 ~]# vgdisplay --help |
- | # | + | |
- | # Multi-Category Security translation table for SELinux | + | |
- | # | + | vgdisplay |
- | # Uncomment the following to disable translation libary | + | [ -A|--activevolumegroups ] |
- | # disable=1 | + | [ -c|--colon ] |
- | # | + | [ -C|--columns ] |
- | # Objects can be categorized with 0-1023 categories defined by the admin. | + | [ -o|--options String ] |
- | # Objects can be in more than one category at a time. | + | [ -S|--select String ] |
- | # Categories are stored in the system as c0-c1023. | + | |
- | # table to translate the categories into a more meaningful output. | + | [ -O|--sort String ] |
- | # Examples: | + | |
- | # s0:c0=CompanyConfidential | + | |
- | # s0: | + | [ --configreport log|vg|lv|pv|pvseg|seg ] |
- | # s0: | + | [ --foreign ] |
- | # s0: | + | [ --ignorelockingfailure ] |
- | # s0: | + | [ --logonly ] |
- | s0=SystemLow | + | [ --noheadings ] |
- | s0-s0: | + | [ --nosuffix ] |
- | s0:c0.c1023=SystemHigh | + | [ --readonly ] |
+ | [ --shared ] | ||
+ | [ --separator String ] | ||
+ | [ --unbuffered ] | ||
+ | [ --units [Number]r|R|h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ VG|Tag | ||
+ | |||
+ | | ||
+ | [ -d|--debug ] | ||
+ | [ -h|--help ] | ||
+ | [ -q|--quiet ] | ||
+ | [ -v|--verbose ] | ||
+ | [ -y|--yes ] | ||
+ | | ||
+ | | ||
+ | [ --config String ] | ||
+ | [ --driverloaded y|n ] | ||
+ | [ --nolocking ] | ||
+ | [ --lockopt String ] | ||
+ | [ --longhelp ] | ||
+ | [ --profile String ] | ||
+ | [ --version ] | ||
+ | [ --devicesfile String ] | ||
+ | [ --devices PV ] | ||
+ | [ --nohints ] | ||
+ | [ --journal String ] | ||
+ | |||
+ | Use --longhelp to show all options and advanced commands. | ||
</ | </ | ||
- | Dans le contexte d'un SC pour un **// | + | ===Logical Volumes (LV)=== |
- | Dans le contexte d'un SC pour un **//objet//**, le champ **identité** indique à quel utilisateur %%SELinux%% appartient l'**//objet//**. | + | Pour créer |
- | %%SELinux%% maintient sa propre liste d' | + | < |
+ | [root@redhat9 ~]# lvcreate -L 350 -n lv0 vg0 | ||
+ | Rounding up size to full physical extent 352.00 MiB | ||
+ | Logical volume " | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** -Notez que la taille du LV est un multiple du PE. | ||
+ | </ | ||
+ | |||
+ | Les options | ||
< | < | ||
- | [root@centos7 /]# / | + | [root@redhat9 ~]# lvcreate |
+ | lvcreate - Create a logical volume | ||
- | Login Name | + | Create a linear LV. |
+ | lvcreate -L|--size Size[m|UNIT] VG | ||
+ | [ --type linear ] (implied) | ||
+ | [ -l|--extents Number[PERCENT] ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
- | __default__ | + | Create a striped LV. |
- | root | + | |
- | system_u | + | |
- | </ | + | [ -l|--extents Number[PERCENT] ] |
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
- | ===Domains et Types=== | + | Create a raid1 or mirror LV. |
+ | lvcreate -m|--mirrors Number -L|--size Size[m|UNIT] VG | ||
+ | [ --type raid1|mirror ] (implied) | ||
+ | [ -l|--extents Number[PERCENT] ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -R|--regionsize Size[m|UNIT] ] | ||
+ | [ --mirrorlog core|disk ] | ||
+ | [ --minrecoveryrate Size[k|UNIT] ] | ||
+ | [ --maxrecoveryrate Size[k|UNIT] ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
- | Le **Domain** est l' | + | Create a raid LV (a specific raid level must be used, e.g. raid1). |
+ | lvcreate --type raid -L|--size Size[m|UNIT] VG | ||
+ | [ -l|--extents Number[PERCENT] ] | ||
+ | [ -i|--stripes Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -m|--mirrors Number ] | ||
+ | [ -R|--regionsize Size[m|UNIT] ] | ||
+ | [ --minrecoveryrate Size[k|UNIT] ] | ||
+ | [ --maxrecoveryrate Size[k|UNIT] ] | ||
+ | [ --raidintegrity y|n ] | ||
+ | [ --raidintegritymode String ] | ||
+ | [ --raidintegrityblocksize Number ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
- | Le **Domain** contient des **// | + | Create a raid10 LV. |
+ | lvcreate -m|--mirrors Number -i|--stripes Number -L|--size Size[m|UNIT] VG | ||
+ | [ --type raid10 ] (implied) | ||
+ | [ -l|--extents Number[PERCENT] ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -R|--regionsize Size[m|UNIT] ] | ||
+ | [ --minrecoveryrate Size[k|UNIT] ] | ||
+ | [ --maxrecoveryrate Size[k|UNIT] ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
- | Dans %%SELinux%% on utilise le mot : | + | Create a COW snapshot LV of an origin LV. |
+ | lvcreate -s|--snapshot -L|--size Size[m|UNIT] LV | ||
+ | [ --type snapshot ] (implied) | ||
+ | [ -l|--extents Number[PERCENT] ] | ||
+ | [ -i|--stripes Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
- | | + | |
- | | + | |
+ | [ -l|--extents Number[PERCENT] ] | ||
+ | [ -i|--stripes Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -T|--thin ] | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ --thinpool LV_new ] | ||
+ | [ --discards passdown|nopassdown|ignore ] | ||
+ | [ --errorwhenfull y|n ] | ||
+ | [ --poolmetadatasize Size[m|UNIT] ] | ||
+ | [ --poolmetadataspare y|n ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
- | ===Roles=== | + | Create a cache pool. |
+ | lvcreate --type cache-pool -L|--size Size[m|UNIT] VG | ||
+ | [ -l|--extents Number[PERCENT] ] | ||
+ | [ -i|--stripes Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -H|--cache ] | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ --cachemode writethrough|writeback|passthrough ] | ||
+ | [ --cachepolicy String ] | ||
+ | [ --cachesettings String ] | ||
+ | [ --cachemetadataformat auto|1|2 ] | ||
+ | [ --poolmetadatasize Size[m|UNIT] ] | ||
+ | [ --poolmetadataspare y|n ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
- | Un **Rôle** est comme un utilisateur dans le système de sécurité DAC de Linux. Chaque utilisateur autorisé peut assumer l' | + | Create a thin LV in a thin pool. |
+ | lvcreate -V|--virtualsize Size[m|UNIT] --thinpool LV VG | ||
+ | [ --type thin ] (implied) | ||
+ | [ -T|--thin ] | ||
+ | [ COMMON_OPTIONS ] | ||
- | ===Politiques de Sécurité=== | + | Create a thin LV that is a snapshot of an existing thin LV. |
+ | lvcreate -s|--snapshot LV | ||
+ | [ --type thin ] (implied) | ||
+ | [ -T|--thin ] | ||
+ | [ COMMON_OPTIONS ] | ||
- | Une politique de sécurité définit les SC de chaque application. Elle définit des droits d' | + | Create |
+ | lvcreate --type thin --thinpool LV LV | ||
+ | [ -T|--thin ] | ||
+ | [ COMMON_OPTIONS ] | ||
- | ^ Politique ^ Description ^ | + | Create a LV that returns VDO when used. |
- | | targeted | + | |
- | | mls | Multi Level Security protection | + | [ -l|--extents Number[PERCENT] ] |
+ | [ -i|--stripes Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -V|--virtualsize Size[m|UNIT] ] | ||
+ | [ --vdo ] | ||
+ | [ --vdopool LV_new ] | ||
+ | [ --compression y|n ] | ||
+ | [ --deduplication y|n ] | ||
+ | [ --vdosettings String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
- | Les politiques de sécurité se trouvent dans le répertoire **/etc/selinux** | + | Create a new LV, then attach the specified cachepool |
+ | which converts the new LV to type cache. | ||
+ | lvcreate --type cache -L|--size Size[m|UNIT] --cachepool LV VG | ||
+ | [ -l|--extents Number[PERCENT] ] | ||
+ | [ -i|--stripes Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -H|--cache ] | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ --cachemode writethrough|writeback|passthrough ] | ||
+ | [ --cachepolicy String ] | ||
+ | [ --cachesettings String ] | ||
+ | [ --cachemetadataformat auto|1|2 ] | ||
+ | [ --poolmetadatasize Size[m|UNIT] ] | ||
+ | [ --poolmetadataspare y|n ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Create a new LV, then attach the specified cachevol | ||
+ | which converts the new LV to type cache. | ||
+ | lvcreate --type cache -L|--size Size[m|UNIT] --cachevol LV VG | ||
+ | [ -l|--extents Number[PERCENT] ] | ||
+ | [ -i|--stripes Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ --cachemode writethrough|writeback|passthrough ] | ||
+ | [ --cachepolicy String ] | ||
+ | [ --cachesettings String ] | ||
+ | [ --cachemetadataformat auto|1|2 ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Create a new LV, then attach a cachevol created from | ||
+ | the specified cache device, which converts the | ||
+ | new LV to type cache. | ||
+ | lvcreate --type cache -L|--size Size[m|UNIT] --cachedevice PV VG | ||
+ | [ -l|--extents Number[PERCENT] ] | ||
+ | [ -i|--stripes Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ --cachesize Size[m|UNIT] ] | ||
+ | [ --cachemode writethrough|writeback|passthrough ] | ||
+ | [ --cachepolicy String ] | ||
+ | [ --cachesettings String ] | ||
+ | [ --cachemetadataformat auto|1|2 ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Create a new LV, then attach the specified cachevol | ||
+ | which converts the new LV to type writecache. | ||
+ | lvcreate --type writecache -L|--size Size[m|UNIT] --cachevol LV VG | ||
+ | [ -l|--extents Number[PERCENT] ] | ||
+ | [ -i|--stripes Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ --cachesettings String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Create a new LV, then attach a cachevol created from | ||
+ | the specified cache device, which converts the | ||
+ | new LV to type writecache. | ||
+ | lvcreate --type writecache -L|--size Size[m|UNIT] --cachedevice PV VG | ||
+ | [ -l|--extents Number[PERCENT] ] | ||
+ | [ -i|--stripes Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ --cachesize Size[m|UNIT] ] | ||
+ | [ --cachesettings String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Common options for command: | ||
+ | [ -a|--activate y|n|ay ] | ||
+ | [ -A|--autobackup y|n ] | ||
+ | [ -C|--contiguous y|n ] | ||
+ | [ -M|--persistent y|n ] | ||
+ | [ -j|--major Number ] | ||
+ | [ -k|--setactivationskip y|n ] | ||
+ | [ -K|--ignoreactivationskip ] | ||
+ | [ -n|--name String ] | ||
+ | [ -p|--permission rw|r ] | ||
+ | [ -r|--readahead auto|none|Number ] | ||
+ | [ -W|--wipesignatures y|n ] | ||
+ | [ -Z|--zero y|n ] | ||
+ | [ --addtag Tag ] | ||
+ | [ --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit ] | ||
+ | [ --setautoactivation y|n ] | ||
+ | [ --ignoremonitoring ] | ||
+ | [ --metadataprofile String ] | ||
+ | [ --minor Number ] | ||
+ | [ --monitor y|n ] | ||
+ | [ --nosync ] | ||
+ | [ --noudevsync ] | ||
+ | [ --reportformat basic|json|json_std ] | ||
+ | |||
+ | Common options for lvm: | ||
+ | [ -d|--debug ] | ||
+ | [ -h|--help ] | ||
+ | [ -q|--quiet ] | ||
+ | [ -v|--verbose ] | ||
+ | [ -y|--yes ] | ||
+ | [ -t|--test ] | ||
+ | [ --commandprofile String ] | ||
+ | [ --config String ] | ||
+ | [ --driverloaded y|n ] | ||
+ | [ --nolocking ] | ||
+ | [ --lockopt String ] | ||
+ | [ --longhelp ] | ||
+ | [ --profile String ] | ||
+ | [ --version ] | ||
+ | [ --devicesfile String ] | ||
+ | [ --devices PV ] | ||
+ | [ --nohints ] | ||
+ | [ --journal String ] | ||
+ | |||
+ | Use --longhelp to show all options and advanced commands. | ||
+ | </code> | ||
+ | |||
+ | Créez maintenant un répertoire dans /mnt pour monter lv0 : | ||
< | < | ||
- | [root@centos7 /]# ls -lR /etc/selinux/ | more | + | [root@redhat9 ~]# mkdir /mnt/lvm |
- | /etc/ | + | </code> |
- | total 12 | + | |
- | -rw-r--r--. 1 root root 547 Dec 10 2015 config | + | |
- | drwx------. 2 root root 6 Apr 23 16:24 final | + | |
- | -rw-r--r--. 1 root root 2321 Aug 4 2017 semanage.conf | + | |
- | drwxr-xr-x. 7 root root 4096 Apr 23 16:24 targeted | + | |
- | drwxr-xr-x. 2 root root 6 Aug 4 2017 tmp | + | |
- | /etc/selinux/final: | + | Créez un système de fichiers en **ext3** sur /dev/vg0/lv0 : |
- | total 0 | + | |
- | /etc/selinux/targeted: | + | < |
- | total 24 | + | [root@redhat9 ~]# mke2fs -j /dev/vg0/lv0 |
- | drwx------. 3 root root 4096 Apr 23 16:24 active | + | mke2fs |
- | -rw-r--r--. | + | Discarding device blocks: done |
- | drwxr-xr-x. 4 root root 4096 Apr 23 16:20 contexts | + | Creating filesystem with 360448 1k blocks and 90112 inodes |
- | drwxr-xr-x. 2 root root 6 Mar 7 15:19 logins | + | Filesystem UUID: 34d451f7-96c2-43b1-8cc0-9fe8bafcf498 |
- | drwxr-xr-x. 3 root root 19 Apr 23 16:41 modules | + | Superblock backups stored on blocks: |
- | drwxr-xr-x. 2 root root 22 Apr 23 16:41 policy | + | 8193, 24577, 40961, 57345, 73729, 204801, 221185 |
- | -rw-------. 1 root root 0 Mar 7 14:52 semanage.read.LOCK | + | |
- | -rw-------. 1 root root 0 Mar 7 14:52 semanage.trans.LOCK | + | Allocating group tables: done |
- | -rw-r--r--. 1 root root 607 Mar 7 15:19 setrans.conf | + | Writing inode tables: done |
- | -rw-r--r--. 1 root root 176 Apr 23 16:24 seusers | + | Creating journal (8192 blocks): done |
- | --More-- | + | Writing superblocks and filesystem accounting information: |
</ | </ | ||
- | Afin d' | + | Montez votre lv0 : |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
- | Pour consulter les statistiques | + | Vous allez maintenant copier le contenu |
+ | |||
+ | Saisissez donc la commande | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | </ | ||
- | Statistics for policy file: /sys/fs/selinux/policy | + | Constatez ensuite le contenu de /mnt/lvm : |
- | Policy Version & Type: v.28 (binary, mls) | + | |
- | | + | < |
- | Sensitivities: | + | [root@redhat9 ~]# ls -l /mnt/lvm |
- | Types: | + | total 13 |
- | Users: | + | drwxr-xr-x. 3 root root 1024 Oct 19 2023 home |
- | Booleans: | + | drwx------. 2 root root 12288 Oct 23 15:21 lost+found |
- | Allow: | + | [root@redhat9 ~]# |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
</ | </ | ||
- | <WRAP center round important | + | Une particularité du volume logique est la capacité de d' |
- | **Important** | + | |
+ | < | ||
+ | [root@redhat9 ~]# df -h /mnt/lvm | ||
+ | Filesystem | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Dans la cas de notre exemple, la taille est de **320 Mo** avec **4.4 Mo** occupé. | ||
+ | |||
+ | ====LAB #4 - Etendre un Volume Logique à Chaud==== | ||
+ | |||
+ | Pour agrandir un volume logique, le paquet **lvm2** contient les commandes **lvextend** et **resize2fs** : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# lvextend -L +100M / | ||
+ | Rounding size to boundary between physical extents: 104.00 MiB. | ||
+ | Size of logical volume vg0/lv0 changed from 352.00 MiB (44 extents) to 456.00 MiB (57 extents). | ||
+ | Logical volume vg0/lv0 successfully resized. | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important | ||
+ | **Important** | ||
</ | </ | ||
- | ===Langage | + | Les options |
- | Un politique est composé de centaines de directives. Les principales directives sont : | + | < |
+ | [root@redhat9 ~]# lvextend --help | ||
+ | lvextend - Add space to a logical volume | ||
- | ==allow== | + | Extend an LV by a specified size. |
+ | lvextend -L|--size [+]Size[m|UNIT] LV | ||
+ | [ -l|--extents [+]Number[PERCENT] ] | ||
+ | [ -r|--resizefs ] | ||
+ | [ -i|--stripes Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ --poolmetadatasize [+]Size[m|UNIT] ] | ||
+ | [ --fs String ] | ||
+ | [ --fsmode String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
- | **allow** autorise l' | + | Extend an LV by specified PV extents. |
+ | lvextend LV PV ... | ||
+ | [ -r|--resizefs ] | ||
+ | [ -i|--stripes Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ --fs String ] | ||
+ | [ --fsmode String ] | ||
+ | [ COMMON_OPTIONS ] | ||
- | | + | |
+ | lvextend --poolmetadatasize [+]Size[m|UNIT] LV | ||
+ | [ -i|--stripes Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
- | Dans cette directive : | + | Extend an LV according to a predefined policy. |
+ | lvextend --usepolicies LV | ||
+ | [ -r|--resizefs ] | ||
+ | [ --fs String ] | ||
+ | [ --fsmode String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
- | | + | |
- | * domaine_t est le domaine des processus qui sont autorisés par allow, | + | [ -A|--autobackup y|n ] |
- | * file (droit1 droit2 etc) est la liste des permissions accordées. | + | [ -f|--force ] |
+ | [ -m|--mirrors Number ] | ||
+ | [ -n|--nofsck ] | ||
+ | [ --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit ] | ||
+ | [ --nosync ] | ||
+ | [ --noudevsync ] | ||
+ | [ --reportformat basic|json|json_std ] | ||
+ | [ --type linear|striped|snapshot|raid|mirror|thin|thin-pool|vdo|vdo-pool|cache|cache-pool|writecache ] | ||
- | Les permissions possibles sont : | + | Common options for lvm: |
+ | [ -d|--debug ] | ||
+ | [ -h|--help ] | ||
+ | [ -q|--quiet ] | ||
+ | [ -v|--verbose ] | ||
+ | [ -y|--yes ] | ||
+ | [ -t|--test ] | ||
+ | [ --commandprofile String ] | ||
+ | [ --config String ] | ||
+ | [ --driverloaded y|n ] | ||
+ | [ --nolocking ] | ||
+ | [ --lockopt String ] | ||
+ | [ --longhelp ] | ||
+ | [ --profile String ] | ||
+ | [ --version ] | ||
+ | [ --devicesfile String ] | ||
+ | [ --devices PV ] | ||
+ | [ --nohints ] | ||
+ | [ --journal String ] | ||
- | | + | |
- | * write | + | </ |
- | * append | + | |
- | * execute | + | |
- | * getattr | + | |
- | * setattr | + | |
- | * lock | + | |
- | * link | + | |
- | * unlink | + | |
- | * rename | + | |
- | * ioctl | + | |
- | ==type== | + | Le volume ayant été agrandi, il est necessaire maintenant d' |
- | La directive **type** définit un type %%SELinux%%. Le type se termine généralement par **_t**. | + | < |
+ | [root@redhat9 ~]# resize2fs / | ||
+ | resize2fs 1.46.5 (30-Dec-2021) | ||
+ | Filesystem at / | ||
+ | old_desc_blocks = 2, new_desc_blocks = 2 | ||
+ | The filesystem on / | ||
+ | </ | ||
- | **auditallow, | + | Constatez maintenant la modification de la taille du volume : |
- | La directive **auditallow** demande l' | + | < |
+ | [root@redhat9 ~]# df -h /mnt/lvm | ||
+ | Filesystem | ||
+ | / | ||
+ | </ | ||
- | L' | + | Vous noterez que la taille a augmentée et que les données sont toujours présentes. |
- | ===type_transition=== | + | ====LAB #5 - Snapshots==== |
- | Normalement quand un fichier | + | Un snapshot |
- | ===Décisions | + | Avant de commencer, créez un fichier de 10Mo dans le volume : |
- | Il existe deux types de décisions auxquelles %%SELinux%% doit faire face : | + | < |
+ | [root@redhat9 ~]# dd if=/ | ||
+ | 10+0 records in | ||
+ | 10+0 records out | ||
+ | 10485760 bytes (10 MB, 10 MiB) copied, 0.0239133 s, 438 MB/s | ||
+ | </ | ||
- | * **Décisions d' | + | Créez maintenant un snapshot : |
- | * **Décisions de Transition** | + | |
- | ==Décisions d' | + | < |
+ | [root@redhat9 ~]# lvcreate -s -L 5M -n testsnap / | ||
+ | Rounding up size to full physical extent 8.00 MiB | ||
+ | Logical volume " | ||
+ | </ | ||
- | Dans ce type de décision %%SELinux%% doit décider d' | + | Pour avoir une confirmation |
- | | + | < |
- | | + | [root@redhat9 ~]# lvs |
+ | LV | ||
+ | | ||
+ | swap rhel -wi-ao---- | ||
+ | lv0 vg0 owi-aos--- 456.00m | ||
+ | testsnap vg0 swi-a-s--- | ||
+ | </ | ||
- | ==Décisions de Transition== | + | <WRAP center round important 60%> |
+ | **Important** - Notez que le snapshot est créé dans le même VG que le LV d' | ||
+ | </ | ||
- | Dans ce type de décision %%SELinux%% doit décider d' | + | Les options |
- | * d' | + | < |
- | | + | [root@redhat9 ~]# lvs --help |
+ | | ||
- | ====Commandes SELinux==== | + | lvs |
+ | [ -H|--history ] | ||
+ | [ -a|--all ] | ||
+ | [ -o|--options String ] | ||
+ | [ -S|--select String ] | ||
+ | [ -O|--sort String ] | ||
+ | [ --segments ] | ||
+ | [ --aligned ] | ||
+ | [ --binary ] | ||
+ | [ --configreport log|vg|lv|pv|pvseg|seg ] | ||
+ | [ --foreign ] | ||
+ | [ --headings none|abbrev|full|0|1|2 ] | ||
+ | [ --ignorelockingfailure ] | ||
+ | [ --logonly ] | ||
+ | [ --nameprefixes ] | ||
+ | [ --noheadings ] | ||
+ | [ --nosuffix ] | ||
+ | [ --readonly ] | ||
+ | [ --reportformat basic|json|json_std ] | ||
+ | [ --rows ] | ||
+ | [ --separator String ] | ||
+ | [ --shared ] | ||
+ | [ --unbuffered ] | ||
+ | [ --units [Number]r|R|h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E ] | ||
+ | [ --unquoted ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ VG|LV|Tag ... ] | ||
- | ^ Commande ^ Description ^ | + | Common options for lvm: |
- | | chcon | Changer le SC d'un fichier | + | [ -d|--debug ] |
- | | audit2allow | Générer la source de la règle de sécurité à l' | + | [ -h|--help ] |
- | | restorecon | Restaurer le SC par défaut à un ou plusieurs fichiers | | + | [ -q|--quiet ] |
- | | setfiles | + | [ -v|--verbose ] |
- | | semodule | Gèrer les modules de politiques | | + | [ -y|--yes ] |
- | | semodule | + | [ -t|--test ] |
- | | checkmodule | Compiler un module | | + | |
- | | semodule_package | Créer un module installable par semodule | | + | |
- | | semanage | Administrer une politique | | + | |
- | | audit2allow | + | |
- | | sesearch | Recherche des règles %%SELinux%% | | + | |
- | | seinfo | Effectuer des recherches dans la politique | | + | |
- | | getsebool | Affiche l' | + | |
- | | getsebool | + | |
- | | sestatus | + | |
- | | setsebool | Modifie l' | + | |
- | | togglesebool | Bascule la valeur d'un booléen | | + | |
+ | [ --journal String ] | ||
- | ====Les Etats de SELinux==== | + | Use --longhelp to show all options and advanced commands. |
+ | </ | ||
- | %%SELinux%% connait trois états | + | Créez maintenant un répertoire pour monter le snapshot |
- | ^ Etat ^ Description ^ | + | < |
- | | disabled | %%SELinux%% est inactif. | | + | [root@redhat9 ~]# mkdir / |
- | | permissive | %%SELinux%% est actif mais tout est permis. Des interdictions ne font que de générer des messages d' | + | </ |
- | | enforcing | %%SELinux%% est actif. | | + | |
- | L' | + | Montez le snapshot |
- | ^ Valeur ^ Description ^ | + | < |
- | | 0 | %%SELinux%% est en mode //permissive// | | + | [root@redhat9 ~]# mount /dev/vg0/testsnap |
- | | 1 | %%SELinux%% est en mode // | + | </code> |
- | La configuration de l'activation de %%SELinux%% ainsi que son état est effectuée grâce au fichier **/ | + | Comparez le volume d'origine et le snapshot |
< | < | ||
- | [root@centos7 /]# cat /etc/selinux/config | + | [root@redhat9 ~]# ls -l /mnt/lvm |
+ | total 10294 | ||
+ | -rw-r--r--. 1 root root 10485760 Oct 23 15:27 10M | ||
+ | drwxr-xr-x. 3 root root 1024 Oct 19 2023 home | ||
+ | drwx------. 2 root root 12288 Oct 23 15:21 lost+found | ||
- | # This file controls the state of SELinux on the system. | + | [root@redhat9 ~]# ls -l / |
- | # SELINUX= can take one of these three values: | + | total 10294 |
- | # | + | -rw-r--r--. 1 root root 10485760 Oct 23 15:27 10M |
- | # | + | drwxr-xr-x. 3 root root 1024 Oct 19 2023 home |
- | # | + | drwx------. 2 root root 12288 Oct 23 15:21 lost+found |
- | SELINUX=enforcing | + | |
- | # SELINUXTYPE= can take one of three two values: | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | SELINUXTYPE=targeted | + | |
</ | </ | ||
- | Afin de connaître l' | + | Supprimez maintenant le fichier |
< | < | ||
- | [root@centos7 /]# getenforce | + | [root@redhat9 ~]# rm / |
- | Enforcing | + | rm: remove regular file '/ |
</ | </ | ||
- | Pour modifier l' | + | Constatez le résultat |
< | < | ||
- | [root@centos7 /]# setenforce permissive | + | [root@redhat9 ~]# df -Ph /mnt/lvm |
- | [root@centos7 | + | Filesystem |
- | Permissive | + | / |
+ | |||
+ | [root@redhat9 ~]# df -Ph /mnt/ | ||
+ | Filesystem | ||
+ | / | ||
+ | |||
+ | [root@redhat9 ~]# lvs | ||
+ | LV | ||
+ | root rhel -wi-ao---- < | ||
+ | swap rhel -wi-ao---- | ||
+ | lv0 vg0 owi-aos--- 456.00m | ||
+ | | ||
</ | </ | ||
- | La commande **sestatus** vous informe sur la configuration de %%SELinux%% et notamment sur la version de la politique utilisée | + | <WRAP center round todo 60%> |
+ | **A Faire** - Restaurez le fichier 10M à partir du snapshot. | ||
+ | </ | ||
+ | |||
+ | ====LAB #6 - Suppression des Volumes==== | ||
+ | |||
+ | La suppression d'un volume logique se fait grace à la commande **lvremove** : | ||
< | < | ||
- | [root@centos7 /]# sestatus | + | [root@redhat9 ~]# umount |
- | SELinux status: | + | |
- | SELinuxfs mount: | + | [root@redhat9 ~]# lvremove |
- | SELinux | + | Do you really want to remove active logical volume vg0/ |
- | Loaded policy name: targeted | + | |
- | Current mode: | + | |
- | Mode from config file: enforcing | + | [root@redhat9 ~]# umount / |
- | Policy MLS status: | + | |
- | Policy deny_unknown status: | + | [root@redhat9 ~]# lvremove / |
- | Max kernel policy version: 28 | + | Do you really want to remove active logical volume vg0/lv0? [y/n]: y |
+ | Logical volume " | ||
</ | </ | ||
- | Les différentes versions de politiques évolue en même temps que le noyau Linux. | + | <WRAP center round important 60%> |
+ | **Important** - Notez que cette opération necéssite à ce que le volume logique soit démonté. | ||
+ | </ | ||
- | La commande | + | Les options de la commande |
< | < | ||
- | [root@centos7 /]# sestatus | + | [root@redhat9 ~]# lvremove |
- | SELinux status: | + | |
- | SELinuxfs mount: | + | |
- | SELinux root directory: | + | |
- | Loaded policy name: | + | [ -A|--autobackup y|n ] |
- | Current mode: | + | [ -f|--force ] |
- | Mode from config file: enforcing | + | [ -S|--select String ] |
- | Policy MLS status: | + | |
- | Policy deny_unknown status: | + | |
- | Max kernel policy version: | + | |
+ | [ COMMON_OPTIONS ] | ||
- | Process contexts: | + | Common options for lvm: |
- | Current context: | + | |
- | Init context: | + | [ -h|--help ] |
- | / | + | |
+ | [ -v|--verbose ] | ||
+ | [ -y|--yes ] | ||
+ | [ -t|--test ] | ||
+ | [ --commandprofile String ] | ||
+ | [ --config String ] | ||
+ | [ --driverloaded y|n ] | ||
+ | [ --nolocking ] | ||
+ | [ --lockopt String ] | ||
+ | [ --longhelp ] | ||
+ | [ --profile String ] | ||
+ | [ --version ] | ||
+ | [ --devicesfile String ] | ||
+ | [ --devices PV ] | ||
+ | [ --nohints ] | ||
+ | [ --journal String ] | ||
- | File contexts: | + | Use --longhelp to show all options and advanced commands. |
- | Controlling terminal: | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | /lib/libc.so.6 system_u: | + | |
- | / | + | |
</ | </ | ||
- | ====Booléens==== | + | Le Volume Group peut aussi être supprimé : |
- | Les booléens permettent à des ensembles de règles d' | + | < |
+ | [root@redhat9 ~]# vgremove vg0 | ||
+ | Volume group " | ||
+ | </ | ||
- | Pour visualiser l' | + | Les options de la commande **vgremove** sont : |
< | < | ||
- | [root@centos7 /]# getsebool | + | [root@redhat9 ~]# vgremove |
- | abrt_anon_write | + | |
- | abrt_handle_event | + | |
- | abrt_upload_watch_anon_write | + | vgremove VG|Tag|Select ... |
- | antivirus_can_scan_system | + | [ -f|--force ] |
- | antivirus_use_jit | + | |
- | auditadm_exec_content | + | |
- | authlogin_nsswitch_use_ldap | + | |
- | authlogin_radius | + | [ COMMON_OPTIONS ] |
- | authlogin_yubikey | + | |
- | awstats_purge_apache_log_files | + | Common options for lvm: |
- | boinc_execmem | + | [ -d|--debug ] |
- | cdrecord_read_content | + | |
- | cluster_can_network_connect | + | |
- | cluster_manage_all_files | + | |
- | cluster_use_execmem | + | |
- | cobbler_anon_write | + | |
- | cobbler_can_network_connect | + | |
- | cobbler_use_cifs | + | |
- | cobbler_use_nfs | + | |
- | collectd_tcp_network_connect | + | |
- | condor_tcp_network_connect | + | |
- | conman_can_network | + | |
- | container_connect_any | + | |
- | --More-- | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Use --longhelp to show all options and advanced commands. | ||
</ | </ | ||
- | ou la commande **sestatus -b** : | + | Ainsi que le volume physique |
< | < | ||
- | [root@centos7 /]# sestatus -b | more | + | [root@redhat9 ~]# pvremove |
- | SELinux status: | + | |
- | SELinuxfs mount: | + | |
- | SELinux root directory: | + | |
- | Loaded policy name: | + | </ |
- | Current mode: | + | |
- | Mode from config file: enforcing | + | |
- | Policy MLS status: | + | |
- | Policy deny_unknown status: | + | |
- | Max kernel policy version: | + | |
- | Policy booleans: | + | Les options de la commande **pvremove** sont : |
- | abrt_anon_write | + | |
- | abrt_handle_event | + | < |
- | abrt_upload_watch_anon_write | + | [root@redhat9 ~]# pvremove --help |
- | antivirus_can_scan_system | + | |
- | antivirus_use_jit | + | |
- | auditadm_exec_content | + | |
- | authlogin_nsswitch_use_ldap | + | [ -f|--force ] |
- | authlogin_radius | + | |
- | authlogin_yubikey | + | [ COMMON_OPTIONS ] |
- | awstats_purge_apache_log_files | + | |
- | boinc_execmem | + | |
- | cdrecord_read_content | + | [ -d|--debug ] |
- | --More-- | + | |
+ | [ -q|--quiet ] | ||
+ | [ -v|--verbose ] | ||
+ | [ -y|--yes ] | ||
+ | [ -t|--test ] | ||
+ | [ --commandprofile String ] | ||
+ | [ --config String ] | ||
+ | [ --driverloaded y|n ] | ||
+ | [ --nolocking ] | ||
+ | [ --lockopt String ] | ||
+ | [ --longhelp ] | ||
+ | [ --profile String ] | ||
+ | [ --version ] | ||
+ | [ --devicesfile String ] | ||
+ | [ --devices PV ] | ||
+ | [ --nohints ] | ||
+ | [ --journal String ] | ||
+ | |||
+ | Use --longhelp to show all options and advanced commands. | ||
</ | </ | ||
- | Pour fixer l' | + | ====LAB #7 - Volumes Logiques en Miroir==== |
+ | |||
+ | Re-créez maintenant votre Volume Group : | ||
< | < | ||
- | [root@centos7 /]# setsebool antivirus_can_scan_system 1 | + | [root@redhat9 ~]# pvcreate /dev/sdb6 /dev/sdb7 /dev/sdb9 |
- | [root@centos7 | + | |
- | antivirus_can_scan_system --> on | + | |
- | [root@centos7 | + | |
- | [root@centos7 /]# getsebool antivirus_can_scan_system | + | |
- | antivirus_can_scan_system | + | [root@redhat9 ~]# vgcreate |
+ | Volume group " | ||
</ | </ | ||
- | =====LAB #3 - Travailler avec SELinux===== | + | Créez maintenant un Logical Volume en miroir grâce à l' |
- | Afin reconstruire la politique actuelle **sans** les règles **dontaudit**, | ||
- | |||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | Rounding up size to full physical extent 104.00 MiB | ||
+ | Logical volume " | ||
</ | </ | ||
- | Vérifiez qu'il ne reste aucune règle de type **dontaudit** | + | Constatez maintenant la présence du miroir |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | --- Logical volume --- | ||
+ | LV Path / | ||
+ | LV Name lv1 | ||
+ | VG Name vg0 | ||
+ | LV UUID L7FOYB-c0tG-dE1u-Oyod-LltI-PEcv-rebeIa | ||
+ | LV Write Access | ||
+ | LV Creation host, time redhat9.ittraining.loc, | ||
+ | LV Status | ||
+ | # open 0 | ||
+ | LV Size 104.00 MiB | ||
+ | Current LE 13 | ||
+ | Mirrored volumes | ||
+ | Segments | ||
+ | Allocation | ||
+ | Read ahead sectors | ||
+ | - currently set to 256 | ||
+ | Block device | ||
+ | |||
+ | --- Segments --- | ||
+ | Logical extents 0 to 12: | ||
+ | Type raid1 | ||
+ | Monitoring | ||
+ | Raid Data LV 0 | ||
+ | Logical volume | ||
+ | Logical extents | ||
+ | Raid Data LV 1 | ||
+ | Logical volume | ||
+ | Logical extents | ||
+ | Raid Metadata LV 0 lv1_rmeta_0 | ||
+ | Raid Metadata LV 1 lv1_rmeta_1 | ||
+ | </ | ||
- | Statistics for policy file: / | + | Le miroir s' |
- | Policy Version & Type: v.28 (binary, mls) | + | |
- | | + | < |
- | Sensitivities: | + | [root@redhat9 ~]# pvdisplay -m /dev/sdb6 /dev/sdb7 /dev/sdb9 |
- | Types: | + | --- Physical volume --- |
- | Users: | + | PV Name |
- | Booleans: | + | VG Name vg0 |
- | Allow: | + | PV Size |
- | Auditallow: | + | Allocatable |
- | Type_trans: | + | PE Size 8.00 MiB |
- | Type_member: | + | Total PE 24 |
- | Role_trans: | + | Free PE 10 |
- | Constraints: | + | Allocated PE |
- | Initial SIDs: 27 Fs_use: | + | PV UUID |
- | Genfscon: | + | |
- | Netifcon: | + | --- Physical Segments --- |
- | Permissives: 6 Polcap: | + | Physical extent 0 to 0: |
+ | Logical volume | ||
+ | | ||
+ | | ||
+ | Logical volume | ||
+ | Logical extents | ||
+ | | ||
+ | FREE | ||
+ | |||
+ | --- Physical volume --- | ||
+ | PV Name / | ||
+ | VG Name vg0 | ||
+ | PV Size | ||
+ | Allocatable | ||
+ | PE Size 8.00 MiB | ||
+ | Total PE 37 | ||
+ | Free PE 23 | ||
+ | Allocated PE 14 | ||
+ | PV UUID | ||
+ | |||
+ | --- Physical Segments --- | ||
+ | Physical extent 0 to 0: | ||
+ | Logical volume | ||
+ | | ||
+ | | ||
+ | Logical volume | ||
+ | | ||
+ | Physical extent 14 to 36: | ||
+ | FREE | ||
+ | |||
+ | --- Physical volume --- | ||
+ | PV Name / | ||
+ | VG Name vg0 | ||
+ | PV Size | ||
+ | Allocatable | ||
+ | PE Size 8.00 MiB | ||
+ | Total PE 49 | ||
+ | Free PE 49 | ||
+ | Allocated PE | ||
+ | PV UUID | ||
+ | |||
+ | --- Physical Segments --- | ||
+ | Physical extent 0 to 48: | ||
+ | FREE | ||
</ | </ | ||
- | ====Copier et Déplacer des Fichiers==== | + | La suppression du miroir se fait en utilisant la commande **lvconvert** en indiquant quel volume physique doit être vidé de son contenu : |
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# lvconvert -m 0 / | ||
+ | Are you sure you want to convert raid1 LV vg0/lv1 to type linear losing all resilience? [y/n]: y | ||
+ | Logical volume vg0/lv1 successfully converted. | ||
+ | </ | ||
- | Créez deux fichiers **file1** et **file2** en tant que l' | + | De même, il est possible de créer un miroir pour un volume logique existant |
< | < | ||
- | [root@centos7 /]# exit | + | [root@redhat9 ~]# lvconvert -m 1 / |
- | logout | + | Are you sure you want to convert linear LV vg0/lv1 to raid1 with 2 images enhancing resilience? |
- | [trainee@centos7 ~]$ touch file1 file2 | + | |
- | [trainee@centos7 ~]$ ls -Z file* | + | |
- | -rw-rw-r--. trainee trainee unconfined_u: | + | |
- | -rw-rw-r--. trainee trainee unconfined_u: | + | |
</ | </ | ||
- | Notez que le type des deux fichiers est **user_home_t**. | + | Supprimez de nouveau votre miroir : |
- | Copiez maintenant le fichier **file1** vers **/tmp** en utilisant | + | < |
+ | [root@redhat9 ~]# lvconvert -m 0 /dev/vg0/lv1 /dev/sdb7 | ||
+ | Are you sure you want to convert raid1 LV vg0/lv1 to type linear losing all resilience? [y/n]: y | ||
+ | Logical volume vg0/lv1 successfully converted. | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **lvconvert** sont : | ||
< | < | ||
- | [trainee@centos7 | + | [root@redhat9 |
- | [trainee@centos7 ~]$ ls -Z /tmp/file1 | + | |
- | -rw-rw-r--. trainee trainee unconfined_u:object_r:user_tmp_t: | + | |
+ | Convert LV to linear. | ||
+ | lvconvert --type linear LV | ||
+ | | ||
+ | [ PV ... ] | ||
+ | |||
+ | Convert LV to striped. | ||
+ | lvconvert --type striped LV | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -R|--regionsize Size[m|UNIT] ] | ||
+ | [ -i|--interval Number ] | ||
+ | [ --stripes Number ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Convert LV to type mirror (also see type raid1), | ||
+ | lvconvert --type mirror LV | ||
+ | [ -m|--mirrors [+|-]Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -R|--regionsize Size[m|UNIT] ] | ||
+ | [ -i|--interval Number ] | ||
+ | [ --stripes Number ] | ||
+ | [ --mirrorlog core|disk ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Convert LV to raid or change raid layout | ||
+ | (a specific raid level must be used, e.g. raid1). | ||
+ | lvconvert --type raid LV | ||
+ | [ -m|--mirrors [+|-]Number ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -R|--regionsize Size[m|UNIT] ] | ||
+ | [ -i|--interval Number ] | ||
+ | [ --stripes Number ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Convert LV to raid1 or mirror, or change number of mirror images. | ||
+ | lvconvert -m|--mirrors [+|-]Number LV | ||
+ | [ -R|--regionsize Size[m|UNIT] ] | ||
+ | [ -i|--interval Number ] | ||
+ | [ --mirrorlog core|disk ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Convert raid LV to change number of stripe images. | ||
+ | lvconvert --stripes Number LV | ||
+ | [ -i|--interval Number ] | ||
+ | [ -R|--regionsize Size[m|UNIT] ] | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Convert raid LV to change the stripe size. | ||
+ | lvconvert -I|--stripesize Size[k|UNIT] LV | ||
+ | [ -i|--interval Number ] | ||
+ | [ -R|--regionsize Size[m|UNIT] ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Split images from a raid1 or mirror LV and use them to create a new LV. | ||
+ | lvconvert --splitmirrors Number -n|--name LV_new LV | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Split images from a raid1 LV and track changes to origin for later merge. | ||
+ | lvconvert --splitmirrors Number --trackchanges LV | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Merge LV images that were split from a raid1 LV. | ||
+ | lvconvert --mergemirrors VG|LV|Tag ... | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Convert LV to a thin LV, using the original LV as an external origin. | ||
+ | lvconvert --type thin --thinpool LV LV | ||
+ | [ -T|--thin ] | ||
+ | [ -r|--readahead auto|none|Number ] | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ -Z|--zero y|n ] | ||
+ | | ||
+ | [ --poolmetadata LV ] | ||
+ | [ --poolmetadatasize Size[m|UNIT] ] | ||
+ | [ --poolmetadataspare y|n ] | ||
+ | [ --metadataprofile String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Convert LV to a thin LV, using LV as thin-pool data volume. | ||
+ | lvconvert --type thin LV | ||
+ | [ -T|--thin ] | ||
+ | [ -r|--readahead auto|none|Number ] | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ -Z|--zero y|n ] | ||
+ | [ --poolmetadata LV ] | ||
+ | [ --poolmetadatasize Size[m|UNIT] ] | ||
+ | [ --poolmetadataspare y|n ] | ||
+ | [ --metadataprofile String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Attach a cache pool to an LV, converts the LV to type cache. | ||
+ | lvconvert --type cache --cachepool LV LV | ||
+ | [ -H|--cache ] | ||
+ | [ -Z|--zero y|n ] | ||
+ | [ -r|--readahead auto|none|Number ] | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ --cachemetadataformat auto|1|2 ] | ||
+ | [ --cachemode writethrough|writeback|passthrough ] | ||
+ | [ --cachepolicy String ] | ||
+ | [ --cachesettings String ] | ||
+ | [ --poolmetadata LV ] | ||
+ | [ --poolmetadatasize Size[m|UNIT] ] | ||
+ | [ --poolmetadataspare y|n ] | ||
+ | [ --metadataprofile String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Attach a writecache to an LV, converts the LV to type writecache. | ||
+ | lvconvert --type writecache --cachevol LV LV | ||
+ | [ --cachesettings String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Attach a cache to an LV, converts the LV to type cache. | ||
+ | lvconvert --type cache --cachevol LV LV | ||
+ | [ -H|--cache ] | ||
+ | [ -Z|--zero y|n ] | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ --cachemetadataformat auto|1|2 ] | ||
+ | [ --cachemode writethrough|writeback|passthrough ] | ||
+ | [ --cachepolicy String ] | ||
+ | [ --cachesettings String ] | ||
+ | [ --poolmetadatasize Size[m|UNIT] ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Add a writecache to an LV, using a specified cache device. | ||
+ | lvconvert --type writecache --cachedevice PV LV | ||
+ | [ --cachesize Size[m|UNIT] ] | ||
+ | [ --cachesettings String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Add a cache to an LV, using a specified cache device. | ||
+ | lvconvert --type cache --cachedevice PV LV | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ --cachesize Size[m|UNIT] ] | ||
+ | [ --cachesettings String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Convert LV to type thin-pool. | ||
+ | lvconvert --type thin-pool LV | ||
+ | [ -I|--stripesize Size[k|UNIT] ] | ||
+ | [ -r|--readahead auto|none|Number ] | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ -Z|--zero y|n ] | ||
+ | [ --stripes Number ] | ||
+ | [ --discards passdown|nopassdown|ignore ] | ||
+ | [ --errorwhenfull y|n ] | ||
+ | [ --poolmetadata LV ] | ||
+ | [ --poolmetadatasize Size[m|UNIT] ] | ||
+ | [ --poolmetadataspare y|n ] | ||
+ | [ --metadataprofile String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Convert LV to type cache-pool. | ||
+ | lvconvert --type cache-pool LV | ||
+ | [ -Z|--zero y|n ] | ||
+ | [ -r|--readahead auto|none|Number ] | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ --cachemetadataformat auto|1|2 ] | ||
+ | [ --cachemode writethrough|writeback|passthrough ] | ||
+ | [ --cachepolicy String ] | ||
+ | [ --cachesettings String ] | ||
+ | [ --poolmetadata LV ] | ||
+ | [ --poolmetadatasize Size[m|UNIT] ] | ||
+ | [ --poolmetadataspare y|n ] | ||
+ | [ --metadataprofile String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Convert LV to type vdopool. | ||
+ | lvconvert --type vdo-pool LV | ||
+ | [ -n|--name LV_new ] | ||
+ | [ -V|--virtualsize Size[m|UNIT] ] | ||
+ | [ -r|--readahead auto|none|Number ] | ||
+ | [ -Z|--zero y|n ] | ||
+ | [ --metadataprofile String ] | ||
+ | [ --compression y|n ] | ||
+ | [ --deduplication y|n ] | ||
+ | [ --vdosettings String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Detach a cache from an LV. | ||
+ | lvconvert --splitcache LV | ||
+ | [ --cachesettings String ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Merge thin LV into its origin LV. | ||
+ | lvconvert --mergethin LV ... | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Merge COW snapshot LV into its origin. | ||
+ | lvconvert --mergesnapshot LV ... | ||
+ | [ -i|--interval Number ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Combine a former COW snapshot (second arg) with a former | ||
+ | origin LV (first arg) to reverse a splitsnapshot command. | ||
+ | lvconvert --type snapshot LV LV | ||
+ | [ -s|--snapshot ] | ||
+ | [ -c|--chunksize Size[k|UNIT] ] | ||
+ | [ -Z|--zero y|n ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Replace failed PVs in a raid or mirror LV. | ||
+ | Repair a thin pool. | ||
+ | Repair a cache pool. | ||
+ | lvconvert --repair LV | ||
+ | [ -i|--interval Number ] | ||
+ | [ -k|--setactivationskip y|n ] | ||
+ | [ --usepolicies ] | ||
+ | [ --poolmetadataspare y|n ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Replace specific PV(s) in a raid LV with another PV. | ||
+ | lvconvert --replace PV LV | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Poll LV to continue conversion. | ||
+ | lvconvert --startpoll LV | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Add or remove data integrity checksums to raid images. | ||
+ | lvconvert --raidintegrity y|n LV | ||
+ | [ --raidintegritymode String ] | ||
+ | [ --raidintegrityblocksize Number ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | [ PV ... ] | ||
+ | |||
+ | Common options for command: | ||
+ | [ -b|--background ] | ||
+ | [ -f|--force ] | ||
+ | [ --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit ] | ||
+ | [ --noudevsync ] | ||
+ | |||
+ | Common options for lvm: | ||
+ | [ -d|--debug ] | ||
+ | [ -h|--help ] | ||
+ | [ -q|--quiet ] | ||
+ | [ -v|--verbose ] | ||
+ | [ -y|--yes ] | ||
+ | [ -t|--test ] | ||
+ | [ --commandprofile String ] | ||
+ | [ --config String ] | ||
+ | [ --driverloaded y|n ] | ||
+ | [ --nolocking ] | ||
+ | [ --lockopt String ] | ||
+ | [ --longhelp ] | ||
+ | [ --profile String ] | ||
+ | [ --version ] | ||
+ | [ --devicesfile String ] | ||
+ | [ --devices PV ] | ||
+ | [ --nohints ] | ||
+ | [ --journal String ] | ||
+ | |||
+ | Use --longhelp to show all options and advanced commands. | ||
</ | </ | ||
- | Notez que le fichier ainsi copié a hérité du **type** du répertoire parent, à savoir **tmp_t**. | + | ====LAB #8 - Modifier les Attributs LVM==== |
- | Déplacez maintenant le fichier | + | En cas de présence d'un miroir, la commande |
< | < | ||
- | [trainee@centos7 | + | [root@redhat9 |
- | [trainee@centos7 ~]$ ls -Z /tmp/file2 | + | |
- | -rw-rw-r--. trainee trainee unconfined_u: | + | root rhel -wi-ao---- < |
+ | swap rhel -wi-ao---- | ||
+ | lv1 vg0 -wi-a----- 104.00m | ||
</ | </ | ||
- | Notez que la commande | + | <WRAP center round important 60%> |
+ | Consultez | ||
+ | </ | ||
- | ====Vérifier | + | La commande equivalente pour les Volume Groups est **vgs** : |
- | Il convient d' | + | < |
+ | [root@redhat9 ~]# vgs | ||
+ | VG #PV #LV #SN Attr | ||
+ | rhel | ||
+ | vg0 3 | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | Consultez | ||
+ | </ | ||
+ | |||
+ | La commande | ||
< | < | ||
- | [trainee@centos7 | + | [root@redhat9 |
- | LABEL | + | |
- | system_u: | + | /dev/sda2 rhel lvm2 a-- <49.00g 0 |
- | deserialize 24 | + | /dev/ |
- | system_u: | + | |
- | system_u: | + | /dev/ |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | --Plus-- | + | |
</ | </ | ||
- | ====Visualiser la SC d'un Utilisateur==== | + | <WRAP center round important 60%> |
+ | Consultez **[[http:// | ||
+ | </ | ||
- | Utilisez l' | + | Les commandes |
+ | |||
+ | Par exemple, pour rendre inutilisable un Logical Volume, il convient d' | ||
< | < | ||
- | [trainee@centos7 | + | [root@redhat9 |
- | unconfined_u: | + | |
+ | [root@redhat9 ~]# lvs | ||
+ | LV | ||
+ | root rhel -wi-ao---- < | ||
+ | swap rhel -wi-ao---- | ||
+ | lv1 vg0 -wi------- 104.00m | ||
</ | </ | ||
- | Notez que vous ne pouvez pas consulter le SC d'un autre utilisateur | + | Pour faire l'inverse il convient de saisir la commande suivante |
< | < | ||
- | [trainee@centos7 | + | [root@redhat9 |
- | uid=0(root) gid=0(root) groupes=0(root) | + | |
- | [trainee@centos7 | + | [root@redhat9 |
- | id: impossible d' | + | LV |
+ | | ||
+ | swap rhel -wi-ao---- | ||
+ | lv1 vg0 -wi-a----- 104.00m | ||
</ | </ | ||
- | ====Vérifier la SC d'un fichier==== | + | Les options de la commande **lvchange** sont : |
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# lvchange --help | ||
+ | lvchange - Change the attributes of logical volume(s) | ||
+ | |||
+ | Change a general LV attribute. | ||
+ | For options listed in parentheses, | ||
+ | required, after which the others are optional. | ||
+ | lvchange | ||
+ | ( -C|--contiguous y|n, | ||
+ | -p|--permission rw|r, | ||
+ | -r|--readahead auto|none|Number, | ||
+ | -k|--setactivationskip y|n, | ||
+ | -Z|--zero y|n, | ||
+ | -M|--persistent n, | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | [ -a|--activate y|n|ay ] | ||
+ | [ --poll y|n ] | ||
+ | [ --monitor y|n ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Resyncronize a mirror or raid LV. | ||
+ | Use to reset ' | ||
+ | lvchange --resync VG|LV|Tag|Select ... | ||
+ | [ -a|--activate y|n|ay ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Resynchronize or check a raid LV. | ||
+ | lvchange --syncaction check|repair VG|LV|Tag|Select ... | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Reconstruct data on specific PVs of a raid LV. | ||
+ | lvchange --rebuild PV VG|LV|Tag|Select ... | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Activate or deactivate an LV. | ||
+ | lvchange -a|--activate y|n|ay VG|LV|Tag|Select ... | ||
+ | [ -P|--partial ] | ||
+ | [ -K|--ignoreactivationskip ] | ||
+ | [ --activationmode partial|degraded|complete ] | ||
+ | [ --poll y|n ] | ||
+ | [ --monitor y|n ] | ||
+ | [ --ignorelockingfailure ] | ||
+ | [ --sysinit ] | ||
+ | [ --readonly ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Reactivate an LV using the latest metadata. | ||
+ | lvchange --refresh VG|LV|Tag|Select ... | ||
+ | [ -P|--partial ] | ||
+ | [ --activationmode partial|degraded|complete ] | ||
+ | [ --poll y|n ] | ||
+ | [ --monitor y|n ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Start or stop monitoring an LV from dmeventd. | ||
+ | lvchange --monitor y|n VG|LV|Tag|Select ... | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Start or stop processing an LV conversion. | ||
+ | lvchange --poll y|n VG|LV|Tag|Select ... | ||
+ | [ --monitor y|n ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Make the minor device number persistent for an LV. | ||
+ | lvchange -M|--persistent y --minor Number LV | ||
+ | [ -j|--major Number ] | ||
+ | [ -a|--activate y|n|ay ] | ||
+ | [ --poll y|n ] | ||
+ | [ --monitor y|n ] | ||
+ | [ COMMON_OPTIONS ] | ||
+ | |||
+ | Common options for command: | ||
+ | [ -A|--autobackup y|n ] | ||
+ | [ -f|--force ] | ||
+ | [ -S|--select String ] | ||
+ | [ --ignoremonitoring ] | ||
+ | [ --noudevsync ] | ||
+ | [ --reportformat basic|json|json_std ] | ||
+ | |||
+ | Common options for lvm: | ||
+ | [ -d|--debug ] | ||
+ | [ -h|--help ] | ||
+ | [ -q|--quiet ] | ||
+ | [ -v|--verbose ] | ||
+ | [ -y|--yes ] | ||
+ | [ -t|--test ] | ||
+ | [ --commandprofile String ] | ||
+ | [ --config String ] | ||
+ | [ --driverloaded y|n ] | ||
+ | [ --nolocking ] | ||
+ | [ --lockopt String ] | ||
+ | [ --longhelp ] | ||
+ | [ --profile String ] | ||
+ | [ --version ] | ||
+ | [ --devicesfile String ] | ||
+ | [ --devices PV ] | ||
+ | [ --nohints ] | ||
+ | [ --journal String ] | ||
+ | |||
+ | Use --longhelp to show all options and advanced commands. | ||
+ | </ | ||
+ | |||
+ | ====LAB #9 - Volumes Logiques en Bandes==== | ||
+ | |||
+ | Un volume logique en bandes est créé pour augmenter, comme dans le cas du RAID, les performances des entrées et sorties. Pour créer ce volume, la commande **lvcreate** prend deux option supplémentaires : | ||
+ | |||
+ | * **-i** - indique le nombre de volumes de bandes, | ||
+ | * **-I** - indique la taille en Ko de chaque bande. | ||
- | Il convient d' | + | Saisissez donc la commande |
< | < | ||
- | [trainee@centos7 | + | [root@redhat9 |
- | [trainee@centos7 etc]$ ls -Z l* -d | + | |
- | -rw-r--r--. root root unconfined_u: | + | |
- | -rw-r--r--. root root system_u: | + | |
- | drwxr-xr-x. root root system_u: | + | |
- | -rw-r-----. root root system_u: | + | |
- | drwxr-xr-x. root root system_u: | + | |
- | drwxr-xr-x. root root system_u: | + | |
- | -rw-r--r--. root root unconfined_u: | + | |
- | -rw-r--r--. root root unconfined_u: | + | |
- | lrwxrwxrwx. root root unconfined_u: | + | |
- | -rw-r--r--. root root unconfined_u: | + | |
- | -rw-r--r--. root root system_u: | + | |
- | drwxr-xr-x. root root system_u: | + | |
- | drwxr-xr-x. root root system_u: | + | |
- | drwxr-xr-x. root root system_u: | + | |
</ | </ | ||
- | ====Troubleshooting SELinux==== | + | Constatez la présence de vos bandes sur /dev/sda7 et sur /dev/sda9 : |
- | L' | + | < |
+ | [root@redhat9 ~]# lvdisplay -m / | ||
+ | --- Logical volume --- | ||
+ | LV Path / | ||
+ | LV Name lv2 | ||
+ | VG Name vg0 | ||
+ | LV UUID rgVJEa-mbyk-nQhm-rLt0-EqPB-QyI3-zyG2qX | ||
+ | LV Write Access | ||
+ | LV Creation host, time redhat9.ittraining.loc, | ||
+ | LV Status | ||
+ | # open 0 | ||
+ | LV Size 112.00 MiB | ||
+ | Current LE 14 | ||
+ | Segments | ||
+ | Allocation | ||
+ | Read ahead sectors | ||
+ | - currently set to 512 | ||
+ | Block device | ||
+ | |||
+ | --- Segments --- | ||
+ | Logical extents 0 to 13: | ||
+ | Type striped | ||
+ | Stripes | ||
+ | Stripe size 64.00 KiB | ||
+ | Stripe 0: | ||
+ | Physical volume | ||
+ | Physical extents | ||
+ | Stripe 1: | ||
+ | Physical volume | ||
+ | Physical extents | ||
+ | </ | ||
- | Si le démon | + | Utilisez maintenant la commande |
- | ===La commande chcon=== | + | < |
+ | [root@redhat9 ~]# lvs -o +devices | ||
+ | LV | ||
+ | root rhel -wi-ao---- < | ||
+ | swap rhel -wi-ao---- | ||
+ | lv1 vg0 -wi-a----- 104.00m | ||
+ | lv2 vg0 -wi-a----- 112.00m | ||
+ | </ | ||
- | La commande | + | ====LAB #10 - Gérer les Métadonnées==== |
+ | |||
+ | Les métadonnées pour chaque Volume Group sont stockés dans un fichier texte au nom du Volume Group dans le répertoire | ||
< | < | ||
- | [trainee@centos7 etc]$ cd ~ | + | [root@redhat9 |
- | [trainee@centos7 | + | # Generated by LVM2 version 2.03.23(2) (2023-11-21): Wed Oct 23 15:49:12 2024 |
- | Utilisation : | + | |
- | ou : chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE... | + | |
- | ou : chcon [OPTION]... --reference=RFILE FILE... | + | |
- | Modifier le contexte de sécurité SELinux de chaque FILE en CONTEXT. | + | |
- | Avec --reference, | + | |
- | celui de RFILE. | + | |
- | Les arguments obligatoires pour les options longues le sont aussi pour les | + | contents |
- | options courtes. | + | version |
- | --dereference | + | |
- | | + | |
- | -h, --no-dereference | + | |
- | | + | |
- | -u, --user=USER définir l' | + | |
- | sécurité cible | + | |
- | -r, --role=ROLE définir le rôle ROLE dans le contexte de sécurité cible | + | |
- | -t, --type=TYPE | + | |
- | -l, --range=RANGE | + | |
- | | + | |
- | --no-preserve-root ne pas traiter « / » de manière spéciale (par défaut) | + | |
- | --preserve-root | + | |
- | --reference=RFILE | + | |
- | | + | |
- | -R, --recursive | + | |
- | -v, --verbose | + | |
- | Les options suivantes modifient la façon de parcourir la hiérarchie lorsque | + | description = " |
- | l'option | + | |
- | dernière sera prise en compte. | + | |
- | | + | creation_host = " |
- | symbolique vers un répertoire, | + | creation_time = 1729691352 |
- | -L | + | |
- | | + | |
- | -P ne parcourir aucun lien symbolique (par défaut) | + | |
- | | + | vg0 { |
- | | + | id = " |
+ | seqno = 11 | ||
+ | format = " | ||
+ | status = [" | ||
+ | flags = [] | ||
+ | extent_size = 16384 # 8 Megabytes | ||
+ | max_lv = 0 | ||
+ | max_pv = 0 | ||
+ | metadata_copies = 0 | ||
- | Aide en ligne de GNU coreutils : | + | physical_volumes { |
- | Signalez les problèmes de traduction de « chcon » à : < | + | |
- | Utilisez « info coreutils 'chcon invocation' | + | pv0 { |
+ | id = " | ||
+ | device = "/dev/sdb6" | ||
+ | |||
+ | device_id_type = " | ||
+ | device_id = "t10.ATA_QEMU_HARDDISK_QM00005" | ||
+ | status = [" | ||
+ | flags = [] | ||
+ | dev_size = 409600 | ||
+ | pe_start = 2048 | ||
+ | pe_count = 24 # 192 Megabytes | ||
+ | } | ||
+ | |||
+ | pv1 { | ||
+ | id = " | ||
+ | device = "/dev/sdb7" | ||
+ | |||
+ | device_id_type = " | ||
+ | device_id = " | ||
+ | status = [" | ||
+ | flags = [] | ||
+ | dev_size = 614400 | ||
+ | pe_start = 2048 | ||
+ | pe_count = 37 # 296 Megabytes | ||
+ | } | ||
+ | |||
+ | pv2 { | ||
+ | id = " | ||
+ | device = "/dev/ | ||
+ | |||
+ | device_id_type = " | ||
+ | device_id = " | ||
+ | status = [" | ||
+ | flags = [] | ||
+ | dev_size = 819200 | ||
+ | pe_start = 2048 | ||
+ | pe_count = 49 # 392 Megabytes | ||
+ | } | ||
+ | } | ||
+ | |||
+ | logical_volumes { | ||
+ | |||
+ | lv1 { | ||
+ | id = " | ||
+ | status = [" | ||
+ | flags = [] | ||
+ | | ||
+ | creation_host = " | ||
+ | segment_count = 1 | ||
+ | |||
+ | segment1 { | ||
+ | start_extent = 0 | ||
+ | extent_count = 13 # 104 Megabytes | ||
+ | |||
+ | type = " | ||
+ | stripe_count = 1 # linear | ||
+ | |||
+ | stripes = [ | ||
+ | " | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | |||
+ | lv2 { | ||
+ | id = " | ||
+ | status = [" | ||
+ | flags = [] | ||
+ | creation_time = 1729691352 | ||
+ | creation_host = " | ||
+ | segment_count = 1 | ||
+ | |||
+ | segment1 { | ||
+ | start_extent = 0 | ||
+ | extent_count = 14 # 112 Megabytes | ||
+ | |||
+ | type = " | ||
+ | stripe_count = 2 | ||
+ | stripe_size = 128 # 64 Kilobytes | ||
+ | |||
+ | stripes = [ | ||
+ | " | ||
+ | " | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | } | ||
</ | </ | ||
- | Prenons le cas de la création | + | Des archives sont créées lors de chaque modification |
< | < | ||
- | [trainee@centos7 ~]$ su - | + | [root@redhat9 |
- | Mot de passe : | + | rhel_00000-628100095.vg |
- | Dernière connexion : dimanche 17 juin 2018 à 20:21:42 CEST sur pts/1 | + | vg0_00000-565701167.vg |
- | [root@centos7 | + | |
- | [root@centos7 ~]# touch /www/index.html | + | |
</ | </ | ||
- | Installez maintenant | + | La commande **vgcfgbackup** est utilisée pour sauvegarder les métadonnées manuellement dans le fichier **/ |
+ | |||
+ | La commande **vgcfgrestore** permet de restaurer une sauvegarde. Sans l' | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | Volume group " | ||
+ | </ | ||
+ | |||
+ | Il est aussi possible de modifier l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# vgcfgbackup -f / | ||
+ | Volume group " | ||
+ | </ | ||
+ | |||
+ | Par contre, toute sauvegarde en dehors des répertoires par défaut n'est pas visible dans la sortie de la commande **vgcfgrestore --list** : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# vgcfgbackup vg0 | ||
+ | Volume group " | ||
+ | [root@redhat9 ~]# vgcfgrestore --list vg0 | ||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:19:32 2024 | ||
+ | |||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:24:34 2024 | ||
+ | |||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:28:18 2024 | ||
+ | |||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:28:18 2024 | ||
+ | |||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:33:25 2024 | ||
+ | |||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:33:25 2024 | ||
+ | |||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:33:54 2024 | ||
+ | |||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:42:34 2024 | ||
+ | |||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:42:34 2024 | ||
+ | |||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:44:01 2024 | ||
+ | |||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:44:22 2024 | ||
+ | |||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:44:39 2024 | ||
+ | |||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:49:12 2024 | ||
+ | |||
+ | |||
+ | File: / | ||
+ | VG name: vg0 | ||
+ | Description: | ||
+ | Backup Time: Wed Oct 23 15:53:54 2024 | ||
+ | </ | ||
+ | |||
+ | =====RAID Logiciel===== | ||
+ | |||
+ | =====Concepts RAID===== | ||
+ | |||
+ | Les solutions RAID ou //Redundant Array of Independent Disks// ou encore //Redundant Array of Inexpensive Disks// permettent la combinaison de plusieurs disques de façon à ce que ceux-ci soient vu comme un seul disque logique. | ||
+ | |||
+ | Les solutions RAID sont issues du travail fourni par l' | ||
+ | |||
+ | * Addition des capacités, | ||
+ | * Amélioration des performances, | ||
+ | * Apporter la tolérance de panne. | ||
+ | |||
+ | Deux concepts sont fondamentaux à la compréhension des solutions RAID. | ||
+ | |||
+ | ====Disques en miroir==== | ||
+ | |||
+ | La technique des disques en miroir consiste à dupliquer l' | ||
+ | |||
+ | ====Bandes de données==== | ||
+ | |||
+ | La technique des bandes de données, autrement appelée //data striping// consiste à couper les données à enregistrer en segments séquentiels et contigus pour les enregistrer sur plusieurs disques physiques. L' | ||
+ | |||
+ | =====Types de RAID===== | ||
+ | |||
+ | ====RAID 0 - Concaténation==== | ||
+ | |||
+ | Création de volume par récupération de l' | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ===Avantages=== | ||
+ | |||
+ | * Récupération de l' | ||
+ | |||
+ | ===Inconvénients=== | ||
+ | |||
+ | * Pas de protection des données, | ||
+ | * Pas d' | ||
+ | |||
+ | ====RAID 0 - Striping==== | ||
+ | |||
+ | Création de volume sur plusieurs disques afin d' | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ===Avantages=== | ||
+ | |||
+ | * Augmentation des performances d'E/S par écriture en parallèle sur les disques. | ||
+ | |||
+ | ===Inconvénients=== | ||
+ | |||
+ | * Pas de protection des données. | ||
+ | |||
+ | ====RAID 1 - Miroir==== | ||
+ | |||
+ | Création d'un volume où les disques sont en miroir. Quand les deux disques sont connectés à des contrôleurs de disques différents, | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ===Avantages=== | ||
+ | |||
+ | * Protection des données contre une défaillance d'un disque. | ||
+ | |||
+ | ===Inconvénients=== | ||
+ | |||
+ | * Coûteux à cause de l' | ||
+ | |||
+ | ====RAID 1+0 - Striping en Miroir==== | ||
+ | |||
+ | Le RAID 1+0 ou encore 0+1 est une technique qui réunit le RAID 0 et le RAID 1. On l' | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ===Avantages=== | ||
+ | |||
+ | * Protection des données contre une défaillance d'un disque. | ||
+ | * Augmentation des performances d'E/S par écriture en parallèle sur les disques. | ||
+ | |||
+ | ===Inconvénients=== | ||
+ | |||
+ | * Coûteux à cause de l' | ||
+ | |||
+ | ====RAID 2 - Miroir avec Contrôle d' | ||
+ | |||
+ | Le RAID 2 est une technique de miroir avec contrôle de correction d' | ||
+ | |||
+ | ====RAID 3 et 4 - Striping avec Parité==== | ||
+ | |||
+ | Les RAID 3 et 4 sont des technologies avec bandes de parité distribuées sur un seul disque : | ||
+ | |||
+ | {{: | ||
+ | |||
+ | En RAID 3, la taille des segments n’est pas modifiable et est fixée à 512 octets (en RAID 3 : un segment = un secteur de disque dur = 512 octets). | ||
+ | |||
+ | En RAID 4, la taille des segments est variable et se modifie en temps réel. Cela implique que les informations de parité doivent être mise à jour à chaque écriture afin de vérifier si la taille des segments a été modifiée. | ||
+ | |||
+ | ===Avantages=== | ||
+ | |||
+ | * Protection des données contre une défaillance d'un disque. | ||
+ | |||
+ | ===Inconvénients=== | ||
+ | |||
+ | * Création d'un goulot d' | ||
+ | |||
+ | ====RAID 5 - Striping avec Parité Distribuée==== | ||
+ | |||
+ | Le RAID 5 est une technologie avec bandes de parité distribuées sur plusieurs disques : | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ===Avantages=== | ||
+ | |||
+ | * Protection des données contre une défaillance d'un disque, | ||
+ | * Evite le goulot d' | ||
+ | |||
+ | ===Inconvénients=== | ||
+ | |||
+ | * Lecture moins performante qu' | ||
+ | |||
+ | ====Au délà de RAID 5==== | ||
+ | |||
+ | Il existe aussi deux autres technologies RAID, toute deux issues de la technologie RAID 5 : | ||
+ | |||
+ | * RAID 6 | ||
+ | * //Disk Striping with Double Distributed Parity// | ||
+ | * RAID TP | ||
+ | * //Disk Striping with Triple Distributed Parity// | ||
+ | |||
+ | ====LAB #11 - Mise en Place du RAID 5 Logiciel==== | ||
+ | |||
+ | ===11.1 - Préparer le disque=== | ||
+ | |||
+ | Rappelez-vous avoir modifié les types de 4 partitions du disque **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# fdisk -l | ||
+ | Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors | ||
+ | Disk model: QEMU HARDDISK | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disklabel type: dos | ||
+ | Disk identifier: 0xd00dfc8a | ||
+ | |||
+ | Device | ||
+ | / | ||
+ | / | ||
+ | |||
+ | |||
+ | Disk /dev/sdb: 32 GiB, 34359738368 bytes, 67108864 sectors | ||
+ | Disk model: QEMU HARDDISK | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disklabel type: dos | ||
+ | Disk identifier: 0x23a56c2e | ||
+ | |||
+ | Device | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | |||
+ | Disk /dev/sdc: 6 GiB, 6442450944 bytes, 12582912 sectors | ||
+ | Disk model: QEMU HARDDISK | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | |||
+ | |||
+ | Disk /dev/sdd: 6 GiB, 6442450944 bytes, 12582912 sectors | ||
+ | Disk model: QEMU HARDDISK | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | |||
+ | |||
+ | Disk /dev/sde: 32 GiB, 34359738368 bytes, 67108864 sectors | ||
+ | Disk model: QEMU HARDDISK | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | |||
+ | |||
+ | Disk / | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | |||
+ | |||
+ | Disk / | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | |||
+ | |||
+ | Disk / | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | |||
+ | |||
+ | Disk / | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
</ | </ | ||
- | Modifiez ensuite la directive **%%DocumentRoot%%** dans le fichier **/ | + | Dans le cas de cet exemple les quatre partitions concernées par la mise en place d'un RAID 5 sont : |
< | < | ||
- | [...] | + | /dev/sdb5 618496 |
- | # | + | /dev/ |
- | DocumentRoot "/www" | + | /dev/ |
- | [...] | + | / |
</ | </ | ||
- | Ajoutez les section **< | + | ===11.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> | ||
+ | </ | ||
+ | |||
+ | Saisissez maintenant la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mdadm --create /dev/md1 --level=5 --raid-devices=3 /dev/sdb5 /dev/sdb8 / | ||
+ | mdadm: Defaulting to version 1.2 metadata | ||
+ | mdadm: array /dev/md1 started. | ||
+ | </ | ||
+ | |||
+ | 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=< | ||
+ | |||
+ | Les options de la commande **mdadm** sont : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mdadm --help-options | ||
+ | Any parameter that does not start with ' | ||
+ | or, for --examine-bitmap, | ||
+ | The first such name is often the name of an md device. | ||
+ | names are often names of component devices. | ||
+ | |||
+ | Some common options are: | ||
+ | --help | ||
+ | mode specific help message | ||
+ | --help-options | ||
+ | --version | ||
+ | --verbose | ||
+ | --quiet | ||
+ | --brief | ||
+ | --export | ||
+ | | ||
+ | --force | ||
+ | |||
+ | --assemble | ||
+ | --build | ||
+ | --create | ||
+ | --detail | ||
+ | --examine | ||
+ | --examine-bitmap -X: Display the detail of a bitmap file | ||
+ | --examine-badblocks: | ||
+ | --monitor | ||
+ | --grow | ||
+ | --incremental -I : add/remove a single device to/from an array as appropriate | ||
+ | --query | ||
+ | | ||
+ | --auto-detect | ||
+ | </ | ||
+ | |||
+ | La commande **mdadm** utilise des sous-commandes ou //mode majeurs// : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# 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/ | ||
+ | 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 ' | ||
+ | or, for --examine-bitmap, | ||
+ | The first such name is often the name of an md device. | ||
+ | names are often names of component devices. | ||
+ | |||
+ | For detailed help on the above major modes use --help after the mode | ||
+ | | ||
+ | mdadm --assemble --help | ||
+ | For general help on options use | ||
+ | mdadm --help-options | ||
+ | </ | ||
+ | |||
+ | Chaque sous-commande bénéficie d'un aide spécifique, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mdadm --create --help | ||
+ | Usage: | ||
+ | |||
+ | This usage will initialise a new md array, associate some | ||
+ | | ||
+ | array with some devices missing, use the special word ' | ||
+ | place of the relevant device name. | ||
+ | |||
+ | | ||
+ | raid superblocks or filesystems. | ||
+ | the variance in device size exceeds 1%. | ||
+ | If any discrepancy is found, the user will be prompted for confirmation | ||
+ | | ||
+ | | ||
+ | |||
+ | If the --size option is given then only that many kilobytes of each | ||
+ | | ||
+ | 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. | ||
+ | |||
+ | | ||
+ | --bitmap= | ||
+ | : or an internal bitmap if ' | ||
+ | --chunk= | ||
+ | --rounding= | ||
+ | --level= | ||
+ | --parity= | ||
+ | --layout= | ||
+ | --raid-devices= | ||
+ | --spare-devices= | ||
+ | --size= | ||
+ | --data-offset= | ||
+ | : of array data. | ||
+ | --force | ||
+ | : 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 | ||
+ | --name= | ||
+ | --bitmap-chunk= | ||
+ | --delay= | ||
+ | --write-journal= | ||
+ | --consistency-policy= : Specify the policy that determines how the array | ||
+ | -k : maintains consistency in case of unexpected shutdown. | ||
+ | --write-zeroes | ||
+ | </ | ||
+ | |||
+ | Les //modes majeurs// de la commande **mdadm** peuvent être visualisés grâce à la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# 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/ | ||
+ | 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 ' | ||
+ | or, for --examine-bitmap, | ||
+ | The first such name is often the name of an md device. | ||
+ | names are often names of component devices. | ||
+ | |||
+ | For detailed help on the above major modes use --help after the mode | ||
+ | | ||
+ | mdadm --assemble --help | ||
+ | For general help on options use | ||
+ | mdadm --help-options | ||
+ | </ | ||
+ | |||
+ | Constatez maintenant les informations concernant le RAID 5 créé : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cat / | ||
+ | Personalities : [raid6] [raid5] [raid4] [raid1] | ||
+ | md1 : active raid5 sdb10[3] sdb8[1] sdb5[0] | ||
+ | 1019904 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU] | ||
+ | |||
+ | unused devices: < | ||
+ | </ | ||
+ | |||
+ | Grâce à la commande mdadm, il est possible d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mdadm --query /dev/md1 | ||
+ | /dev/md1: 996.00MiB raid5 3 devices, 0 spares. Use mdadm --detail for more detail. | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mdadm --detail /dev/md1 | ||
+ | /dev/md1: | ||
+ | | ||
+ | | ||
+ | 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 | ||
+ | | ||
+ | |||
+ | | ||
+ | State : clean | ||
+ | Active Devices : 3 | ||
+ | | ||
+ | Failed Devices : 0 | ||
+ | Spare Devices : 0 | ||
+ | |||
+ | Layout : left-symmetric | ||
+ | Chunk Size : 512K | ||
+ | |||
+ | Consistency Policy : resync | ||
+ | |||
+ | Name : redhat9.ittraining.loc: | ||
+ | UUID : 3645cd8c: | ||
+ | Events : 18 | ||
+ | |||
+ | Number | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Le nom **redhat9.ittraining.loc: | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mdadm --stop /dev/md1 | ||
+ | mdadm: stopped /dev/md1 | ||
+ | |||
+ | [root@redhat9 ~]# mdadm --assemble /dev/md1 --name=redhat.ittraining.loc --update=name /dev/sdb5 /dev/sdb8 / | ||
+ | mdadm: /dev/md1 has been started with 3 drives. | ||
+ | |||
+ | [root@redhat9 ~]# mdadm --query /dev/md1 | ||
+ | /dev/md1: 996.00MiB raid5 3 devices, 0 spares. Use mdadm --detail for more detail. | ||
+ | |||
+ | [root@redhat9 ~]# mdadm --detail /dev/md1 | ||
+ | /dev/md1: | ||
+ | | ||
+ | | ||
+ | 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 | ||
+ | | ||
+ | |||
+ | | ||
+ | State : clean | ||
+ | Active Devices : 3 | ||
+ | | ||
+ | Failed Devices : 0 | ||
+ | Spare Devices : 0 | ||
+ | |||
+ | Layout : left-symmetric | ||
+ | Chunk Size : 512K | ||
+ | |||
+ | Consistency Policy : resync | ||
+ | |||
+ | Name : redhat.ittraining.loc | ||
+ | UUID : 3645cd8c: | ||
+ | Events : 18 | ||
+ | |||
+ | Number | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | 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 **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# echo ' | ||
+ | |||
+ | [root@redhat9 ~]# mdadm --detail --scan >> / | ||
+ | |||
+ | [root@redhat9 ~]# cat / | ||
+ | DEVICE /dev/sdb5 /dev/sdb8 / | ||
+ | ARRAY /dev/md1 metadata=1.2 name=redhat.ittraining.loc UUID=3645cd8c: | ||
+ | </ | ||
+ | |||
+ | Mettez à jour l' | ||
+ | |||
+ | <code> | ||
+ | [root@redhat9 ~]# cp / | ||
+ | |||
+ | [root@redhat9 ~]# dracut -f -v | ||
... | ... | ||
- | < | + | dracut: *** Creating initramfs image file '/boot/initramfs-5.14.0-427.37.1.el9_4.x86_64.img' |
- | AllowOverride None | + | |
- | # Allow open access: | + | |
- | Require all granted | + | |
- | </Directory> | + | |
- | < | + | [root@redhat9 ~]# grep initrd |
- | Options Indexes FollowSymLinks | + | / |
- | AllowOverride None | + | / |
- | Require all granted | + | / |
- | </Directory> | + | </code> |
- | # Further relax access to the default document | + | Chaque unité peut être examinée individuellement : |
- | <Directory "/var/www/html"> | + | |
+ | < | ||
+ | [root@redhat9 ~]# mdadm --examine /dev/sdb5 | ||
+ | / | ||
+ | Magic : a92b4efc | ||
+ | Version : 1.2 | ||
+ | Feature Map : 0x0 | ||
+ | Array UUID : 3645cd8c: | ||
+ | Name : redhat.ittraining.loc | ||
+ | Creation Time : Wed Oct 23 16:14:41 2024 | ||
+ | Raid Level : raid5 | ||
+ | Raid Devices : 3 | ||
+ | |||
+ | Avail Dev Size : 1019904 sectors (498.00 MiB 522.19 MB) | ||
+ | Array Size : 1019904 KiB (996.00 MiB 1044.38 MB) | ||
+ | Data Offset : 4096 sectors | ||
+ | Super Offset : 8 sectors | ||
+ | | ||
+ | State : clean | ||
+ | Device UUID : 1ef50b0e: | ||
+ | |||
+ | Update Time : Wed Oct 23 16:14:55 2024 | ||
+ | Bad Block Log : 512 entries available at offset 16 sectors | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | Chunk Size : 512K | ||
+ | |||
+ | | ||
+ | Array State : AAA (' | ||
+ | </ | ||
+ | |||
+ | ===11.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/sdb5 est devenue défaillante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mdadm --manage --set-faulty /dev/md1 /dev/sdb5 | ||
+ | mdadm: set /dev/sdb5 faulty in /dev/md1 | ||
+ | </code> | ||
+ | |||
+ | L' | ||
+ | |||
+ | <code> | ||
+ | [root@redhat9 ~]# mdadm --detail /dev/md1 | ||
+ | /dev/md1: | ||
+ | | ||
+ | | ||
+ | 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 | ||
+ | | ||
+ | |||
+ | | ||
+ | State : clean, degraded | ||
+ | Active Devices : 2 | ||
+ | | ||
+ | Failed Devices : 1 | ||
+ | Spare Devices : 0 | ||
+ | |||
+ | Layout : left-symmetric | ||
+ | Chunk Size : 512K | ||
+ | |||
+ | Consistency Policy : resync | ||
+ | |||
+ | Name : redhat.ittraining.loc | ||
+ | UUID : 3645cd8c: | ||
+ | Events : 20 | ||
+ | |||
+ | Number | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | </ | ||
+ | |||
+ | Il est maintenant nécessaire de supprimer /dev/sdb5 de notre RAID 5 : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mdadm --manage --remove /dev/md1 /dev/sdb5 | ||
+ | mdadm: hot removed /dev/sdb5 from /dev/md1 | ||
+ | </ | ||
+ | |||
+ | A l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mdadm --detail /dev/md1 | ||
+ | /dev/md1: | ||
+ | | ||
+ | | ||
+ | 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 | ||
+ | | ||
+ | |||
+ | | ||
+ | State : clean, degraded | ||
+ | Active Devices : 2 | ||
+ | | ||
+ | Failed Devices : 0 | ||
+ | Spare Devices : 0 | ||
+ | |||
+ | Layout : left-symmetric | ||
+ | Chunk Size : 512K | ||
+ | |||
+ | Consistency Policy : resync | ||
+ | |||
+ | Name : redhat.ittraining.loc | ||
+ | UUID : 3645cd8c: | ||
+ | Events : 21 | ||
+ | |||
+ | Number | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Constatez maintenant l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cat / | ||
+ | Personalities : [raid6] [raid5] [raid4] [raid1] | ||
+ | md1 : active raid5 sdb10[3] sdb8[1] | ||
+ | 1019904 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [_UU] | ||
+ | |||
+ | unused devices: < | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **iMPORTANT** - Notez que le RAID a 2 unités au lieu de trois. | ||
+ | </ | ||
+ | |||
+ | Pour ajouter un autre disque à notre RAID afin de remplacer /dev/sdb5 il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mdadm --manage --add /dev/md1 / | ||
+ | mdadm: added / | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mdadm --detail /dev/md1 | ||
+ | /dev/md1: | ||
+ | | ||
+ | | ||
+ | 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 | ||
+ | | ||
+ | |||
+ | | ||
+ | State : clean, degraded, recovering | ||
+ | Active Devices : 2 | ||
+ | | ||
+ | Failed Devices : 0 | ||
+ | Spare Devices : 1 | ||
+ | |||
+ | Layout : left-symmetric | ||
+ | Chunk Size : 512K | ||
+ | |||
+ | Consistency Policy : resync | ||
+ | |||
+ | Rebuild Status : 1% complete | ||
+ | |||
+ | Name : redhat.ittraining.loc | ||
+ | UUID : 3645cd8c: | ||
+ | Events : 23 | ||
+ | |||
+ | Number | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Vérifiez la prise en compte de la configuration : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# lsblk | ||
+ | NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS | ||
+ | sda | ||
+ | ├─sda1 | ||
+ | └─sda2 | ||
+ | ├─rhel-root 253:0 0 | ||
+ | └─rhel-swap 253:1 0 5G 0 lvm | ||
+ | sdb | ||
+ | ├─sdb1 | ||
+ | ├─sdb2 | ||
+ | ├─sdb3 | ||
+ | ├─sdb4 | ||
+ | ├─sdb5 | ||
+ | ├─sdb6 | ||
+ | │ └─vg0-lv1 | ||
+ | ├─sdb7 | ||
+ | │ └─vg0-lv2 | ||
+ | ├─sdb8 | ||
+ | │ └─md1 | ||
+ | ├─sdb9 | ||
+ | │ └─vg0-lv2 | ||
+ | ├─sdb10 | ||
+ | │ └─md1 | ||
+ | ├─sdb11 | ||
+ | │ └─md1 | ||
+ | └─sdb12 | ||
+ | sdc | ||
+ | sdd | ||
+ | sde | ||
+ | sr0 11:0 1 1024M 0 rom | ||
+ | |||
+ | [root@redhat9 ~]# cat / | ||
+ | Personalities : [raid6] [raid5] [raid4] [raid1] | ||
+ | md1 : active raid5 sdb11[4] sdb10[3] sdb8[1] | ||
+ | 1019904 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [_UU] | ||
+ | [======> | ||
+ | |||
+ | unused devices: < | ||
+ | |||
+ | [root@redhat9 ~]# cat / | ||
+ | Personalities : [raid6] [raid5] [raid4] [raid1] | ||
+ | md1 : active raid5 sdb11[4] sdb10[3] sdb8[1] | ||
+ | 1019904 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [_UU] | ||
+ | [==========> | ||
+ | |||
+ | unused devices: < | ||
+ | |||
+ | [root@redhat9 ~]# cat / | ||
+ | Personalities : [raid6] [raid5] [raid4] [raid1] | ||
+ | md1 : active raid5 sdb11[4] sdb10[3] sdb8[1] | ||
+ | 1019904 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [_UU] | ||
+ | [==================> | ||
+ | |||
+ | unused devices: < | ||
+ | |||
+ | [root@redhat9 ~]# cat / | ||
+ | Personalities : [raid6] [raid5] [raid4] [raid1] | ||
+ | md1 : active raid5 sdb11[4] sdb10[3] sdb8[1] | ||
+ | 1019904 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU] | ||
+ | |||
+ | unused devices: < | ||
+ | </ | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | << | ||
+ | [root@redhat9 ~]# echo ' | ||
+ | |||
+ | [root@redhat9 ~]# mdadm --detail --scan >> / | ||
+ | |||
+ | [root@redhat9 ~]# cat / | ||
+ | DEVICE /dev/sdb8 /dev/sdb10 / | ||
+ | ARRAY /dev/md1 metadata=1.2 name=redhat.ittraining.loc UUID=3645cd8c: | ||
+ | </ | ||
+ | |||
+ | Mettez à jour l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# dracut -f -v | ||
... | ... | ||
- | </file> | + | dracut: *** Creating initramfs image file '/ |
+ | </code> | ||
+ | |||
+ | =====LAB #12 - Stratis===== | ||
+ | |||
+ | ====12.1 - Présentation==== | ||
+ | |||
+ | **Stratis** est une solution de gestion de volumes et de stockage pour Linux, développée par Red Hat, qui combine des technologies comme **LVM (Logical Volume Manager)** et **XFS** pour fournir une gestion simplifiée des volumes de stockage. Il est conçu pour offrir une solution robuste et facile à utiliser, tout en offrant une gestion avancée du stockage comme la gestion des snapshots, le thin provisioning, | ||
+ | |||
+ | Voici un aperçu de la gestion du stockage avec Stratis : | ||
+ | |||
+ | ===Concepts clés de Stratis=== | ||
+ | |||
+ | * **Pool de stockage** : Un pool est une collection de disques physiques (ou d' | ||
+ | * **Volumes logiques** : Une fois que vous avez un pool, vous pouvez créer des volumes logiques (ou systèmes de fichiers). Ces volumes logiques peuvent être utilisés comme tout autre système de fichiers dans Linux. Ils peuvent être agrandis ou réduits dynamiquement, | ||
+ | * **Thin provisioning** : Stratis permet de créer des volumes logiques "thin provisioned", | ||
+ | * **Snapshots** : Stratis permet de créer des snapshots, qui sont des copies instantanées des volumes à un moment donné. Ces snapshots peuvent être utilisés pour des sauvegardes ou pour restaurer un état précédent du système de fichiers. | ||
+ | |||
+ | ===Gestion simplifiée=== | ||
+ | |||
+ | L’un des principaux objectifs de Stratis est de simplifier la gestion des volumes. Il combine plusieurs technologies complexes (comme LVM, D-Bus, et XFS) sous une interface de gestion unique, accessible via des commandes simples. | ||
+ | |||
+ | ===Avantages de Stratis=== | ||
+ | |||
+ | * **Facilité d' | ||
+ | * **Thin provisioning** et **snapshots** intégrés, | ||
+ | * **Gestion dynamique** des disques et des volumes, sans avoir besoin de redémarrer le système, | ||
+ | * **Snapshots** rapides pour des sauvegardes ou restaurations faciles. | ||
+ | |||
+ | ===Stratis vs ZFS/ | ||
+ | |||
+ | Stratis est parfois comparé à d' | ||
+ | |||
+ | En résumé, Stratis simplifie la gestion du stockage en regroupant plusieurs fonctionnalités avancées dans un cadre simple et accessible pour les administrateurs Linux, tout en utilisant des technologies éprouvées. | ||
+ | |||
+ | ====12.2 - Travailler avec Stratis==== | ||
+ | |||
+ | ===Installation=== | ||
- | Créez le fichier | + | Le support de Stratis peut être obtenu en installant les paquets |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | [root@centos7 ~]# cat / | + | |
- | < | + | |
- | < | + | |
- | This is a test | + | |
- | </ | + | |
- | < | + | |
- | www test page | + | |
- | </ | + | |
- | </ | + | |
</ | </ | ||
- | Modifiez ensuite le propriétaire | + | Activez |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | |||
+ | [root@redhat9 ~]# systemctl status stratisd | ||
+ | ● stratisd.service - Stratis daemon | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | Main PID: 2676 (stratisd) | ||
+ | Tasks: 8 (limit: 48799) | ||
+ | | ||
+ | CPU: 22ms | ||
+ | | ||
+ | | ||
+ | |||
+ | Oct 24 06:51:25 redhat9.ittraining.loc systemd[1]: Starting Stratis daemon... | ||
+ | Oct 24 06:51:25 redhat9.ittraining.loc stratisd[2676]: | ||
+ | Oct 24 06:51:25 redhat9.ittraining.loc stratisd[2676]: | ||
+ | Oct 24 06:51:25 redhat9.ittraining.loc stratisd[2676]: | ||
+ | Oct 24 06:51:25 redhat9.ittraining.loc systemd[1]: Started Stratis daemon. | ||
+ | Oct 24 06:51:25 redhat9.ittraining.loc stratisd[2676]: | ||
+ | [root@redhat9 ~]# | ||
</ | </ | ||
- | Dernièrement, | + | ===Création d'un Pool=== |
+ | |||
+ | Créez le pool de stockage | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
- | Redémarrez maintenant le service httpd : | + | Consultez la taille du pool : |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | Name Total / Used / Free Properties | ||
+ | pool1 6 GiB / 526 MiB / 5.49 GiB | ||
</ | </ | ||
- | Consultez | + | Dans la colonne **Properties**, |
+ | |||
+ | * **Ca** - Cache, | ||
+ | * **Cr** - Chiffrement, | ||
+ | * **Op** - Surprovisionnement. | ||
+ | |||
+ | L' | ||
+ | |||
+ | Ajoutez donc **/dev/sdd** au pool : | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | [root@redhat9 ~]# stratis pool list | ||
+ | Name Total / Used / Free Properties | ||
+ | pool1 12 GiB / 534 MiB / 11.48 GiB | ||
+ | |||
+ | [root@redhat9 ~]# stratis blockdev list pool1 | ||
+ | Pool Name | ||
+ | pool1 / | ||
+ | pool1 / | ||
</ | </ | ||
- | Pour consulter les messages | + | ===Création |
- | Installez donc ce paquet | + | Créez le système de fichiers en provisionnement fin **filesystem1** |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
- | La commande **sealert** possède à la fois une interface graphique **et** un mode en ligne de commande | + | Consultez |
< | < | ||
- | [root@centos7 | + | root@redhat9 |
- | type=AVC msg=audit(1524491216.546: | + | Pool Filesystem |
- | + | pool1 | |
- | **** Invalid AVC allowed in current policy *** | + | </ |
- | type=AVC msg=audit(1524491220.766: | + | ===Montage du System de Fichiers=== |
- | + | ||
- | **** Invalid AVC allowed in current policy *** | + | Créez maintenant le point de montage |
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mkdir /volume | ||
</ | </ | ||
- | Consultez le fichier | + | Montez **filesystem1** sur **/volume** : |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | </ | ||
- | found 3 alerts in /var/log/audit/audit.log | + | Vérifiez que **/dev/stratis/pool1/filesystem1** a été monté : |
- | -------------------------------------------------------------------------------- | + | |
- | SELinux is preventing | + | < |
+ | [root@redhat9 ~]# mount | grep volume | ||
+ | /dev/mapper/stratis-1-4cfd12ac57e74c9d8f486c33f482fc46-thin-fs-e80a1eeb95d0413a86412a07ea685b6a | ||
+ | </ | ||
- | ***** Plugin catchall (100. confidence) suggests | + | Obtenez l'UUID de **/ |
- | you believe that dbus-daemon-launch-helper should be allowed rlimitinh access on processes labeled unconfined_service_t by default. | + | < |
- | Then you should report this as a bug. | + | [root@redhat9 ~]# lsblk --output=UUID / |
- | You can generate a local policy module to allow this access. | + | UUID |
- | Do | + | e80a1eeb-95d0-413a-8641-2a07ea685b6a |
- | allow this access for now by executing: | + | </ |
- | # ausearch | + | |
- | # semodule -i my-dbusdaemonlau.pp | + | |
+ | Modifiez le fichier **/ | ||
- | Additional Information: | + | < |
- | Source Context | + | [root@redhat9 ~]# vi / |
- | Target Context | + | [root@redhat9 ~]# cat / |
- | 023 | + | |
- | Target Objects | + | # |
- | Source | + | # / |
- | Source Path /usr/libexec/dbus-1/dbus-daemon-launch-helper | + | # Created by anaconda on Thu Oct 19 16:05:58 2023 |
- | Port < | + | # |
- | Host < | + | # Accessible filesystems, |
- | Source RPM Packages | + | # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. |
- | Target RPM Packages | + | # |
- | Policy RPM selinux-policy-3.13.1-166.el7_4.9.noarch | + | # After editing this file, run ' |
- | Selinux Enabled | + | # units generated from this file. |
- | Policy Type | + | # |
- | Enforcing Mode Permissive | + | /dev/mapper/rhel-root / xfs |
- | Host Name | + | UUID=6f6c5bb9-30be-4734-bc23-03fed8541616 /boot |
- | Platform | + | / |
- | 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 | + | UUID=e80a1eeb-95d0-413a-8641-2a07ea685b6a /volume xfs defaults,x-systemd.requires=stratisd.service 0 0 |
- | 19:03:37 UTC 2018 x86_64 x86_64 | + | |
- | Alert Count 1 | + | |
- | First Seen 2020-01-23 16:04:33 CET | + | |
- | Last Seen 2020-01-23 16:04:33 CET | + | |
- | --More--(4%) | + | |
</ | </ | ||
- | Cherchez dans le fichier la chaine | + | Démontez maintenant |
< | < | ||
- | ***** Plugin catchall (17.1 confidence) suggests | + | [root@redhat9 ~]# umount /volume |
+ | [root@redhat9 ~]# mount | grep volume | ||
+ | </ | ||
- | you believe that httpd should be allowed getattr access on the index.html file by default. | + | Montez **/volume** à partir de **/ |
- | Then you should report this as a bug. | + | |
- | You can generate a local policy module to allow this access. | + | |
- | Do | + | |
- | allow this access for now by executing: | + | |
- | # ausearch -c ' | + | |
- | # semodule -i my-httpd.pp | + | |
+ | < | ||
+ | [root@redhat9 ~]# mount -a | ||
+ | mount: (hint) your fstab has been modified, but systemd still uses | ||
+ | the old version; use ' | ||
- | Additional Information: | + | [root@redhat9 ~]# mount | grep volume |
- | Source Context | + | /dev/mapper/stratis-1-4cfd12ac57e74c9d8f486c33f482fc46-thin-fs-e80a1eeb95d0413a86412a07ea685b6a on /volume type xfs (rw, |
- | Target Context | + | |
- | Target Objects | + | |
- | Source | + | |
- | Source Path /usr/sbin/httpd | + | |
- | Port < | + | |
- | Host < | + | |
- | Source RPM Packages | + | |
- | Target RPM Packages | + | |
- | Policy RPM selinux-policy-3.13.1-166.el7_4.9.noarch | + | |
- | Selinux Enabled | + | |
- | Policy Type | + | |
- | Enforcing Mode Permissive | + | |
- | Host Name | + | |
- | Platform | + | |
- | 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 | + | |
- | 19:03:37 UTC 2018 x86_64 x86_64 | + | |
- | Alert Count 1 | + | |
- | First Seen 2020-01-23 16:04:30 CET | + | |
- | Last Seen | + | |
- | Local ID 096941d6-1c72-49bd-862b-9bfc3aad32e5 | + | |
- | Raw Audit Messages | + | [root@redhat9 ~]# systemctl daemon-reload |
- | type=AVC msg=audit(1579791870.276: | + | </code> |
+ | ===Croissance Dynamique du Système de Fichiers=== | ||
- | type=SYSCALL msg=audit(1579791870.276:244): arch=x86_64 syscall=stat success=yes exit=0 a0=56255c9727b8 a1=7ffd44466030 a2=7ffd44466030 a3=7f3a4d9ab712 items=0 ppid=1722 pid=1728 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm=httpd exe=/ | + | Consultez l' |
- | Hash: httpd, | + | < |
+ | [root@redhat9 ~]# stratis filesystem list | ||
+ | Pool Filesystem | ||
+ | pool1 | ||
</ | </ | ||
- | Ce message a été généré parce que le repertoire /www ainsi que le fichier | + | Créez un fichier |
< | < | ||
- | [root@centos6 | + | [root@redhat9 |
- | -rw-r--r--. root root unconfined_u: | + | 2048+0 records in |
+ | 2048+0 records out | ||
+ | 2147483648 bytes (2.1 GB, 2.0 GiB) copied, 26.3089 s, 81.6 MB/s | ||
</ | </ | ||
+ | |||
+ | Consultez l' | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | -rw-r--r--. root root unconfined_u:object_r: | + | Pool Filesystem |
+ | pool1 | ||
</ | </ | ||
- | L' | + | <WRAP center round important 60%> |
+ | **Important** : Notez que l' | ||
+ | </ | ||
- | Modifiez donc la SC de /www et / | + | ===Création d'un Snapshot=== |
+ | |||
+ | Créez le snapshot **filesystem1-snap** | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | changing security context of ‘/ | + | </code> |
- | changing security context of ‘/www’ | + | |
- | [root@centos7 | + | Vérifiez la présence du snapshot : |
- | -rw-r--r--. root root unconfined_u: | + | |
+ | < | ||
+ | [root@redhat9 | ||
+ | Pool Filesystem | ||
+ | pool1 | ||
+ | pool1 | ||
</ | </ | ||
- | Afin de maintenir ces SC lors d' | + | Supprimez le fichier |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
- | ====La commande restorecon==== | + | Vérifiez la suppression de **/ |
- | <file> | + | <code> |
- | usage: | + | [root@redhat9 ~]# ls -l /volume |
- | </file> | + | total 0 |
+ | </code> | ||
- | Pour illustrer l' | + | Créez |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | [root@centos7 tmp]# ls -Z | grep html | + | |
- | -rw-r--r--. root root unconfined_u: | + | |
- | -rw-r--r--. root root unconfined_u: | + | |
</ | </ | ||
- | **Copiez** le fichier copy.html vers /var/www/html et **déplacez** le fichier move.html vers la même cible : | + | Montez |
< | < | ||
- | [root@centos7 tmp]# cp copy.html | + | [root@redhat9 ~]# mount /dev/stratis/pool1/filesystem1-snap /filesystem1-snap |
- | [root@centos7 tmp]# mv move.html / | + | |
- | [root@centos7 tmp]# ls -Z /var/ | + | |
- | -rw-r--r--. root root unconfined_u: | + | |
- | -rw-r--r--. root root unconfined_u: | + | |
- | -rw-r--r--. root root unconfined_u: | + | |
</ | </ | ||
- | <WRAP center round important 50%> | + | Vérifiez la présence du fichier **/ |
- | **Important** : Notez ici que copy.html a pris le type du répertoire | + | |
+ | <code> | ||
+ | [root@redhat9 ~]# ls -l / | ||
+ | total 2097152 | ||
+ | -rw-r--r--. 1 root root 2147483648 Oct 24 07:37 file | ||
+ | </ | ||
+ | |||
+ | ===Suppression des Systèmes de Fichiers=== | ||
+ | |||
+ | Démontez les deux systèmes de fichiers : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# umount /volume | ||
+ | |||
+ | [root@redhat9 ~]# umount / | ||
+ | </ | ||
+ | |||
+ | Supprimez les deux systèmes de fichiers : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# stratis filesystem destroy pool1 filesystem1-snap | ||
+ | |||
+ | [root@redhat9 ~]# stratis filesystem destroy pool1 filesystem1 | ||
+ | |||
+ | [root@redhat9 ~]# stratis filesystem list | ||
+ | Pool | ||
+ | </ | ||
+ | |||
+ | Editez le fichier | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# vi / | ||
+ | [root@redhat9 ~]# cat / | ||
+ | |||
+ | # | ||
+ | # / | ||
+ | # Created by anaconda on Thu Oct 19 16:05:58 2023 | ||
+ | # | ||
+ | # Accessible filesystems, | ||
+ | # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. | ||
+ | # | ||
+ | # After editing this file, run ' | ||
+ | # units generated from this file. | ||
+ | # | ||
+ | / | ||
+ | UUID=6f6c5bb9-30be-4734-bc23-03fed8541616 /boot | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Supprimez les deux points de montage : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# rm -rf /volume / | ||
+ | </ | ||
+ | |||
+ | Désactiver et arrêtez | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl disable --now stratisd | ||
+ | Removed "/ | ||
+ | |||
+ | [root@redhat9 ~]# systemctl status stratisd | ||
+ | ○ stratisd.service - Stratis daemon | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | |||
+ | Oct 24 07:58:07 redhat9.ittraining.loc stratisd[2676]: | ||
+ | Oct 24 07:58:14 redhat9.ittraining.loc stratisd[2676]: | ||
+ | Oct 24 08:02:37 redhat9.ittraining.loc systemd[1]: Stopping Stratis daemon... | ||
+ | Oct 24 08:02:37 redhat9.ittraining.loc stratisd[2676]: | ||
+ | Oct 24 08:02:37 redhat9.ittraining.loc stratisd[2676]: | ||
+ | Oct 24 08:02:37 redhat9.ittraining.loc stratisd[2676]: | ||
+ | Oct 24 08:02:37 redhat9.ittraining.loc stratisd[2676]: | ||
+ | Oct 24 08:02:37 redhat9.ittraining.loc systemd[1]: stratisd.service: | ||
+ | Oct 24 08:02:37 redhat9.ittraining.loc systemd[1]: Stopped Stratis daemon. | ||
+ | Oct 24 08:02:37 redhat9.ittraining.loc systemd[1]: stratisd.service: | ||
+ | </ | ||
+ | |||
+ | =====Systèmes | ||
+ | |||
+ | ====Présentation==== | ||
+ | |||
+ | Un journal est la partie d'un système de fichiers journalisé qui trace les opérations d' | ||
+ | |||
+ | L' | ||
+ | |||
+ | Sans un tel fichier journal, un outil de récupération de données après un arrêt brutal doit parcourir l' | ||
+ | |||
+ | Linux peut utiliser un des systèmes de fichiers journalisés suivants : | ||
+ | |||
+ | ^ Système de fichier ^ Taille maximum - fichier ^ Taille maximum - système de fichier ^ | ||
+ | | **[[http:// | ||
+ | | **[[http:// | ||
+ | | **[[http:// | ||
+ | | **[[http:// | ||
+ | | **[[http:// | ||
+ | | **[[https:// | ||
+ | |||
+ | <WRAP center round todo 60%> | ||
+ | **A faire** : Pour comparer ces six systèmes de fichier, veuillez consulter **[[http:// | ||
</ | </ | ||
- | Restaurez maintenant la SC par défaut | + | ====LAB #13 - Ext3==== |
+ | |||
+ | Ext3 est une évolution | ||
+ | |||
+ | * être utilisé à partir d'une partition Ext2, sans avoir à sauvegarder et à restaurer des données, | ||
+ | * utiliser tous les utilitaires | ||
+ | | ||
+ | |||
+ | Pour plus d' | ||
+ | |||
+ | ===13.1 - Gestion d' | ||
+ | |||
+ | Notez maintenant le numéro de la dernière partition que vous avez précédemment créée | ||
< | < | ||
- | [root@centos7 tmp]# restorecon | + | [root@redhat9 ~]# fdisk -l |
- | restorecon reset /var/www/html/ | + | Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 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: 0xd00dfc8a | ||
- | [root@centos7 tmp]# ls -Z /var/www/html | + | Device |
- | -rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 copy.html | + | /dev/ |
- | -rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 index.html | + | /dev/sda2 |
- | -rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 move.html | + | |
+ | |||
+ | Disk /dev/sdb: 32 GiB, 34359738368 bytes, 67108864 sectors | ||
+ | Disk model: QEMU HARDDISK | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disklabel type: dos | ||
+ | Disk identifier: 0x23a56c2e | ||
+ | |||
+ | Device | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | |||
+ | |||
+ | Disk /dev/sdc: 6 GiB, 6442450944 bytes, 12582912 sectors | ||
+ | Disk model: QEMU HARDDISK | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | |||
+ | |||
+ | Disk /dev/sdd: 6 GiB, 6442450944 bytes, 12582912 sectors | ||
+ | Disk model: QEMU HARDDISK | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | |||
+ | |||
+ | Disk /dev/sde: 32 GiB, 34359738368 bytes, 67108864 sectors | ||
+ | Disk model: QEMU HARDDISK | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | |||
+ | |||
+ | Disk / | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | |||
+ | |||
+ | Disk / | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | |||
+ | |||
+ | Disk /dev/md1: 996 MiB, 1044381696 bytes, 2039808 sectors | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | |||
+ | |||
+ | Disk / | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | |||
+ | |||
+ | Disk / | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
</ | </ | ||
- | ====Le fichier /.autorelabel==== | + | Créez un filesystem Ext3 sur /dev/sdb12 en utilisant la commande **mke2fs -j** : |
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mke2fs -j / | ||
+ | mke2fs 1.46.5 (30-Dec-2021) | ||
+ | Discarding device blocks: done | ||
+ | Creating filesystem with 204800 1k blocks and 51200 inodes | ||
+ | Filesystem UUID: f489fe51-2f8b-444a-af89-9bb5b6301214 | ||
+ | Superblock backups stored on blocks: | ||
+ | 8193, 24577, 40961, 57345, 73729 | ||
+ | |||
+ | Allocating group tables: done | ||
+ | Writing inode tables: done | ||
+ | Creating journal (4096 blocks): done | ||
+ | Writing superblocks and filesystem accounting information: | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Lors de la mise en place d'un filesystem ext2/ | ||
+ | </ | ||
+ | |||
+ | ===13.2 - Convertir un Système de Fichiers Ext3 en Ext2=== | ||
- | En cas de besoin il est intéressant de pouvoir restaurer les SC par défaut sur l' | + | Pour vérifier si un système |
< | < | ||
- | [root@centos7 tmp]# touch /.autorelabel | + | [root@redhat9 ~]# dumpe2fs -h /dev/sdb12 |
- | [root@centos7 tmp]# shutdown | + | dumpe2fs 1.46.5 (30-Dec-2021) |
+ | Filesystem volume name: < | ||
+ | Last mounted on: <not available> | ||
+ | Filesystem UUID: f489fe51-2f8b-444a-af89-9bb5b6301214 | ||
+ | Filesystem magic number: | ||
+ | Filesystem revision | ||
+ | Filesystem features: | ||
+ | Filesystem flags: | ||
+ | Default mount options: | ||
+ | Filesystem state: | ||
+ | Errors behavior: | ||
+ | Filesystem OS type: | ||
+ | Inode count: | ||
+ | Block count: | ||
+ | Reserved block count: | ||
+ | Overhead clusters: | ||
+ | Free blocks: | ||
+ | Free inodes: | ||
+ | First block: | ||
+ | Block size: | ||
+ | Fragment size: 1024 | ||
+ | Reserved GDT blocks: | ||
+ | Blocks per group: | ||
+ | Fragments per group: | ||
+ | Inodes per group: | ||
+ | Inode blocks per group: | ||
+ | Filesystem created: | ||
+ | Last mount time: n/a | ||
+ | Last write time: Thu Oct 24 08:26:00 2024 | ||
+ | Mount count: | ||
+ | Maximum mount count: | ||
+ | Last checked: | ||
+ | Check interval: | ||
+ | Reserved blocks uid: 0 (user root) | ||
+ | Reserved blocks gid: 0 (group root) | ||
+ | First inode: | ||
+ | Inode size: 256 | ||
+ | Required extra isize: | ||
+ | Desired extra isize: | ||
+ | Journal inode: | ||
+ | Default directory hash: | ||
+ | Directory Hash Seed: e7f0145e-3007-4ee4-b433-4ac7d3480c57 | ||
+ | Journal backup: | ||
+ | Journal features: | ||
+ | Total journal size: | ||
+ | Total journal blocks: | ||
+ | Max transaction length: | ||
+ | Fast commit length: | ||
+ | Journal sequence: | ||
+ | Journal start: | ||
</ | </ | ||
- | ====La commande semanage==== | + | <WRAP center round important 60%> |
+ | **Important** : Le drapeau **Filesystem features: | ||
+ | </ | ||
- | La commande **semanage** peut prendre plusieurs options : | + | Pour supprimer le journal du système de fichier Ext3 sur cette partition, il convient d' |
< | < | ||
- | [root@centos7 tmp]# semanage | + | [root@redhat9 ~]# tune2fs |
- | usage: semanage [-h] | + | tune2fs 1.46.5 (30-Dec-2021) |
- | + | </ | |
- | {import, | + | |
- | ... | + | |
- | semanage is used to configure certain elements of SELinux policy with-out | + | Constatez le résultat de cette commande : |
- | requiring modification to or recompilation from policy source. | + | |
- | positional arguments: | + | < |
- | | + | [root@redhat9 ~]# dumpe2fs -h / |
- | | + | dumpe2fs 1.46.5 (30-Dec-2021) |
- | | + | Filesystem volume name: < |
- | | + | Last mounted on: <not available> |
- | | + | Filesystem UUID: f489fe51-2f8b-444a-af89-9bb5b6301214 |
- | | + | Filesystem magic number: |
- | | + | Filesystem revision #: 1 (dynamic) |
- | | + | Filesystem features: |
- | | + | Filesystem flags: |
- | module | + | Default mount options: |
- | | + | Filesystem state: |
- | | + | Errors behavior: |
- | | + | Filesystem OS type: |
- | | + | Inode count: |
- | | + | Block count: |
+ | Reserved block count: | ||
+ | Overhead clusters: | ||
+ | Free blocks: | ||
+ | Free inodes: | ||
+ | First block: | ||
+ | Block size: | ||
+ | Fragment size: 1024 | ||
+ | Reserved GDT blocks: | ||
+ | Blocks per group: | ||
+ | Fragments per group: | ||
+ | Inodes per group: | ||
+ | Inode blocks per group: | ||
+ | Filesystem created: | ||
+ | Last mount time: n/a | ||
+ | Last write time: Thu Oct 24 08:27:14 2024 | ||
+ | Mount count: | ||
+ | Maximum mount count: | ||
+ | Last checked: | ||
+ | Check interval: | ||
+ | Reserved blocks uid: 0 (user root) | ||
+ | Reserved blocks gid: 0 (group root) | ||
+ | First inode: | ||
+ | Inode size: 256 | ||
+ | Required extra isize: | ||
+ | Desired extra isize: | ||
+ | Default directory hash: | ||
+ | Directory Hash Seed: e7f0145e-3007-4ee4-b433-4ac7d3480c57 | ||
+ | Journal backup: | ||
+ | </code> | ||
- | optional arguments: | + | <WRAP center round important 60%> |
- | -h, --help show this help message and exit | + | **Important** |
+ | </ | ||
+ | |||
+ | Supprimez maintenant l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# fsck / | ||
+ | fsck from util-linux 2.37.4 | ||
+ | e2fsck 1.46.5 (30-Dec-2021) | ||
+ | /dev/sdb12: clean, 11/51200 files, 14413/ | ||
</ | </ | ||
- | Pour illustrer l' | + | Créez maintenant un point de montage pour /dev/sdb12 : |
- | %%SELinux%% gère aussi l' | + | < |
+ | [root@redhat9 ~]# mkdir / | ||
+ | </ | ||
+ | |||
+ | Essayez de monter /dev/sdb12 en tant que système de fichiers Ext3. Vous obtiendrez un résultat similaire | ||
< | < | ||
- | [root@centos7 tmp]# semanage port -l | + | [root@redhat9 ~]# mount -t ext3 /dev/sdb12 /mnt/sdb12 |
- | SELinux Port Type Proto Port Number | + | mount: /mnt/sdb12: wrong fs type, bad option, bad superblock on /dev/sdb12, missing codepage or helper program, or other error. |
+ | </ | ||
- | afs3_callback_port_t | + | <WRAP center round important |
- | afs3_callback_port_t | + | **Important** : Notez l' |
- | afs_bos_port_t | + | </ |
- | afs_fs_port_t | + | |
- | afs_fs_port_t | + | Montez maintenant le système de fichiers en tant que Ext2 : |
- | afs_ka_port_t | + | |
- | afs_pt_port_t | + | < |
- | afs_pt_port_t | + | [root@redhat9 ~]# mount -t ext2 /dev/sdb12 /mnt/sdb12 |
- | afs_vl_port_t | + | |
- | agentx_port_t | + | |
- | agentx_port_t | + | |
- | amanda_port_t | + | |
- | amanda_port_t | + | |
- | amavisd_recv_port_t | + | |
- | amavisd_send_port_t | + | |
- | amqp_port_t | + | |
- | amqp_port_t | + | |
- | aol_port_t | + | |
- | aol_port_t | + | |
- | apc_port_t | + | |
- | apc_port_t | + | |
- | apcupsd_port_t | + | |
- | apcupsd_port_t | + | |
- | apertus_ldp_port_t | + | |
- | apertus_ldp_port_t | + | |
- | asterisk_port_t | + | |
- | asterisk_port_t | + | |
- | audit_port_t | + | |
- | auth_port_t | + | |
- | bacula_port_t | + | |
- | bacula_port_t | + | |
- | bctp_port_t | + | |
- | bctp_port_t | + | |
- | bgp_port_t | + | |
- | bgp_port_t | + | |
- | boinc_client_port_t | + | |
- | boinc_client_port_t | + | |
- | boinc_port_t | + | |
- | brlp_port_t | + | |
- | certmaster_port_t | + | |
- | chronyd_port_t | + | |
- | clamd_port_t | + | |
- | clockspeed_port_t | + | |
- | cluster_port_t | + | |
- | cluster_port_t | + | |
- | cma_port_t | + | |
- | cma_port_t | + | |
- | cobbler_port_t | + | |
- | collectd_port_t | + | |
- | commplex_link_port_t | + | |
- | commplex_link_port_t | + | |
- | commplex_main_port_t | + | |
- | commplex_main_port_t | + | |
- | comsat_port_t | + | |
- | condor_port_t | + | |
- | condor_port_t | + | |
- | conman_port_t | + | |
- | conman_port_t | + | |
- | connlcli_port_t | + | |
- | connlcli_port_t | + | |
- | couchdb_port_t | + | |
- | couchdb_port_t | + | |
- | ctdb_port_t | + | |
- | ctdb_port_t | + | |
- | cvs_port_t | + | |
- | cvs_port_t | + | |
- | cyphesis_port_t | + | |
- | cyphesis_port_t | + | |
- | cyrus_imapd_port_t | + | |
- | daap_port_t | + | |
- | daap_port_t | + | |
- | dbskkd_port_t | + | |
- | dcc_port_t | + | |
- | dccm_port_t | + | |
- | dccm_port_t | + | |
- | dey_keyneg_port_t | + | |
- | dey_keyneg_port_t | + | |
- | dey_sapi_port_t | + | |
- | dhcpc_port_t | + | |
- | dhcpc_port_t | + | |
- | dhcpd_port_t | + | |
- | dhcpd_port_t | + | |
- | dict_port_t | + | |
- | distccd_port_t | + | |
- | dns_port_t | + | |
- | dns_port_t | + | |
- | dnssec_port_t | + | |
- | dogtag_port_t | + | |
- | echo_port_t | + | |
- | echo_port_t | + | |
- | efs_port_t | + | |
- | embrace_dp_c_port_t | + | |
- | embrace_dp_c_port_t | + | |
- | ephemeral_port_t | + | |
- | ephemeral_port_t | + | |
- | epmap_port_t | + | |
- | epmap_port_t | + | |
- | epmd_port_t | + | |
- | epmd_port_t | + | |
- | fac_restore_port_t | + | |
- | fac_restore_port_t | + | |
- | fingerd_port_t | + | |
- | flash_port_t | + | |
- | flash_port_t | + | |
- | fmpro_internal_port_t | + | |
- | fmpro_internal_port_t | + | |
- | freeipmi_port_t | + | |
- | freeipmi_port_t | + | |
- | ftp_data_port_t | + | |
- | ftp_port_t | + | |
- | ftp_port_t | + | |
- | gatekeeper_port_t | + | |
- | gatekeeper_port_t | + | |
- | gdomap_port_t | + | |
- | gdomap_port_t | + | |
- | gds_db_port_t | + | |
- | gds_db_port_t | + | |
- | gear_port_t | + | |
- | gear_port_t | + | |
- | geneve_port_t | + | |
- | giftd_port_t | + | |
- | git_port_t | + | |
- | git_port_t | + | |
- | glance_port_t | + | |
- | glance_port_t | + | |
- | glance_registry_port_t | + | |
- | glance_registry_port_t | + | |
- | gluster_port_t | + | |
- | gluster_port_t | + | |
- | gopher_port_t | + | |
- | gopher_port_t | + | |
- | gpsd_port_t | + | |
- | hadoop_datanode_port_t | + | |
- | hadoop_namenode_port_t | + | |
- | hddtemp_port_t | + | |
- | hi_reserved_port_t | + | |
- | hi_reserved_port_t | + | |
- | howl_port_t | + | |
- | howl_port_t | + | |
- | hplip_port_t | + | |
- | http_cache_port_t | + | |
- | http_cache_port_t | + | |
- | http_port_t | + | |
- | ... | + | |
</ | </ | ||
- | Notez par exemple que le serveur apache est autorisé d' | + | ===13.3 - Convertir un Système de Fichiers Ext2 en Ext3=== |
- | < | + | Pour replacer le journal sur /dev/sdb12, il convient d' |
- | http_port_t | + | |
- | </ | + | |
- | Dans le cas où on souhaite qu' | + | < |
+ | [root@redhat9 ~]# umount / | ||
+ | |||
+ | [root@redhat9 ~]# tune2fs -j / | ||
+ | tune2fs 1.46.5 (30-Dec-2021) | ||
+ | Creating journal inode: done | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Notez que vous avez du démonter | ||
+ | </ | ||
+ | |||
+ | ===13.4 - Placer le Journal sur un autre Partition=== | ||
+ | |||
+ | Le journal d'un système de fichiers peut être placé sur un autre périphérique bloc. | ||
+ | |||
+ | Créez un système de fichiers sur / | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | mdadm: stopped /dev/md1 | ||
+ | |||
+ | [root@redhat9 ~]# mke2fs -O journal_dev / | ||
+ | mke2fs 1.46.5 (30-Dec-2021) | ||
+ | /dev/sdb11 contains | ||
+ | Proceed anyway? (y,N) y | ||
+ | Discarding device blocks: done | ||
+ | Creating filesystem with 512000 1k blocks and 0 inodes | ||
+ | Filesystem UUID: 5ab9820b-f652-4e79-99a9-07f5581cb312 | ||
+ | Superblock backups stored on blocks: | ||
+ | |||
+ | Zeroing journal device: | ||
</ | </ | ||
- | Vous noterez que le port 8090 a été ajouté à la liste des ports reconnus comme valides par %%SELinux%% | + | <WRAP center round important 60%> |
+ | **Important** : Notez l' | ||
+ | </ | ||
+ | |||
+ | Créez maintenant un système de fichiers Ext3 sur /dev/sdb12 en plaçant | ||
< | < | ||
- | [root@centos7 tmp]# semanage port -l | grep http | + | [root@redhat9 ~]# mke2fs |
- | http_cache_port_t | + | mke2fs 1.46.5 (30-Dec-2021) |
- | http_cache_port_t | + | Using journal device' |
- | http_port_t | + | /dev/sdb12 contains a ext3 file system |
- | pegasus_http_port_t | + | last mounted on Thu Oct 24 08:29:20 2024 |
- | pegasus_https_port_t | + | Proceed anyway? (y,N) y |
+ | Discarding device blocks: done | ||
+ | Creating filesystem with 204800 1k blocks and 51200 inodes | ||
+ | Filesystem UUID: ac7c133a-3f15-4fa4-81df-b1a0c808a4d0 | ||
+ | Superblock backups stored on blocks: | ||
+ | 8193, 24577, 40961, 57345, 73729 | ||
+ | |||
+ | Allocating group tables: done | ||
+ | Writing inode tables: done | ||
+ | Adding journal to device /dev/sdb11: done | ||
+ | Writing superblocks and filesystem accounting information: | ||
</ | </ | ||
- | ====La commande audit2allow==== | + | <WRAP center round important 60%> |
+ | **Important** : Notez que le journal a été placé sur /dev/sdb11 graĉe à l' | ||
+ | </ | ||
+ | |||
+ | ===13.5 - Modifier la Fréquence de Vérification du Système de Fichiers Ext3=== | ||
+ | |||
+ | Pour modifier la fréquence de vérification du système de fichiers sur /dev/sdb12, il convient d' | ||
< | < | ||
- | [root@centos7 tmp]# audit2allow | + | [root@redhat9 ~]# tune2fs |
- | Usage: audit2allow [options] | + | tune2fs 1.46.5 (30-Dec-2021) |
+ | Setting interval between checks to 8640000 seconds | ||
+ | </ | ||
+ | Dernièrement, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# dumpe2fs /dev/sdb12 | grep UUID | ||
+ | dumpe2fs 1.46.5 (30-Dec-2021) | ||
+ | Filesystem UUID: ac7c133a-3f15-4fa4-81df-b1a0c808a4d0 | ||
+ | Journal UUID: | ||
+ | </ | ||
+ | |||
+ | ====LAB #14 - Ext4==== | ||
+ | |||
+ | Le système de fichiers **Ext4** a été introduit dans le noyau **2.6.19** en mode expérimental et est devenu stable dans le noyau **2.6.28**. | ||
+ | |||
+ | Ext4 n'est pas une évolution de Ext3. Cependant il a une compatibilité ascendante avec Ext3. | ||
+ | |||
+ | Les fonctionnalités majeures d'Ext4 sont : | ||
+ | |||
+ | * la gestion des volumes d'une taille allant jusqu' | ||
+ | * l' | ||
+ | |||
+ | L' | ||
+ | |||
+ | La compatibilité ascendante avec ext3 comprend : | ||
+ | |||
+ | * la possibilité de monter une partition Ext3 en tant que partition Ext4, | ||
+ | * la possibilité de monter une partition Ext4 en tant que partition Ext3 mais **uniquement** dans le cas où la partition Ext4 n'ait jamais utilisé l' | ||
+ | |||
+ | Pour plus d' | ||
+ | |||
+ | ===14.1 - Créer un Système de Fichiers Ext4=== | ||
+ | |||
+ | Créez un système de fichiers Ext4 sur **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mkfs.ext4 /dev/sdb11 | ||
+ | mke2fs 1.46.5 (30-Dec-2021) | ||
+ | /dev/sdb11 contains a jbd file system | ||
+ | Proceed anyway? (y,N) y | ||
+ | Discarding device blocks: done | ||
+ | Creating filesystem with 512000 1k blocks and 128016 inodes | ||
+ | Filesystem UUID: 52c3fea6-d28b-40db-b7e5-d3c289b51043 | ||
+ | Superblock backups stored on blocks: | ||
+ | 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409 | ||
+ | |||
+ | Allocating group tables: done | ||
+ | Writing inode tables: done | ||
+ | Creating journal (8192 blocks): done | ||
+ | Writing superblocks and filesystem accounting information: | ||
+ | </ | ||
+ | |||
+ | Consultez maintenant les caractéristiques du système de fichier : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# dumpe2fs /dev/sdb11 | more | ||
+ | dumpe2fs 1.46.5 (30-Dec-2021) | ||
+ | Filesystem volume name: < | ||
+ | Last mounted on: <not available> | ||
+ | Filesystem UUID: 52c3fea6-d28b-40db-b7e5-d3c289b51043 | ||
+ | Filesystem magic number: | ||
+ | Filesystem revision #: 1 (dynamic) | ||
+ | Filesystem features: | ||
+ | Filesystem flags: | ||
+ | Default mount options: | ||
+ | Filesystem state: | ||
+ | Errors behavior: | ||
+ | Filesystem OS type: Linux | ||
+ | Inode count: | ||
+ | Block count: | ||
+ | Reserved block count: | ||
+ | Overhead clusters: | ||
+ | Free blocks: | ||
+ | Free inodes: | ||
+ | First block: | ||
+ | Block size: 1024 | ||
+ | Fragment size: 1024 | ||
+ | Group descriptor size: 64 | ||
+ | Reserved GDT blocks: | ||
+ | Blocks per group: | ||
+ | Fragments per group: | ||
+ | Inodes per group: | ||
+ | Inode blocks per group: | ||
+ | Flex block group size: 16 | ||
+ | Filesystem created: | ||
+ | Last mount time: n/a | ||
+ | Last write time: Thu Oct 24 08:35:02 2024 | ||
+ | Mount count: | ||
+ | Maximum mount count: | ||
+ | Last checked: | ||
+ | Check interval: | ||
+ | Lifetime writes: | ||
+ | Reserved blocks uid: 0 (user root) | ||
+ | Reserved blocks gid: 0 (group root) | ||
+ | First inode: | ||
+ | Inode size: 256 | ||
+ | Required extra isize: | ||
+ | Desired extra isize: | ||
+ | Journal inode: | ||
+ | Default directory hash: | ||
+ | Directory Hash Seed: 6bf0e2d7-9fb0-4c7b-8d32-b0ca3113c0cd | ||
+ | Journal backup: | ||
+ | Checksum type: crc32c | ||
+ | Checksum: | ||
+ | Journal features: | ||
+ | Total journal size: 8M | ||
+ | Total journal blocks: | ||
+ | Max transaction length: | ||
+ | Fast commit length: | ||
+ | Journal sequence: | ||
+ | Journal start: | ||
+ | |||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | ===14.2 - Ajouter une Etiquette au Système de Fichiers Ext4=== | ||
+ | |||
+ | Utilisez la commande **e2label** pour associer une étiquette au système de fichiers : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# e2label /dev/sdb11 my_ext4 | ||
+ | |||
+ | [root@redhat9 ~]# dumpe2fs /dev/sdb11 | more | ||
+ | dumpe2fs 1.46.5 (30-Dec-2021) | ||
+ | Filesystem volume name: | ||
+ | Last mounted on: <not available> | ||
+ | Filesystem UUID: 52c3fea6-d28b-40db-b7e5-d3c289b51043 | ||
+ | Filesystem magic number: | ||
+ | Filesystem revision #: 1 (dynamic) | ||
+ | Filesystem features: | ||
+ | Filesystem flags: | ||
+ | Default mount options: | ||
+ | Filesystem state: | ||
+ | Errors behavior: | ||
+ | Filesystem OS type: Linux | ||
+ | Inode count: | ||
+ | Block count: | ||
+ | Reserved block count: | ||
+ | Overhead clusters: | ||
+ | Free blocks: | ||
+ | Free inodes: | ||
+ | First block: | ||
+ | Block size: 1024 | ||
+ | Fragment size: 1024 | ||
+ | Group descriptor size: 64 | ||
+ | Reserved GDT blocks: | ||
+ | Blocks per group: | ||
+ | Fragments per group: | ||
+ | Inodes per group: | ||
+ | Inode blocks per group: | ||
+ | Flex block group size: 16 | ||
+ | Filesystem created: | ||
+ | Last mount time: n/a | ||
+ | Last write time: Thu Oct 24 08:36:06 2024 | ||
+ | Mount count: | ||
+ | Maximum mount count: | ||
+ | Last checked: | ||
+ | Check interval: | ||
+ | Lifetime writes: | ||
+ | Reserved blocks uid: 0 (user root) | ||
+ | Reserved blocks gid: 0 (group root) | ||
+ | First inode: | ||
+ | Inode size: 256 | ||
+ | Required extra isize: | ||
+ | Desired extra isize: | ||
+ | Journal inode: | ||
+ | Default directory hash: | ||
+ | Directory Hash Seed: 6bf0e2d7-9fb0-4c7b-8d32-b0ca3113c0cd | ||
+ | Journal backup: | ||
+ | Checksum type: crc32c | ||
+ | Checksum: | ||
+ | Journal features: | ||
+ | Total journal size: 8M | ||
+ | Total journal blocks: | ||
+ | Max transaction length: | ||
+ | Fast commit length: | ||
+ | Journal sequence: | ||
+ | Journal start: | ||
+ | |||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** - Notez que l' | ||
+ | </ | ||
+ | |||
+ | Créez un point de montage dans **/mnt** et essayez de monter **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mkdir /mnt/sdb11 | ||
+ | |||
+ | [root@redhat9 ~]# mount -t ext3 /dev/sdb11 /mnt/sdb11 | ||
+ | mount: /mnt/sdb11: wrong fs type, bad option, bad superblock on /dev/sdb11, missing codepage or helper program, or other error. | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** - Notez l' | ||
+ | </ | ||
+ | |||
+ | Montez de nouveau la partition **sans** stipuler le type de système de fichiers : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mount /dev/sdb11 /mnt/sdb11 | ||
+ | |||
+ | [root@redhat9 ~]# mount | grep sdb11 | ||
+ | /dev/sdb11 on /mnt/sdb11 type ext4 (rw, | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** - Constatez que la partition a été monté en tant qu' | ||
+ | </ | ||
+ | |||
+ | ===14.3 - Convertir un Système de Fichiers Ext3 en Ext4=== | ||
+ | |||
+ | Créez un système de fichiers ext3 sur /dev/sdb12 : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mkfs.ext3 /dev/sdb12 | ||
+ | mke2fs 1.46.5 (30-Dec-2021) | ||
+ | /dev/sdb12 contains a ext3 file system | ||
+ | created on Thu Oct 24 08:33:41 2024 | ||
+ | Proceed anyway? (y,N) y | ||
+ | Discarding device blocks: done | ||
+ | Creating filesystem with 204800 1k blocks and 51200 inodes | ||
+ | Filesystem UUID: aed27e98-82d1-4a9d-a072-5f73162e8f4c | ||
+ | Superblock backups stored on blocks: | ||
+ | 8193, 24577, 40961, 57345, 73729 | ||
+ | |||
+ | Allocating group tables: done | ||
+ | Writing inode tables: done | ||
+ | Creating journal (4096 blocks): done | ||
+ | Writing superblocks and filesystem accounting information: | ||
+ | </ | ||
+ | |||
+ | Montez maintenant **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mount /dev/sdb12 /mnt/sdb12 | ||
+ | |||
+ | [root@redhat9 ~]# ls -l /mnt/sdb12 | ||
+ | total 12 | ||
+ | drwx------. 2 root root 12288 Oct 24 08:38 lost+found | ||
+ | </ | ||
+ | |||
+ | Créez le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# touch / | ||
+ | </ | ||
+ | |||
+ | Injectez la chaine **check file** dans le fichier / | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# echo "check file" > / | ||
+ | |||
+ | [root@redhat9 ~]# umount /dev/sdb12 | ||
+ | </ | ||
+ | |||
+ | Exécutez e2fsck sur /dev/sda12 : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# e2fsck /dev/sdb12 | ||
+ | e2fsck 1.46.5 (30-Dec-2021) | ||
+ | /dev/sdb12: clean, 12/51200 files, 18527/ | ||
+ | </ | ||
+ | |||
+ | Convertissez /dev/sdb12 en Ext4 : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# tune2fs -O extents, | ||
+ | tune2fs 1.46.5 (30-Dec-2021) | ||
+ | </ | ||
+ | |||
+ | Optimisez le système de fichiers : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# e2fsck -fDC0 /dev/sdb12 | ||
+ | e2fsck 1.46.5 (30-Dec-2021) | ||
+ | Pass 1: Checking inodes, blocks, and sizes | ||
+ | Pass 2: Checking directory structure | ||
+ | Pass 3: Checking directory connectivity | ||
+ | Pass 3A: Optimizing directories | ||
+ | Pass 4: Checking reference counts | ||
+ | Pass 5: Checking group summary information | ||
+ | | ||
+ | /dev/sdb12: ***** FILE SYSTEM WAS MODIFIED ***** | ||
+ | /dev/sdb12: 12/51200 files (0.0% non-contiguous), | ||
+ | </ | ||
+ | |||
+ | Essayez de monter **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mount -t ext3 /dev/sdb12 /mnt/sdb12 | ||
+ | mount: /mnt/sdb12: wrong fs type, bad option, bad superblock on /dev/sdb12, missing codepage or helper program, or other error. | ||
+ | </ | ||
+ | |||
+ | Montez /dev/sdb12 sans spécifier le type de fichiers Ext3 et vérifiez le contenu du fichier **check_file** : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mount /dev/sdb12 /mnt/sdb12 | ||
+ | |||
+ | [root@redhat9 ~]# ls -l /mnt/sdb12 | ||
+ | total 13 | ||
+ | -rw-r--r--. 1 root root 11 Oct 24 08:39 check_file | ||
+ | drwx------. 2 root root 12288 Oct 24 08:38 lost+found | ||
+ | |||
+ | [root@redhat9 ~]# cat / | ||
+ | check file | ||
+ | </ | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# dumpe2fs /dev/sdb11 | grep UUID | ||
+ | dumpe2fs 1.46.5 (30-Dec-2021) | ||
+ | Filesystem UUID: 52c3fea6-d28b-40db-b7e5-d3c289b51043 | ||
+ | |||
+ | [root@redhat9 ~]# dumpe2fs /dev/sdb12 | grep UUID | ||
+ | dumpe2fs 1.46.5 (30-Dec-2021) | ||
+ | Filesystem UUID: aed27e98-82d1-4a9d-a072-5f73162e8f4c | ||
+ | </ | ||
+ | |||
+ | ====LAB #15 - XFS==== | ||
+ | |||
+ | XFS est un système de fichiers 64-bit journalisé de haute performance crée par SGI pour son système d' | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Le système de fichiers XFS permet l' | ||
+ | </ | ||
+ | |||
+ | Pour plus d' | ||
+ | |||
+ | ===15.1 - Créer un Système de Fichiers XFS=== | ||
+ | |||
+ | Démontez **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# umount /dev/sdb12 | ||
+ | </ | ||
+ | |||
+ | Créez un système de fichiers XFS sur la partition **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mkfs.xfs -f /dev/sdb12 | ||
+ | Filesystem should be larger than 300MB. | ||
+ | Log size should be at least 64MB. | ||
+ | Support for filesystems like this one is deprecated and they will not be supported in future releases. | ||
+ | meta-data=/ | ||
+ | | ||
+ | | ||
+ | | ||
+ | data | ||
+ | | ||
+ | naming | ||
+ | log =internal log | ||
+ | | ||
+ | realtime =none | ||
+ | Discarding blocks...Done. | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** - Notez l' | ||
+ | </ | ||
+ | |||
+ | Consultez maintenant les caractéristiques du système de fichier : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# xfs_info /dev/sdb12 | ||
+ | meta-data=/ | ||
+ | | ||
+ | | ||
+ | | ||
+ | data | ||
+ | | ||
+ | naming | ||
+ | log =internal log | ||
+ | | ||
+ | realtime =none | ||
+ | </ | ||
+ | |||
+ | ===15.2 - Ajouter une Etiquette au Système de Fichiers XFS=== | ||
+ | |||
+ | Utilisez la commande **xfs_admin** pour associer une étiquette au système de fichiers : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# xfs_admin -L my_xfs /dev/sdb12 | ||
+ | writing all SBs | ||
+ | new label = " | ||
+ | </ | ||
+ | |||
+ | Pour voir l' | ||
+ | |||
+ | < | ||
+ | root@redhat9 ~]# xfs_admin -l /dev/sdb12 | ||
+ | label = " | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** - Notez que l' | ||
+ | </ | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# xfs_admin -u /dev/sdb12 | ||
+ | UUID = 0b61a609-6997-4c63-9de9-d3d316c4d5d7 | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** - La commande **xfs_metadump** est utilisée pour sauvegarder les méta-données du système de fichiers, tandis que la commande **xfs_mdrestore** est utilisée pour restaurer les les méta-données du système de fichiers. | ||
+ | </ | ||
+ | |||
+ | =====Autres Systèmes de Fichiers===== | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** - Veuillez noter que le support des systèmes de fichiers **ReiserFS**, | ||
+ | </ | ||
+ | |||
+ | ====ReiserFS==== | ||
+ | |||
+ | %%ReiserFS%% permet : | ||
+ | |||
+ | * de meilleurs temps d' | ||
+ | * une plus grande efficacité pour ce qui concerne le stockage des fichiers moins de quelques ko. Le gain d' | ||
+ | |||
+ | Pour plus d' | ||
+ | |||
+ | ====JFS==== | ||
+ | |||
+ | JFS //Journaled File System// est un système de fichiers journalisé mis au point par IBM et disponible sous licence GPL. | ||
+ | |||
+ | Pour plus d' | ||
+ | |||
+ | ====Btrfs==== | ||
+ | |||
+ | **[[https:// | ||
+ | |||
+ | A noter sont les points suivants : | ||
+ | |||
+ | * Btrfs utilise des extents, | ||
+ | * Btrfs stocke les données des très petits fichiers directement dans l' | ||
+ | * Btrfs gère une notion de « sous-volumes » permettant ainsi des snapshots, | ||
+ | * Btrfs possède ses techniques propres de protection des données, | ||
+ | * Btrfs permet de redimensionner à chaud la taille du système de fichiers, | ||
+ | * Btrfs gère le RAID 0 ainsi que le RAID 1 logiciel, | ||
+ | * Btrfs gère la comprssion du système de fichiers. | ||
+ | |||
+ | =====Comparaison des Commandes par Système de Fichiers===== | ||
+ | |||
+ | ^ Description ^ Ext3 ^ Ext4 ^ XFS ^ ReiserFS ^ JFS ^ Btrfs ^ | ||
+ | | Build a Linux filesystem | mkfs.ext3 (mke2fs -j) | mkfs.ext4 (mke4fs) | mkfs.xfs | mkfs.reiserfs (mkreiserfs) | mkfs.jfs (jfs_mkfs) | mkfs.btrfs | | ||
+ | | Check a Linux filesystem | e2fsck | e2fsck | xfs_check / xfs_repair | reiserfsck | jfs_fsck | btrfsck | | ||
+ | | Adjust tunable filesystem parameters Linux filesystems | tune2fs | tune2fs | xfs_admin | reiserfstune | jfs_tune | btrfs-show-super, | ||
+ | | File system resizer | resize2fs | resize2fs | xfs_growfs | resize_reiserfs | S/O | btrfs filesystem resize | | ||
+ | | Dump filesystem information | dumpe2fs | dumpe2fs | xfs_info / xfs_metadump | debugreiserfs | jfs_tune | btrfstune | | ||
+ | | File system debugger | debugfs | debugfs | xfs_db | debugreiserfs | jfs_debugfs | btrfs-debug-tree | | ||
+ | | Change the label on a filesystem | e2label | e2label | xfs_admin | reiserfstune | jfs_tune | btrfs filesystem label | | ||
+ | |||
+ | =====LAB #16 - Créer un Système de Fichiers ISO===== | ||
+ | |||
+ | ====16.1 - La Commande mkisofs==== | ||
+ | |||
+ | Pour créer un fichier ISO à partir d'une arborescence de fichiers, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cd /tmp | ||
+ | |||
+ | [root@redhat9 tmp]# mkisofs -r -T -o tmp.iso . | ||
+ | bash: mkisofs: command not found... | ||
+ | Install package ' | ||
+ | |||
+ | |||
+ | * Waiting in queue... | ||
+ | * Loading list of packages.... | ||
+ | The following packages have to be installed: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | Proceed with changes? [N/y] y | ||
+ | |||
+ | |||
+ | * Waiting in queue... | ||
+ | * Waiting for authentication... | ||
+ | * Waiting in queue... | ||
+ | * Downloading packages... | ||
+ | * Requesting data... | ||
+ | * Testing changes... | ||
+ | * Installing packages... | ||
+ | xorriso 1.5.4 : RockRidge filesystem manipulator, | ||
+ | |||
+ | Drive current: -outdev ' | ||
+ | Media current: stdio file, overwriteable | ||
+ | Media status : is blank | ||
+ | Media summary: 0 sessions, 0 data blocks, 0 data, 37.0g free | ||
+ | xorriso : NOTE : -as genisofs: Ignored option ' | ||
+ | Added to ISO image: directory '/' | ||
+ | xorriso : UPDATE : 37 files added in 1 seconds | ||
+ | xorriso : UPDATE : 37 files added in 1 seconds | ||
+ | ISO image produced: 202 sectors | ||
+ | Written to medium : 202 sectors at LBA 0 | ||
+ | Writing to ' | ||
+ | </ | ||
+ | |||
+ | Le fichier ISO peut être monter en utilisant un périphérique de type **loop** : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# mount tmp.iso /mnt -o loop | ||
+ | mount: /mnt: WARNING: source write-protected, | ||
+ | |||
+ | [root@redhat9 tmp]# ls /mnt | ||
+ | copy.html | ||
+ | dbus-59XI29LyuI | ||
+ | dbus-K54lUGWRFp | ||
+ | dbus-pLIWTki5B4 | ||
+ | dbus-UpdINCi7Cg | ||
+ | file1 systemd-private-aea59c32b8804212a7e18c402fe2ec29-ModemManager.service-yO8983 | ||
+ | |||
+ | [root@redhat9 tmp]# ls | ||
+ | copy.html | ||
+ | dbus-59XI29LyuI | ||
+ | dbus-K54lUGWRFp | ||
+ | dbus-pLIWTki5B4 | ||
+ | dbus-UpdINCi7Cg | ||
+ | file1 systemd-private-aea59c32b8804212a7e18c402fe2ec29-power-profiles-daemon.service-NoPIRE | ||
+ | file2 systemd-private-aea59c32b8804212a7e18c402fe2ec29-rtkit-daemon.service-RLivCo | ||
+ | </ | ||
+ | |||
+ | Démontez maintenant le fichier ISO : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 tmp]# cd ~ | ||
+ | |||
+ | [root@redhat9 ~]# umount / | ||
+ | </ | ||
+ | |||
+ | ====Options de la Commande mkisofs==== | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mkisofs --help | ||
+ | Usage: xorriso -as mkisofs [options] file... | ||
+ | Note: This is not mkisofs. See xorriso -help, xorriso -version, man xorrisofs | ||
Options: | Options: | ||
- | --version | + | -f, -follow-links |
- | -h, --help | + | -graft-points |
- | -b, --boot audit messages since last boot conflicts with -i | + | |
- | -a, --all | + | -hfsplus |
- | -p POLICY, | + | -hfsplus-file-creator-type CREATOR TYPE iso_rr_path |
- | | + | Attach creator |
- | -d, --dmesg read input from dmesg - conflicts with --all and | + | -hfs-bless FOLDER_NAME |
- | --input | + | |
- | -i INPUT, --input=INPUT | + | Bless ISO_RR_PATH by BLESS_TYPE {p,i,s,9,x} |
- | read input from < | + | -hfsplus-serial-no HEXSTRING |
- | -l, --lastreload | + | HFS serial number: 16 characters [0-9a-fA-F] |
- | -r, --requires | + | -hfsplus-block-size NUMBER |
- | -m MODULE, --module=MODULE | + | -apm-block-size NUMBER |
- | set the module name - implies | + | -hide GLOBFILE |
- | -M MODULE_PACKAGE, --module-package=MODULE_PACKAGE | + | -hide-list FILE |
- | | + | |
- | -o OUTPUT, | + | -hide-joliet-list FILE File with list of Joliet files to hide |
- | | + | |
- | -D, --dontaudit | + | -hide-hfsplus-list FILE File with list of HFS+ files to hide |
- | -R, --reference | + | |
- | -N, --noreference | + | -output-charset CHARSET |
- | -v, --verbose | + | -iso-level LEVEL Set ISO9660 conformance level (1..3) or 4 for ISO9660 version 2 |
- | -e, --explain | + | -disallow_dir_id_ext |
- | -t TYPE, --type=TYPE | + | -J, -joliet |
- | regex | + | -joliet-long |
- | --perm-map=PERM_MAP | + | -joliet-utf16 |
- | --interface-info=INTERFACE_INFO | + | -U, -untranslated-filenames Allow Untranslated filenames (for HPUX & AIX - violates ISO9660). |
- | file name of interface information | + | -untranslated_name_len LEN Allow up to LEN (1..96) name characters (heavily violates ISO9660). |
- | --debug | + | -allow-lowercase |
- | -w, --why | + | -relaxed-filenames |
- | of why the access was denied | + | -d, -omit-period |
+ | | ||
+ | -max-iso9660-filenames | ||
+ | -N, -omit-version-number | ||
+ | -D, -disable-deep-relocation | ||
+ | Disable deep directory relocation (violates ISO9660) | ||
+ | -hide-rr-moved | ||
+ | -rr_reloc_dir NAME Set deep directory relocation target in root | ||
+ | -uid uid Make the owner of all files this uid. | ||
+ | -gid gid Make the group owner of all files this gid. | ||
+ | | ||
+ | -m GLOBFILE, -exclude GLOBFILE | ||
+ | Exclude file name | ||
+ | | ||
+ | -exclude-list FILE File with list of file names to exclude | ||
+ | | ||
+ | -no-pad | ||
+ | -M FILE, -prev-session FILE Set path to previous session to merge | ||
+ | -C PARAMS, -cdrecord-params PARAMS | ||
+ | Magic paramters from cdrecord | ||
+ | -dir-mode mode Make the mode of all directories this mode. | ||
+ | -file-mode mode Make the mode of all plain files this mode. | ||
+ | -path-list FILE File with list of pathnames to process | ||
+ | --quoted_path_list FILE File with list of quoted pathnames to process | ||
+ | -print-size | ||
+ | -quiet | ||
+ | -gui Switch behaviour for GUI | ||
+ | -R, -rock | ||
+ | -r, -rational-rock Generate rationalized Rock Ridge directory information | ||
+ | --norock | ||
+ | -file_name_limit LEN Set truncation limit for Rock Ridge names | ||
+ | --hardlinks | ||
+ | --acl | ||
+ | --xattr | ||
+ | --xattr-any | ||
+ | | ||
+ | | ||
+ | --for_backup | ||
+ | -V ID, -volid ID Set Volume ID | ||
+ | -volset ID Set Volume | ||
+ | | ||
+ | | ||
+ | -sysid ID Set System ID | ||
+ | -p PREP, -preparer PREP Set Volume preparer | ||
+ | | ||
+ | | ||
+ | | ||
+ | --application_use CHAR|PATH | ||
+ | -jigdo-jigdo FILE | ||
+ | | ||
+ | | ||
+ | -jigdo-force-checksum PTRN Pattern(s) where files MUST match an externally-supplied checksum | ||
+ | -jigdo-force-md5 PATTERN | ||
+ | -jigdo-exclude PATTERN | ||
+ | -jigdo-map PATTERN1=PATTERN2 | ||
+ | | ||
+ | | ||
+ | -md5-list FILE Outdated alias of -checksum-list | ||
+ | -jigdo-checksum-algorithm ALGORITHM | ||
+ | Choose algorithm for file matching checksums: md5, sha256 | ||
+ | Expected in the -checksum-list FILE, written into .jigdo file. | ||
+ | -jigdo-template-compress ALGORITHM | ||
+ | Choose to use gzip or bzip2 compression for template data; default is gzip | ||
+ | -checksum_algorithm_iso alg1, | ||
+ | Specify the checksum types desired for the output | ||
+ | -checksum_algorithm_template alg1,alg2,... | ||
+ | Specify the checksum types desired for the output jigdo template | ||
+ | | ||
+ | -b FILE, -eltorito-boot FILE | ||
+ | Set El Torito boot image name | ||
+ | -eltorito-alt-boot | ||
+ | --efi-boot FILE Set El Torito EFI boot image name and type | ||
+ | -e FILE Set EFI boot image name (more rawly) | ||
+ | -c FILE, -eltorito-catalog FILE | ||
+ | Set El Torito boot catalog name | ||
+ | --boot-catalog-hide | ||
+ | -boot-load-size # Set numbers of load sectors | ||
+ | -hard-disk-boot | ||
+ | -no-emul-boot | ||
+ | -boot-info-table | ||
+ | --grub2-boot-info | ||
+ | -eltorito-id ID Set El Torito Id String | ||
+ | -eltorito-selcrit HEXBYTES | ||
+ | -isohybrid-gpt-basdat | ||
+ | -isohybrid-gpt-hfsplus | ||
+ | -isohybrid-apm-hfsplus | ||
+ | -part_like_isohybrid | ||
+ | -iso_mbr_part_type | ||
+ | or type GUID if a GPT ISO partition emerges. | ||
+ | --gpt_disk_guid GUID Set GPT disk GUID or choose automatic GUID | ||
+ | | ||
+ | --embedded-boot FILE Alias of -G | ||
+ | --protective-msdos-label | ||
+ | --mbr-force-bootable | ||
+ | -partition_offset LBA Make image mountable by first partition, too | ||
+ | -partition_sec_hd NUMBER | ||
+ | -partition_hd_cyl NUMBER | ||
+ | -partition_cyl_align MODE | ||
+ | -mips-boot FILE Set mips boot image name (relative to image root) | ||
+ | -mipsel-boot FILE Set mipsel boot image name (relative to image root) | ||
+ | -B FILES, -sparc-boot FILES Set sparc boot image names | ||
+ | -sparc-label label text Set sparc boot disk label | ||
+ | -hppa-cmdline CMDLINE | ||
+ | -hppa-kernel-32 FILE Set hppa 32-bit image name (relative to image root) | ||
+ | -hppa-kernel-64 FILE Set hppa 64-bit image name (relative to image root) | ||
+ | -hppa-bootloader FILE Set hppa boot loader | ||
+ | -hppa-ramdisk FILE Set hppa ramdisk file name (relative to image root) | ||
+ | -hppa-hdrversion NUMBER | ||
+ | -alpha-boot FILE Set alpha boot image name (relative to image root) | ||
+ | --grub2-sparc-core FILE Set path of core file for disk label patching | ||
+ | -efi-boot-part DISKFILE|--efi-boot-image | ||
+ | Set data source for EFI System Partition | ||
+ | -chrp-boot-part | ||
+ | -chrp-boot | ||
+ | -prep-boot-part DISKFILE | ||
+ | -append_partition NUMBER TYPE FILE | ||
+ | Append FILE after image. TYPE is hex: 0x.. or | ||
+ | a GUID to be used if -appended_part_as_gpt. | ||
+ | -appended_part_as_gpt | ||
+ | -appended_part_as_apm | ||
+ | --modification-date=YYYYMMDDhhmmsscc | ||
+ | | ||
+ | --set_all_file_dates TIME | ||
+ | -isohybrid-mbr FILE Set SYSLINUX mbr/ | ||
+ | --grub2-mbr FILE Set GRUB2 MBR for boot image address patching | ||
+ | --sort-weight NUMBER FILE Set LBA weight number to file or file tree | ||
+ | --sort-weight-list DISKFILE Read list of NUMBER FILE pairs for --sort-weight | ||
+ | --sort-weight-patterns DISKFILE | ||
+ | --stdio_sync on|off|number | ||
+ | --no-emul-toc | ||
+ | | ||
+ | --old-empty | ||
+ | -z, -transparent-compression | ||
+ | | ||
+ | --zisofs-version-2 | ||
+ | --zisofs2-susp-z2 | ||
+ | --zisofs2-susp-zf | ||
+ | -root DIR Set root directory for all new files and directories | ||
+ | -old-root DIR Set root directory in previous session that is searched for files | ||
+ | --old-root-no-md5 | ||
+ | --old-root-no-ino | ||
+ | --old-root-devno | ||
+ | -log-file LOG_FILE | ||
+ | --no_rc | ||
+ | -v, -verbose | ||
+ | -version | ||
+ | |||
+ | Report any bugs to bug-xorriso@gnu.org or in private to scdbackup@gmx.net . | ||
</ | </ | ||
- | La création d'un module | + | =====LAB #17 - Systèmes de Fichiers Chiffrés sous RedHat 9===== |
+ | |||
+ | ====17.1 - Créer | ||
+ | |||
+ | ===Présentation=== | ||
+ | |||
+ | **LUKS** ( Linux Unified Key Setup ) permet de chiffrer l'intégralité d'un disque | ||
- | * la résolution du problème n'est pas possible | + | ===Mise |
- | * il n' | + | |
- | Pour illustrer l' | + | Remplissez |
< | < | ||
- | [root@centos7 tmp]# mkdir /www1 | + | [root@redhat9 ~]# shred -v --iterations=1 |
- | [root@centos7 tmp]# touch /www1/index.html | + | shred: |
+ | shred: /dev/sdb12: pass 1/1 (random)...5.7MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...10MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...14MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...18MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...23MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...27MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...31MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...36MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...41MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...45MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...49MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...53MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...57MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...61MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...64MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...68MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...73MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...77MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...81MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...86MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...90MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...94MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...98MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...105MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...108MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...112MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...113MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...117MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...121MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...125MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...129MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...133MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...137MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...141MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...145MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...148MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...152MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...156MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...159MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...163MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...167MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...170MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...174MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...178MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...182MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...187MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...190MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...194MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...198MiB/ | ||
+ | shred: /dev/sdb12: pass 1/1 (random)...200MiB/ | ||
</ | </ | ||
- | Éditez le fichier | + | <WRAP center round important 60%> |
+ | **Important** : L' | ||
+ | </ | ||
- | < | + | Initialisez la partition avec LUKS : |
- | [...] | + | |
- | # | + | |
- | DocumentRoot "/ | + | |
- | [...] | + | |
- | </ | + | |
- | Ajoutez les section **<Directory "/ | + | <code> |
+ | [root@redhat9 ~]# cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb12 | ||
- | < | + | WARNING! |
- | ... | + | ======== |
- | < | + | This will overwrite data on /dev/sdb12 irrevocably. |
- | AllowOverride None | + | |
- | # Allow open access: | + | |
- | Require all granted | + | |
- | </ | + | |
- | < | + | Are you sure? (Type ' |
- | Options Indexes FollowSymLinks | + | Enter passphrase for /dev/sdb12: fenestros123456789 |
- | AllowOverride None | + | Verify passphrase: fenestros123456789 |
- | Require all granted | + | Key slot 0 created. |
- | </Directory> | + | Command successful. |
+ | </code> | ||
- | # Further relax access to the default document root: | + | <WRAP center round important 60%> |
- | <Directory "/ | + | **Important** : La passphrase ne sera pas en claire. Elle l'est ici pour vous montrer un mot de passe acceptable pour LUKS. |
- | ... | + | </WRAP> |
- | </file> | + | |
- | Créez | + | Ouvrez la partition LUKS en lui donnant |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | [root@centos7 ~]# vi /www1/index.html | + | Enter passphrase for /dev/sdb12: fenestros123456789 |
- | [root@centos7 ~]# cat /www1/ | + | |
- | < | + | |
- | < | + | |
- | This is a test | + | |
- | </ | + | |
- | < | + | |
- | www test page | + | |
- | </ | + | |
- | </html> | + | |
</ | </ | ||
- | Modifiez ensuite | + | Vérifiez que le système voit la partition |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | lrwxrwxrwx. 1 root root 7 Oct 24 09:21 sdb12 -> ../dm-9 | ||
</ | </ | ||
- | Redémarrez le service httpd : | + | Créez maintenant un système de fichiers sur **/ |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | Filesystem should be larger than 300MB. | ||
+ | Log size should be at least 64MB. | ||
+ | Support for filesystems like this one is deprecated and they will not be supported in future releases. | ||
+ | meta-data=/ | ||
+ | | ||
+ | | ||
+ | | ||
+ | data | ||
+ | | ||
+ | naming | ||
+ | log =internal log | ||
+ | | ||
+ | realtime =none | ||
</ | </ | ||
- | Consultez le site localhost en utilisant **lynx** | + | Montez la partition LUKS : |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
- | Le fichier **/ | + | Vérifiez la présence du montage |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | type=USER_AVC msg=audit(1462020229.957: | + | /dev/mapper/sdb12 179M |
- | type=AVC msg=audit(1524491216.546: | + | |
- | type=AVC msg=audit(1524491220.766: | + | |
- | type=AVC msg=audit(1529418883.052: | + | |
- | type=AVC msg=audit(1529418883.052: | + | |
- | type=AVC msg=audit(1529418919.091: | + | |
- | type=AVC msg=audit(1529418919.092: | + | |
- | type=AVC msg=audit(1529418954.500: | + | |
- | type=AVC msg=audit(1529418954.500: | + | |
- | type=AVC msg=audit(1529419054.949: | + | |
- | type=AVC msg=audit(1529419054.949: | + | |
- | type=USER_AVC msg=audit(1529421001.608: | + | |
- | type=USER_AVC msg=audit(1529421602.007: | + | |
- | type=AVC msg=audit(1529422368.058: | + | |
- | type=AVC msg=audit(1529422368.058: | + | |
</ | </ | ||
- | A l'aide de la commande grep, il convient maintenant d' | + | Editez le fichier **/etc/crypttab/** : |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | |||
+ | [root@redhat9 ~]# cat / | ||
+ | sdb12 /dev/sdb12 none | ||
</ | </ | ||
- | L' | + | Modifiez le fichier **/etc/fstab** : |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | module httpdlocal 1.0; | + | [root@redhat9 ~]# cat /etc/fstab |
- | require { | + | # |
- | type httpd_t; | + | # /etc/fstab |
- | type default_t; | + | # Created by anaconda on Thu Oct 19 16:05:58 2023 |
- | class file getattr; | + | # |
- | } | + | # Accessible filesystems, |
+ | # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. | ||
+ | # | ||
+ | # After editing this file, run ' | ||
+ | # units generated from this file. | ||
+ | # | ||
+ | / | ||
+ | UUID=6f6c5bb9-30be-4734-bc23-03fed8541616 /boot | ||
+ | / | ||
+ | / | ||
+ | </ | ||
- | # | + | Restaurer les SC par défaut de SELinux : |
- | #!!!! WARNING: ' | + | < |
- | #!!!! The file '/www/index.html' | + | [root@redhat9 ~]# /sbin/restorecon -v -R /mnt/sdb12 |
- | #!!!! Fix with $ restorecon | + | Relabeled /mnt/sdb12 from system_u: |
- | allow httpd_t default_t:file getattr; | + | |
</ | </ | ||
- | L' | + | Redémarrez votre machine virtuelle |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | ******************** IMPORTANT *********************** | + | </ |
- | To make this policy package active, execute: | + | |
- | semodule -i httpdlocal.pp | + | <WRAP center round important 60%> |
+ | **Important** : Lors du démarrage de la machine virtuelle, le système devrait vous demander d' | ||
+ | </ | ||
+ | |||
+ | ===Ajouter une deuxième Passphrase=== | ||
+ | |||
+ | Pour ajouter une deuxième passphrase, utilisez la commande cryptsetup avec la sous-commande **luksAddKey** : | ||
+ | |||
+ | < | ||
+ | [trainee@redhat9 ~]$ su - | ||
+ | Password: fenestros | ||
+ | [root@redhat9 ~]# cryptsetup luksAddKey / | ||
+ | Enter any existing passphrase: fenestros123456789 | ||
+ | Enter new passphrase for key slot: redhat123456789 | ||
+ | Verify passphrase: redhat123456789 | ||
</ | </ | ||
- | Chargez maintenant | + | <WRAP center round important 60%> |
+ | **Important** : Les passphrases ne seront pas en claire. Elle le sont ici pour vous montrer des mots de passe acceptables pour LUKS. | ||
+ | </ | ||
+ | |||
+ | ===Supprimer une Passphrase=== | ||
+ | |||
+ | Pour supprimer une passphrase, utilisez | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | Enter passphrase to be deleted: redhat123456789 | ||
</ | </ | ||
- | Vérifiez que le module est chargé | + | ===Supprimer LUKS=== |
+ | |||
+ | Constatez | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | httpdlocal 1.0 | + | |
+ | [root@redhat9 ~]# cryptsetup status sdb12 | ||
+ | / | ||
+ | type: LUKS2 | ||
+ | cipher: | ||
+ | keysize: 512 bits | ||
+ | key location: keyring | ||
+ | device: | ||
+ | sector size: 512 | ||
+ | offset: | ||
+ | size: 376832 sectors | ||
+ | mode: read/write | ||
</ | </ | ||
- | Redémarrez le service httpd : | + | Avant de supprimer LUKs, il convient de supprimer la dernière passphrase |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | Enter passphrase to be deleted: | ||
+ | |||
+ | WARNING! | ||
+ | ======== | ||
+ | This is the last keyslot. Device will become unusable after purging this key. | ||
+ | |||
+ | Are you sure? (Type ' | ||
</ | </ | ||
- | Videz le fichier **/ | + | Supprimez maintenant LUKs : |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
- | Consultez | + | Vérifiez de nouveau |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | / | ||
+ | |||
+ | [root@redhat9 ~]# lsblk | ||
+ | NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS | ||
+ | sda | ||
+ | ├─sda1 | ||
+ | └─sda2 | ||
+ | ├─rhel-root 253:0 0 | ||
+ | └─rhel-swap 253:1 0 5G 0 lvm | ||
+ | sdb | ||
+ | ├─sdb1 | ||
+ | ├─sdb2 | ||
+ | ├─sdb3 | ||
+ | ├─sdb4 | ||
+ | ├─sdb5 | ||
+ | ├─sdb6 | ||
+ | │ └─vg0-lv1 | ||
+ | ├─sdb7 | ||
+ | │ └─vg0-lv2 | ||
+ | ├─sdb8 | ||
+ | │ └─md1 | ||
+ | ├─sdb9 | ||
+ | │ └─vg0-lv2 | ||
+ | ├─sdb10 | ||
+ | │ └─md1 | ||
+ | ├─sdb11 | ||
+ | └─sdb12 | ||
+ | sdc | ||
+ | sdd | ||
+ | sr0 11:0 1 1024M 0 rom | ||
+ | </ | ||
+ | |||
+ | Editez les fichiers **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# vi / | ||
+ | |||
+ | [root@redhat9 ~]# cat / | ||
+ | |||
+ | # | ||
+ | # / | ||
+ | # Created by anaconda on Thu Oct 19 16:05:58 2023 | ||
+ | # | ||
+ | # Accessible filesystems, | ||
+ | # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. | ||
+ | # | ||
+ | # After editing this file, run ' | ||
+ | # units generated from this file. | ||
+ | # | ||
+ | / | ||
+ | UUID=6f6c5bb9-30be-4734-bc23-03fed8541616 /boot | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Supprimez le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# rm -f / | ||
+ | </ | ||
+ | |||
+ | =====LAB #18 - Le Swap===== | ||
+ | |||
+ | ====18.1 - Taille du swap==== | ||
+ | |||
+ | Le tableau suivant résume la taille du swap recommandée en fonction de la RAM de la machine : | ||
+ | |||
+ | ^ RAM ^ Taille du swap ^ Taille du Swap si Hibernation ^ | ||
+ | | 2 Go ou moins | 2 * RAM | 3 * RAM | | ||
+ | | 2 Go à 8 Go | Identique à la RAM | 2 * RAM | | ||
+ | | 8 Go à 64 Go | Au moins 4 Go | 1.5 * RAM | | ||
+ | | 64 Go et plus | Au moins 4 Go | Hibernation n'est pas recommendée | | ||
+ | |||
+ | ====18.2 - Partitions de swap==== | ||
+ | |||
+ | Une partition de swap peut être créée sur : | ||
+ | |||
+ | * une partition du disque dur | ||
+ | * un RAID logiciel | ||
+ | * un Volume Logique | ||
+ | |||
+ | ====18.3 - La Commande swapon==== | ||
+ | |||
+ | Pour préparer un espace de swap, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# swapon -s | ||
+ | Filename | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Vous noterez que dans l' | ||
+ | </ | ||
+ | |||
+ | ===Options de la Commande=== | ||
+ | |||
+ | Les options de la commande swapon sont : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# swapon --help | ||
+ | |||
+ | Usage: | ||
+ | | ||
+ | |||
+ | Enable devices and files for paging and swapping. | ||
+ | |||
+ | Options: | ||
+ | -a, --all enable all swaps from / | ||
+ | -d, --discard[=< | ||
+ | -e, --ifexists | ||
+ | -f, --fixpgsz | ||
+ | -o, --options < | ||
+ | -p, --priority < | ||
+ | -s, --summary | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | -v, --verbose | ||
+ | |||
+ | -h, --help | ||
+ | -V, --version | ||
+ | |||
+ | The < | ||
+ | -L < | ||
+ | -U < | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | < | ||
+ | < | ||
+ | |||
+ | Available discard policy types (for --discard): | ||
+ | | ||
+ | | ||
+ | If no policy is selected, both discard types are enabled (default). | ||
+ | |||
+ | Available output columns: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | For more details see swapon(8). | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : L' | ||
+ | </ | ||
+ | |||
+ | ====18.4 - La Commande swapoff==== | ||
+ | |||
+ | Dans le cas de notre exemple, la partition de swap se trouve sur **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# swapoff /dev/dm-1 | ||
+ | |||
+ | [root@redhat9 ~]# swapon -s | ||
+ | [root@redhat9 ~]# | ||
+ | </ | ||
+ | |||
+ | ===Options de la Commande=== | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# swapoff --help | ||
+ | |||
+ | Usage: | ||
+ | | ||
+ | |||
+ | Disable devices and files for paging and swapping. | ||
+ | |||
+ | Options: | ||
+ | -a, --all disable all swaps from / | ||
+ | -v, --verbose | ||
+ | |||
+ | -h, --help | ||
+ | -V, --version | ||
+ | |||
+ | The < | ||
+ | -L < | ||
+ | -U < | ||
+ | | ||
+ | | ||
+ | < | ||
+ | < | ||
+ | |||
+ | For more details see swapoff(8). | ||
+ | </ | ||
+ | |||
+ | ====18.5 - 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**. | ||
+ | |||
+ | La commande **dd** copie le fichier passé en entrée dans le fichier de sortie en limitant le nombre d' | ||
+ | |||
+ | * **count** | ||
+ | * le nombre | ||
+ | * **bs** | ||
+ | * la taille du bloc à copier | ||
+ | |||
+ | Dans le cas du fichier swap il convient d' | ||
+ | |||
+ | Pour créer votre fichier de swap de 256 MiB, appelé **swap**, saisissez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# dd if=/ | ||
+ | 256+0 records in | ||
+ | 256+0 records out | ||
+ | 268435456 bytes (268 MB, 256 MiB) copied, 1.45212 s, 185 MB/s | ||
+ | </ | ||
+ | |||
+ | Pour préparer le fichier en tant qu' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# mkswap /swap | ||
+ | mkswap: /swap: insecure permissions 0644, fix with: chmod 0600 /swap | ||
+ | Setting up swapspace version 1, size = 256 MiB (268431360 bytes) | ||
+ | no label, UUID=6bc62766-8662-478a-8556-8b17b26fc5ae | ||
+ | </ | ||
+ | |||
+ | Pour activer le fichier avec une priorité de **1**, saisissez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# swapon -p1 /swap | ||
+ | swapon: /swap: insecure permissions 0644, 0600 suggested. | ||
+ | |||
+ | [root@redhat9 ~]# swapon /dev/dm-1 | ||
+ | </ | ||
+ | |||
+ | Pour visualiser les éspaces swap, saisissez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# swapon -s | ||
+ | Filename | ||
+ | /swap | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Le fichier de swap ayant une priorité de 1 sera utilisé avant la partition de swap ayant une priorité de -2. | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Pour activer le fichier swap d'une manière permanente, il convient d' | ||
+ | </ | ||
+ | |||
+ | Désactivez maintenant le fichier swap : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# swapoff /swap | ||
+ | |||
+ | [root@redhat9 ~]# swapon -s | ||
+ | Filename | ||
+ | / | ||
</ | </ | ||
- | Constatez que la consultation ne génère plus de messages de type **AVC** | + | Supprimez maintenant le fichier |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | [root@centos7 ~]# | + | rm: remove regular file '/swap'? y |
</ | </ | ||
----- | ----- | ||
- | < | + | Copyright © 2024 Hugh Norris. |
- | <div align=" | + | |
- | Copyright © 2021 Hugh Norris.< | + | |
- | </ | + | |
- | </ | + |