Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
elearning:workbooks:lpic:11:500:l104 [2023/06/09 06:16] – created admin | elearning:workbooks:lpic:11:500:l104 [2024/04/05 08:03] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
- | Version : **2023.01** | + | Version : **2024.01** |
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
Ligne 595: | Ligne 595: | ||
**Important** : Un lien symbolique peut être créé même dans le cas où les deux fichiers se trouvent dans deux filesystems différents et même dans le cas où le fichier source n' | **Important** : Un lien symbolique peut être créé même dans le cas où les deux fichiers se trouvent dans deux filesystems différents et même dans le cas où le fichier source n' | ||
</ | </ | ||
+ | |||
+ | =====Périphériques de stockage===== | ||
+ | |||
+ | Les unités de stockage sous Linux sont référencées par un des fichiers se trouvant dans le répertoire **/dev** : | ||
+ | |||
+ | * 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 sur IBM XT | ||
+ | * 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 | ||
+ | |||
+ | =====Partitions===== | ||
+ | |||
+ | 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. Il faut 16 octets pour codés une partition. | ||
+ | * **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 la liste de partitions suivante : sda1, sda2, sda5, sda6, sda7. Notez que la sda3 ne peut pas être utilisée en tant que partition car elle est cachée par les lecteurs sda5, sda6 et sda7. | ||
+ | |||
+ | {{free: | ||
+ | |||
+ | Le nombre de partitions sur un disque est limité : | ||
+ | |||
+ | * **IDE**, | ||
+ | * Jusqu' | ||
+ | * **SCSI**, | ||
+ | * Jusqu' | ||
+ | * **Disques utilisant l'API libata**, | ||
+ | * Jusqu' | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Ces limites peuvent être dépassées en utilisant la gestion **LVM** (//Logical Volume Management// | ||
+ | </ | ||
+ | |||
+ | =====Partitionnement===== | ||
+ | |||
+ | ====LAB #1 - Partitionnement de votre Disque sous RHEL/CentOS 7 avec fdisk==== | ||
+ | |||
+ | Pour procéder au partitionnement de votre disque ou de vos disques, RHEL/CentOS 7 possède l' | ||
+ | |||
+ | Lancez fdisk en fournissant en argument le fichier de référence de votre premier disque dur, par exemple : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# fdisk /dev/sda | ||
+ | Welcome to fdisk (util-linux 2.23.2). | ||
+ | |||
+ | Changes will remain in memory only, until you decide to write them. | ||
+ | Be careful before using the write command. | ||
+ | |||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | Tapez ensuite la lettre **m** puis < | ||
+ | |||
+ | < | ||
+ | Command (m for help): m | ||
+ | Command action | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | 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/sda4 | Extended | Du premier cylindre disponible au dernier cylindre du disque | | ||
+ | | /dev/sda5 | Logique | 500 Mo | | ||
+ | | /dev/sda6 | Logique | 200 Mo | | ||
+ | | /dev/sda7 | Logique | 300 Mo | | ||
+ | | /dev/sda8 | Logique | 500 Mo | | ||
+ | | /dev/sda9 | Logique | 400 Mo | | ||
+ | | /dev/sda10 | Logique | 500 Mo | | ||
+ | | /dev/sda11 | Logique | 500 Mo | | ||
+ | | /dev/sda12 | Logique | 200 Mo | | ||
+ | |||
+ | Créez d' | ||
+ | |||
+ | < | ||
+ | Command (m for help): n | ||
+ | Partition type: | ||
+ | | ||
+ | | ||
+ | Select (default e): e | ||
+ | Selected partition 4 | ||
+ | First sector (20891648-41943039, | ||
+ | Using default value 20891648 | ||
+ | Last sector, +sectors or +size{K, | ||
+ | Using default value 41943039 | ||
+ | Partition 4 of type Extended and of size 10 GiB is set | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | Créez ensuite les autres partitions l'une après l' | ||
+ | |||
+ | < | ||
+ | Command (m for help): n | ||
+ | All primary partitions are in use | ||
+ | Adding logical partition 5 | ||
+ | First sector (20893696-41943039, | ||
+ | Using default value 20893696 | ||
+ | Last sector, +sectors or +size{K, | ||
+ | Partition 5 of type Linux and of size 500 MiB is set | ||
+ | |||
+ | Command (m for help): n | ||
+ | All primary partitions are in use | ||
+ | Adding logical partition 6 | ||
+ | First sector (21919744-41943039, | ||
+ | Using default value 21919744 | ||
+ | Last sector, +sectors or +size{K, | ||
+ | Partition 6 of type Linux and of size 200 MiB is set | ||
+ | |||
+ | Command (m for help): n | ||
+ | All primary partitions are in use | ||
+ | Adding logical partition 7 | ||
+ | First sector (22331392-41943039, | ||
+ | Using default value 22331392 | ||
+ | Last sector, +sectors or +size{K, | ||
+ | Partition 7 of type Linux and of size 300 MiB is set | ||
+ | |||
+ | Command (m for help): n | ||
+ | All primary partitions are in use | ||
+ | Adding logical partition 8 | ||
+ | First sector (22947840-41943039, | ||
+ | Using default value 22947840 | ||
+ | Last sector, +sectors or +size{K, | ||
+ | Partition 8 of type Linux and of size 500 MiB is set | ||
+ | |||
+ | Command (m for help): n | ||
+ | All primary partitions are in use | ||
+ | Adding logical partition 9 | ||
+ | First sector (23973888-41943039, | ||
+ | Using default value 23973888 | ||
+ | Last sector, +sectors or +size{K, | ||
+ | Partition 9 of type Linux and of size 400 MiB is set | ||
+ | |||
+ | Command (m for help): n | ||
+ | All primary partitions are in use | ||
+ | Adding logical partition 10 | ||
+ | First sector (24795136-41943039, | ||
+ | Using default value 24795136 | ||
+ | Last sector, +sectors or +size{K, | ||
+ | Partition 10 of type Linux and of size 500 MiB is set | ||
+ | |||
+ | Command (m for help): n | ||
+ | All primary partitions are in use | ||
+ | Adding logical partition 11 | ||
+ | First sector (25821184-41943039, | ||
+ | Using default value 25821184 | ||
+ | Last sector, +sectors or +size{K, | ||
+ | Partition 11 of type Linux and of size 500 MiB is set | ||
+ | |||
+ | Command (m for help): n | ||
+ | All primary partitions are in use | ||
+ | Adding logical partition 12 | ||
+ | First sector (26847232-41943039, | ||
+ | Using default value 26847232 | ||
+ | Last sector, +sectors or +size{K, | ||
+ | Partition 12 of type Linux and of size 200 MiB is set | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | Tapez ensuite la lettre **p** puis < | ||
+ | |||
+ | < | ||
+ | Command (m for help): p | ||
+ | |||
+ | Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors | ||
+ | Units = sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disk label type: dos | ||
+ | Disk identifier: 0x000f2006 | ||
+ | |||
+ | | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Chaque bloc fait 1 024 octets. Chaque secteur fait 512 octets. Quand la partition contient un nombre impair de secteurs, celle-ci est marquée avec un **+**. Ceci implique que le dernier secteur de 512 octets est effectivement perdu. | ||
+ | </ | ||
+ | |||
+ | Ecrivez la table des partitions sur disque et exécutez la commande **partprobe** : | ||
+ | |||
+ | < | ||
+ | Command (m for help): w | ||
+ | The partition table has been altered! | ||
+ | |||
+ | Calling ioctl() to re-read partition table. | ||
+ | |||
+ | WARNING: Re-reading the partition table failed with error 16: Device or resource busy. | ||
+ | The kernel still uses the old table. The new table will be used at | ||
+ | the next reboot or after you run partprobe(8) or kpartx(8) | ||
+ | Syncing disks. | ||
+ | [root@centos7 ~]# partprobe | ||
+ | </ | ||
+ | |||
+ | Lancez fdisk puis tapez ensuite la lettre **p** puis < | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# fdisk /dev/sda | ||
+ | Welcome to fdisk (util-linux 2.23.2). | ||
+ | |||
+ | Changes will remain in memory only, until you decide to write them. | ||
+ | Be careful before using the write command. | ||
+ | |||
+ | |||
+ | Command (m for help): p | ||
+ | |||
+ | Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors | ||
+ | Units = sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disk label type: dos | ||
+ | Disk identifier: 0x000f2006 | ||
+ | |||
+ | | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | Pour supprimer une partition, utilisez la commande **d** puis < | ||
+ | |||
+ | < | ||
+ | Command (m for help): d | ||
+ | Partition number (1-12, default 12): 12 | ||
+ | Partition 12 is deleted | ||
+ | |||
+ | Command (m for help): p | ||
+ | |||
+ | Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors | ||
+ | Units = sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disk label type: dos | ||
+ | Disk identifier: 0x000f2006 | ||
+ | |||
+ | | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | 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 : | ||
+ | |||
+ | < | ||
+ | Command (m for help): q | ||
+ | |||
+ | [root@centos7 ~]# fdisk /dev/sda | ||
+ | Welcome to fdisk (util-linux 2.23.2). | ||
+ | |||
+ | Changes will remain in memory only, until you decide to write them. | ||
+ | Be careful before using the write command. | ||
+ | |||
+ | |||
+ | Command (m for help): p | ||
+ | |||
+ | Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors | ||
+ | Units = sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disk label type: dos | ||
+ | Disk identifier: 0x000f2006 | ||
+ | |||
+ | | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | ====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. | ||
+ | |||
+ | Modifiez donc les nouvelles partitions à l'aide de la commande **t** de **fdisk** selon le tableau ci-dessous : | ||
+ | |||
+ | ^ Taille de la Partition ^ Système de Fichiers ^ | ||
+ | | 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é | | ||
+ | |||
+ | Vous obtiendrez un résultat similaire à celui-ci : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# fdisk /dev/sda | ||
+ | Welcome to fdisk (util-linux 2.23.2). | ||
+ | |||
+ | Changes will remain in memory only, until you decide to write them. | ||
+ | Be careful before using the write command. | ||
+ | |||
+ | |||
+ | Command (m for help): p | ||
+ | |||
+ | Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors | ||
+ | Units = sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disk label type: dos | ||
+ | Disk identifier: 0x000f2006 | ||
+ | |||
+ | | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | |||
+ | Command (m for help): t | ||
+ | Partition number (1-12, default 12): 5 | ||
+ | Hex code (type L to list all codes): fd | ||
+ | Changed type of partition ' | ||
+ | |||
+ | Command (m for help): t | ||
+ | Partition number (1-12, default 12): 6 | ||
+ | Hex code (type L to list all codes): 8e | ||
+ | Changed type of partition ' | ||
+ | |||
+ | Command (m for help): t | ||
+ | Partition number (1-12, default 12): 7 | ||
+ | Hex code (type L to list all codes): 8e | ||
+ | Changed type of partition ' | ||
+ | |||
+ | Command (m for help): t | ||
+ | Partition number (1-12, default 12): 8 | ||
+ | Hex code (type L to list all codes): fd | ||
+ | Changed type of partition ' | ||
+ | |||
+ | Command (m for help): t | ||
+ | Partition number (1-12, default 12): 9 | ||
+ | Hex code (type L to list all codes): 8e | ||
+ | Changed type of partition ' | ||
+ | |||
+ | Command (m for help): t | ||
+ | Partition number (1-12, default 12): 10 | ||
+ | Hex code (type L to list all codes): fd | ||
+ | Changed type of partition ' | ||
+ | |||
+ | Command (m for help): t | ||
+ | Partition number (1-12, default 12): 11 | ||
+ | Hex code (type L to list all codes): fd | ||
+ | Changed type of partition ' | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | A l'issu des modifications, | ||
+ | |||
+ | < | ||
+ | Command (m for help): p | ||
+ | |||
+ | Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors | ||
+ | Units = sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disk label type: dos | ||
+ | Disk identifier: 0x000f2006 | ||
+ | |||
+ | | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | Pour écrire la nouvelle table des partitions sur disque, vous devez utilisez la commande **w** puis la commande **partprobe** : | ||
+ | |||
+ | < | ||
+ | Command (m for help): w | ||
+ | The partition table has been altered! | ||
+ | |||
+ | Calling ioctl() to re-read partition table. | ||
+ | |||
+ | WARNING: Re-reading the partition table failed with error 16: Device or resource busy. | ||
+ | The kernel still uses the old table. The new table will be used at | ||
+ | the next reboot or after you run partprobe(8) or kpartx(8) | ||
+ | Syncing disks. | ||
+ | [root@centos7 ~]# partprobe | ||
+ | </ | ||
+ | |||
+ | ====Options de la Commande fdisk==== | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# fdisk --help | ||
+ | fdisk: invalid option -- ' | ||
+ | Usage: | ||
+ | fdisk [options] < | ||
+ | fdisk [options] -l < | ||
+ | fdisk -s < | ||
+ | |||
+ | Options: | ||
+ | -b < | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | -C < | ||
+ | -H < | ||
+ | -S < | ||
+ | </ | ||
+ | |||
+ | =====Logical Volume Manager (LVM)===== | ||
+ | |||
+ | ====LAB #3 - Volumes Logiques Linéaires==== | ||
+ | |||
+ | Afin de mettre en place le LVM, vous avez besoin du paquet **lvm2** et du paquet **device-mapper**. | ||
+ | |||
+ | Nous allons travailler sous RHEL/CentOS 7 avec les partitions suivantes : | ||
+ | |||
+ | < | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Pour initialiser le LVM saississez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# vgscan | ||
+ | Reading all physical volumes. | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **vgscan** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# vgscan --help | ||
+ | vgscan: Search for all volume groups | ||
+ | |||
+ | vgscan [--cache] | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [-h|--help] | ||
+ | [--ignorelockingfailure] | ||
+ | [--mknodes] | ||
+ | [-P|--partial] | ||
+ | [-v|--verbose] | ||
+ | [--version] | ||
+ | </ | ||
+ | |||
+ | ===Physical Volume (PV)=== | ||
+ | |||
+ | Pour créer le **PV** il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# pvcreate /dev/sda6 /dev/sda7 /dev/sda9 | ||
+ | Physical volume "/ | ||
+ | Physical volume "/ | ||
+ | Physical volume "/ | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **pvcreate** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# pvcreate --help | ||
+ | pvcreate: Initialize physical volume(s) for use by LVM | ||
+ | |||
+ | pvcreate | ||
+ | [--norestorefile] | ||
+ | [--restorefile file] | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [-f[f]|--force [--force]] | ||
+ | [-h|-? | ||
+ | [--labelsector sector] | ||
+ | [-M|--metadatatype 1|2] | ||
+ | [--pvmetadatacopies #copies] | ||
+ | [--bootloaderareasize BootLoaderAreaSize[bBsSkKmMgGtTpPeE]] | ||
+ | [--metadatasize MetadataSize[bBsSkKmMgGtTpPeE]] | ||
+ | [--dataalignment Alignment[bBsSkKmMgGtTpPeE]] | ||
+ | [--dataalignmentoffset AlignmentOffset[bBsSkKmMgGtTpPeE]] | ||
+ | [--setphysicalvolumesize PhysicalVolumeSize[bBsSkKmMgGtTpPeE] | ||
+ | [-t|--test] | ||
+ | [-u|--uuid uuid] | ||
+ | [-v|--verbose] | ||
+ | [-y|--yes] | ||
+ | [-Z|--zero {y|n}] | ||
+ | [--version] | ||
+ | PhysicalVolume [PhysicalVolume...] | ||
+ | </ | ||
+ | |||
+ | Pour visualiser le PV il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# pvdisplay /dev/sda6 /dev/sda7 /dev/sda9 | ||
+ | "/ | ||
+ | --- NEW Physical volume --- | ||
+ | PV Name / | ||
+ | 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 | ||
+ | |||
+ | "/ | ||
+ | --- NEW Physical volume --- | ||
+ | PV Name / | ||
+ | VG Name | ||
+ | PV Size | ||
+ | Allocatable | ||
+ | PE Size | ||
+ | Total PE 0 | ||
+ | Free PE 0 | ||
+ | Allocated PE 0 | ||
+ | PV UUID | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **pvdisplay** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# pvdisplay --help | ||
+ | pvdisplay: Display various attributes of physical volume(s) | ||
+ | |||
+ | pvdisplay | ||
+ | [-c|--colon] | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [-h|--help] | ||
+ | [--ignorelockingfailure] | ||
+ | [--ignoreskippedcluster] | ||
+ | [-m|--maps] | ||
+ | [--nosuffix] | ||
+ | [--readonly] | ||
+ | [-s|--short] | ||
+ | [--units hHbBsSkKmMgGtTpPeE] | ||
+ | [-v|--verbose] | ||
+ | [--version] | ||
+ | [PhysicalVolumePath [PhysicalVolumePath...]] | ||
+ | |||
+ | pvdisplay --columns|-C | ||
+ | [--aligned] | ||
+ | [-a|--all] | ||
+ | [--binary] | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [-h|--help] | ||
+ | [--ignorelockingfailure] | ||
+ | [--ignoreskippedcluster] | ||
+ | [--noheadings] | ||
+ | [--nosuffix] | ||
+ | [-o|--options [+]Field[, | ||
+ | [-O|--sort [+|-]key1[, | ||
+ | [-S|--select Selection] | ||
+ | [--readonly] | ||
+ | [--separator Separator] | ||
+ | [--unbuffered] | ||
+ | [--units hHbBsSkKmMgGtTpPeE] | ||
+ | [-v|--verbose] | ||
+ | [--version] | ||
+ | [PhysicalVolumePath [PhysicalVolumePath...]] | ||
+ | </ | ||
+ | |||
+ | ===Volume Group (VG) et Physical Extent (PE)=== | ||
+ | |||
+ | Pour créer un Volume Group dénommé **vg0**, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# vgcreate -s 8M vg0 /dev/sda6 /dev/sda7 /dev/sda9 | ||
+ | Volume group " | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **vgcreate** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# vgcreate --help | ||
+ | vgcreate: Create a volume group | ||
+ | |||
+ | vgcreate | ||
+ | [-A|--autobackup {y|n}] | ||
+ | [--addtag Tag] | ||
+ | [--alloc AllocationPolicy] | ||
+ | [-c|--clustered {y|n}] | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [-h|--help] | ||
+ | [-l|--maxlogicalvolumes MaxLogicalVolumes] | ||
+ | [--metadataprofile ProfileName] | ||
+ | [-M|--metadatatype 1|2] | ||
+ | [--[vg]metadatacopies #copies] | ||
+ | [-p|--maxphysicalvolumes MaxPhysicalVolumes] | ||
+ | [-s|--physicalextentsize PhysicalExtentSize[bBsSkKmMgGtTpPeE]] | ||
+ | [-t|--test] | ||
+ | [-v|--verbose] | ||
+ | [--version] | ||
+ | [-y|--yes] | ||
+ | [ PHYSICAL DEVICE OPTIONS ] | ||
+ | VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...] | ||
+ | </ | ||
+ | |||
+ | Pour afficher les informations concernant **vg0**, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# 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 0 / 0 | ||
+ | Free PE / Size 110 / 880.00 MiB | ||
+ | VG UUID | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **vgdisplay** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# vgdisplay --help | ||
+ | vgdisplay: Display volume group information | ||
+ | |||
+ | vgdisplay | ||
+ | [-A|--activevolumegroups] | ||
+ | [-c|--colon | -s|--short | -v|--verbose] | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [-h|--help] | ||
+ | [--ignorelockingfailure] | ||
+ | [--ignoreskippedcluster] | ||
+ | [--nosuffix] | ||
+ | [-P|--partial] | ||
+ | [--readonly] | ||
+ | [--units hHbBsSkKmMgGtTpPeE] | ||
+ | [--version] | ||
+ | [VolumeGroupName [VolumeGroupName...]] | ||
+ | |||
+ | vgdisplay --columns|-C | ||
+ | [--aligned] | ||
+ | [--binary] | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [-h|--help] | ||
+ | [--ignorelockingfailure] | ||
+ | [--ignoreskippedcluster] | ||
+ | [--noheadings] | ||
+ | [--nosuffix] | ||
+ | [-o|--options [+]Field[, | ||
+ | [-O|--sort [+|-]key1[, | ||
+ | [-P|--partial] | ||
+ | [-S|--select Selection] | ||
+ | [--readonly] | ||
+ | [--separator Separator] | ||
+ | [--unbuffered] | ||
+ | [--units hHbBsSkKmMgGtTpPeE] | ||
+ | [--verbose] | ||
+ | [--version] | ||
+ | [VolumeGroupName [VolumeGroupName...]] | ||
+ | </ | ||
+ | |||
+ | ===Logical Volumes (LV)=== | ||
+ | |||
+ | Pour créer un **Logical Volume** dénommé **lv0** dans le **Volume Group** **vg0**, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# lvcreate -L 350 -n lv0 vg0 | ||
+ | Rounding up size to full physical extent 352.00 MiB | ||
+ | Logical volume " | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | Notez que la taille du LV est un multiple du PE. | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **lvcreate** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# lvcreate --help | ||
+ | lvcreate: Create a logical volume | ||
+ | |||
+ | lvcreate | ||
+ | [-A|--autobackup {y|n}] | ||
+ | [-a|--activate [a|e|l]{y|n}] | ||
+ | [--addtag Tag] | ||
+ | [--alloc AllocationPolicy] | ||
+ | [-H|--cache | ||
+ | [--cachemode {writeback|writethrough}] | ||
+ | [--cachepool CachePoolLogicalVolume{Name|Path}] | ||
+ | [-c|--chunksize ChunkSize] | ||
+ | [-C|--contiguous {y|n}] | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [-h|-? | ||
+ | [--errorwhenfull {y|n}] | ||
+ | [--ignoremonitoring] | ||
+ | [--monitor {y|n}] | ||
+ | [-i|--stripes Stripes [-I|--stripesize StripeSize]] | ||
+ | [-k|--setactivationskip {y|n}] | ||
+ | [-K|--ignoreactivationskip] | ||
+ | {-l|--extents LogicalExtentsNumber[%{VG|PVS|FREE}] | | ||
+ | -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]} | ||
+ | [-M|--persistent {y|n}] [-j|--major major] [--minor minor] | ||
+ | [--metadataprofile ProfileName] | ||
+ | [-m|--mirrors Mirrors [--nosync] | ||
+ | [{--mirrorlog {disk|core|mirrored}|--corelog}]] | ||
+ | [-n|--name LogicalVolumeName] | ||
+ | [--noudevsync] | ||
+ | [-p|--permission {r|rw}] | ||
+ | [--poolmetadatasize MetadataSize[bBsSkKmMgG]] | ||
+ | [--poolmetadataspare {y|n}]] | ||
+ | [--[raid]minrecoveryrate Rate] | ||
+ | [--[raid]maxrecoveryrate Rate] | ||
+ | [-r|--readahead {ReadAheadSectors|auto|none}] | ||
+ | [-R|--regionsize MirrorLogRegionSize] | ||
+ | [-T|--thin | ||
+ | [--discards {ignore|nopassdown|passdown}] | ||
+ | [--thinpool ThinPoolLogicalVolume{Name|Path}] | ||
+ | [-t|--test] | ||
+ | [--type VolumeType] | ||
+ | [-v|--verbose] | ||
+ | [-W|--wipesignatures {y|n}] | ||
+ | [-Z|--zero {y|n}] | ||
+ | [--version] | ||
+ | VolumeGroupName [PhysicalVolumePath...] | ||
+ | |||
+ | lvcreate | ||
+ | { {-s|--snapshot} OriginalLogicalVolume[Path] | | ||
+ | [-s|--snapshot] VolumeGroupName[Path] -V|--virtualsize VirtualSize} | ||
+ | {-H|--cache} VolumeGroupName[Path][/ | ||
+ | {-T|--thin} VolumeGroupName[Path][/ | ||
+ | -V|--virtualsize VirtualSize} | ||
+ | [-A|--autobackup {y|n}] | ||
+ | [--addtag Tag] | ||
+ | [--alloc AllocationPolicy] | ||
+ | [--cachepolicy Policy] [--cachesettings Key=Value] | ||
+ | [-c|--chunksize] | ||
+ | [-C|--contiguous {y|n}] | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [--discards {ignore|nopassdown|passdown}] | ||
+ | [-h|-? | ||
+ | [--ignoremonitoring] | ||
+ | [--monitor {y|n}] | ||
+ | [-i|--stripes Stripes [-I|--stripesize StripeSize]] | ||
+ | [-k|--setactivationskip {y|n}] | ||
+ | [-K|--ignoreactivationskip] | ||
+ | {-l|--extents LogicalExtentsNumber[%{VG|FREE|ORIGIN}] | | ||
+ | -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]} | ||
+ | [--poolmetadatasize MetadataVolumeSize[bBsSkKmMgG]] | ||
+ | [-M|--persistent {y|n}] [-j|--major major] [--minor minor] | ||
+ | [--metadataprofile ProfileName] | ||
+ | [-n|--name LogicalVolumeName] | ||
+ | [--noudevsync] | ||
+ | [-p|--permission {r|rw}] | ||
+ | [-r|--readahead ReadAheadSectors|auto|none] | ||
+ | [-t|--test] | ||
+ | [{--thinpool ThinPoolLogicalVolume[Path] | | ||
+ | --cachepool CachePoolLogicalVolume[Path]}] | ||
+ | [-v|--verbose] | ||
+ | [--version] | ||
+ | [PhysicalVolumePath...] | ||
+ | </ | ||
+ | |||
+ | Créez maintenant un répertoire dans /mnt pour monter lv0 : | ||
+ | |||
+ | [root@centos7 ~]# mkdir /mnt/lvm | ||
+ | |||
+ | Créez un système de fichiers en **ext3** sur / | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mke2fs -j / | ||
+ | mke2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem label= | ||
+ | OS type: Linux | ||
+ | Block size=1024 (log=0) | ||
+ | Fragment size=1024 (log=0) | ||
+ | Stride=0 blocks, Stripe width=0 blocks | ||
+ | 90112 inodes, 360448 blocks | ||
+ | 18022 blocks (5.00%) reserved for the super user | ||
+ | First data block=1 | ||
+ | Maximum filesystem blocks=67633152 | ||
+ | 44 block groups | ||
+ | 8192 blocks per group, 8192 fragments per group | ||
+ | 2048 inodes per group | ||
+ | Superblock backups stored on blocks: | ||
+ | 8193, 24577, 40961, 57345, 73729, 204801, 221185 | ||
+ | |||
+ | Allocating group tables: done | ||
+ | Writing inode tables: done | ||
+ | Creating journal (8192 blocks): done | ||
+ | Writing superblocks and filesystem accounting information: | ||
+ | </ | ||
+ | |||
+ | Montez votre lv0 : | ||
+ | |||
+ | [root@centos7 ~]# mount -t ext3 / | ||
+ | |||
+ | Vous allez maintenant copier le contenu de votre répertoire /home vers /mnt/lvm. | ||
+ | |||
+ | Saisissez donc la commande pour copier le contenu de /home : | ||
+ | |||
+ | [root@centos7 ~]# cp -a /home /mnt/lvm | ||
+ | |||
+ | Constatez ensuite le contenu de /mnt/lvm : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# ls -l /mnt/lvm | ||
+ | total 14 | ||
+ | drwxr-xr-x. 5 root root 1024 Oct 15 18:27 home | ||
+ | drwx------. 2 root root 12288 Oct 20 18:24 lost+found | ||
+ | </ | ||
+ | |||
+ | Une particularité du volume logique est la capacité de d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# df -h /mnt/lvm | ||
+ | Filesystem | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Dans la cas de notre exemple, la taille est de **333 Mo** avec **50 Mo** occupé. | ||
+ | |||
+ | ====LAB #4 - Etendre un Volume Logique à Chaud==== | ||
+ | |||
+ | Pour agrandir un volume logique, le paquet **lvm2** contient les commandes **lvextend** et **resize2fs** : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# 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 lv0 successfully resized | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | Notez que l' | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **lvextend** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# lvextend --help | ||
+ | lvextend: Add space to a logical volume | ||
+ | |||
+ | lvextend | ||
+ | [-A|--autobackup y|n] | ||
+ | [--alloc AllocationPolicy] | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [-f|--force] | ||
+ | [-h|--help] | ||
+ | [-i|--stripes Stripes [-I|--stripesize StripeSize]] | ||
+ | {-l|--extents [+]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}] | | ||
+ | -L|--size [+]LogicalVolumeSize[bBsSkKmMgGtTpPeE]} | ||
+ | --poolmetadatasize [+]MetadataVolumeSize[bBsSkKmMgG]} | ||
+ | [-m|--mirrors Mirrors] | ||
+ | [--nosync] | ||
+ | [--use-policies] | ||
+ | [-n|--nofsck] | ||
+ | [--noudevsync] | ||
+ | [-r|--resizefs] | ||
+ | [-t|--test] | ||
+ | [--type VolumeType] | ||
+ | [-v|--verbose] | ||
+ | [--version] | ||
+ | LogicalVolume[Path] [ PhysicalVolumePath... ] | ||
+ | </ | ||
+ | |||
+ | Le volume ayant été agrandi, il est necessaire maintenant d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# resize2fs / | ||
+ | resize2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem at / | ||
+ | old_desc_blocks = 2, new_desc_blocks = 2 | ||
+ | The filesystem on / | ||
+ | </ | ||
+ | |||
+ | Constatez maintenant la modification de la taille du volume : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# df -h /mnt/lvm | ||
+ | Filesystem | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Vous noterez que la taille a augmentée mais que les données sont toujours présentes. | ||
+ | |||
+ | ====LAB #5 - Snapshots==== | ||
+ | |||
+ | Un snapshot est un instantané d'un système de fichiers. Dans cet exemple, vous allez créer un snapshot de votre lv0 : | ||
+ | |||
+ | Avant de commencer, créez un fichier de 10Mo dans le volume : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# dd if=/ | ||
+ | 10+0 records in | ||
+ | 10+0 records out | ||
+ | 10485760 bytes (10 MB) copied, 0.044034 s, 238 MB/s | ||
+ | </ | ||
+ | |||
+ | Créez maintenant un snapshot : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# lvcreate -s -L 65M -n testsnap / | ||
+ | Rounding up size to full physical extent 72.00 MiB | ||
+ | Logical volume " | ||
+ | </ | ||
+ | |||
+ | Pour avoir une confirmation de la création du snapshot, utilisez la commande **lvs** : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# lvs | ||
+ | LV | ||
+ | lv0 vg0 owi-aos--- 456.00m | ||
+ | testsnap vg0 swi-a-s--- | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | Notez que le snapshot est créé dans le même VG que le LV d' | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **lvs** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# lvs --help | ||
+ | lvs: Display information about logical volumes | ||
+ | |||
+ | lvs | ||
+ | [-a|--all] | ||
+ | [--aligned] | ||
+ | [--binary] | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [-h|--help] | ||
+ | [--ignorelockingfailure] | ||
+ | [--ignoreskippedcluster] | ||
+ | [--nameprefixes] | ||
+ | [--noheadings] | ||
+ | [--nosuffix] | ||
+ | [-o|--options [+]Field[, | ||
+ | [-O|--sort [+|-]key1[, | ||
+ | [-P|--partial] | ||
+ | [--readonly] | ||
+ | [--rows] | ||
+ | [--segments] | ||
+ | [-S|--select Selection] | ||
+ | [--separator Separator] | ||
+ | [--trustcache] | ||
+ | [--unbuffered] | ||
+ | [--units hHbBsSkKmMgGtTpPeE] | ||
+ | [--unquoted] | ||
+ | [-v|--verbose] | ||
+ | [--version] | ||
+ | [LogicalVolume[Path] [LogicalVolume[Path]...]] | ||
+ | </ | ||
+ | |||
+ | Créez maintenant un répertoire pour monter le snapshot : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mkdir / | ||
+ | </ | ||
+ | |||
+ | Montez le snapshot : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mount / | ||
+ | </ | ||
+ | |||
+ | Comparez le volume d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# ls -l /mnt/lvm | ||
+ | total 10296 | ||
+ | -rw-r--r--. 1 root root 10485760 Oct 20 18:53 10M | ||
+ | drwxr-xr-x. 5 root root 1024 Oct 15 18:27 home | ||
+ | drwx------. 2 root root 12288 Oct 20 18:24 lost+found | ||
+ | |||
+ | [root@centos7 ~]# ls -l / | ||
+ | total 10296 | ||
+ | -rw-r--r--. 1 root root 10485760 Oct 20 18:53 10M | ||
+ | drwxr-xr-x. 5 root root 1024 Oct 15 18:27 home | ||
+ | drwx------. 2 root root 12288 Oct 20 18:24 lost+found | ||
+ | </ | ||
+ | |||
+ | Supprimez maintenant le fichier **10M** de votre volume d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# rm / | ||
+ | rm: remove regular file ‘/ | ||
+ | </ | ||
+ | |||
+ | Constatez le résultat de cette suppression : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# df -Ph /mnt/lvm | ||
+ | Filesystem | ||
+ | / | ||
+ | [root@centos7 ~]# df -Ph / | ||
+ | Filesystem | ||
+ | / | ||
+ | [root@centos7 ~]# lvs | ||
+ | LV | ||
+ | lv0 vg0 owi-aos--- 456.00m | ||
+ | testsnap vg0 swi-aos--- | ||
+ | </ | ||
+ | |||
+ | <WRAP center round todo 60%> | ||
+ | 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 ~]# umount / | ||
+ | [root@centos7 ~]# lvremove / | ||
+ | Do you really want to remove active logical volume testsnap? [y/n]: y | ||
+ | Logical volume " | ||
+ | [root@centos7 ~]# umount /mnt/lvm | ||
+ | [root@centos7 ~]# lvremove / | ||
+ | Do you really want to remove active logical volume lv0? [y/n]: y | ||
+ | Logical volume " | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | Notez que cette opération necéssite à ce que le volume logique soit démonté. | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **lvremove** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# lvremove --help | ||
+ | lvremove: Remove logical volume(s) from the system | ||
+ | |||
+ | lvremove | ||
+ | [-A|--autobackup y|n] | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [-f|--force] | ||
+ | [-h|--help] | ||
+ | [--noudevsync] | ||
+ | [-t|--test] | ||
+ | [-v|--verbose] | ||
+ | [--version] | ||
+ | LogicalVolume[Path] [LogicalVolume[Path]...] | ||
+ | </ | ||
+ | |||
+ | Le Volume Group peut aussi être supprimé : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# vgremove vg0 | ||
+ | Volume group " | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **vgremove** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# vgremove --help | ||
+ | vgremove: Remove volume group(s) | ||
+ | |||
+ | vgremove | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [-f|--force] | ||
+ | [-h|--help] | ||
+ | [--noudevsync] | ||
+ | [-t|--test] | ||
+ | [-v|--verbose] | ||
+ | [--version] | ||
+ | VolumeGroupName [VolumeGroupName...] | ||
+ | </ | ||
+ | |||
+ | Ainsi que le volume physique : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# pvremove /dev/sda6 /dev/sda7 /dev/sda9 | ||
+ | Labels on physical volume "/ | ||
+ | Labels on physical volume "/ | ||
+ | Labels on physical volume "/ | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **pvremove** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# pvremove --help | ||
+ | pvremove: Remove LVM label(s) from physical volume(s) | ||
+ | |||
+ | pvremove | ||
+ | [--commandprofile ProfileName] | ||
+ | [-d|--debug] | ||
+ | [-f[f]|--force [--force]] | ||
+ | [-h|-? | ||
+ | [-t|--test] | ||
+ | [-v|--verbose] | ||
+ | [--version] | ||
+ | [-y|--yes] | ||
+ | PhysicalVolume [PhysicalVolume...] | ||
+ | </ | ||
+ | |||
+ | =====Systèmes de Fichiers Journalisés===== | ||
+ | |||
+ | ====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:// | ||
+ | </ | ||
+ | |||
+ | ====Ext3==== | ||
+ | |||
+ | Ext3 est une évolution de Ext2 et a pour principale différence d' | ||
+ | |||
+ | * être utilisé à partir d'une partition Ext2, sans avoir à sauvegarder et à restaurer des données, | ||
+ | * utiliser tous les utilitaires de maintenance pour les systèmes de fichiers ext2, comme fsck, | ||
+ | * utiliser le logiciel dump, ce qui n'est pas le cas avec %%ReiserFS%%. | ||
+ | |||
+ | Pour plus d' | ||
+ | |||
+ | ===Gestion d' | ||
+ | |||
+ | Notez maintenant le numéro de la dernière partition que vous avez précédemment créée : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# fdisk -l | ||
+ | |||
+ | Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors | ||
+ | Units = sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disk label type: dos | ||
+ | Disk identifier: 0x000f2006 | ||
+ | |||
+ | | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | |||
+ | 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/ | ||
+ | </ | ||
+ | |||
+ | Dans le cas de RHEL/CentOS 7, il s'agit de **/ | ||
+ | |||
+ | Sous RHEL/CentOS créez un filesystem Ext3 sur /dev/sda12 en utilisant la commande **mke2fs -j** : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mke2fs -j /dev/sda12 | ||
+ | mke2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem label= | ||
+ | OS type: Linux | ||
+ | Block size=1024 (log=0) | ||
+ | Fragment size=1024 (log=0) | ||
+ | Stride=0 blocks, Stripe width=0 blocks | ||
+ | 51200 inodes, 204800 blocks | ||
+ | 10240 blocks (5.00%) reserved for the super user | ||
+ | First data block=1 | ||
+ | Maximum filesystem blocks=67371008 | ||
+ | 25 block groups | ||
+ | 8192 blocks per group, 8192 fragments per group | ||
+ | 2048 inodes per group | ||
+ | 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: | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **mke2fs** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mke2fs --help | ||
+ | mke2fs: invalid option -- ' | ||
+ | Usage: mke2fs [-c|-l filename] [-b block-size] [-C cluster-size] | ||
+ | [-i bytes-per-inode] [-I inode-size] [-J journal-options] | ||
+ | [-G flex-group-size] [-N number-of-inodes] | ||
+ | [-m reserved-blocks-percentage] [-o creator-os] | ||
+ | [-g blocks-per-group] [-L volume-label] [-M last-mounted-directory] | ||
+ | [-O feature[, | ||
+ | [-t fs-type] [-T usage-type ] [-U UUID] [-jnqvDFKSV] device [blocks-count] | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Lors de la mise en place d'un filesystem ext2/ | ||
+ | </ | ||
+ | |||
+ | ===LAB #7 - Convertir un Système de Fichiers Ext3 en Ext2=== | ||
+ | |||
+ | Pour vérifier si un système de fichiers Ext2 est journalisé, | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# dumpe2fs -h /dev/sda12 | ||
+ | dumpe2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem volume name: < | ||
+ | Last mounted on: <not available> | ||
+ | Filesystem UUID: ee905f90-e7cd-41a0-aa75-a3eb9e94b183 | ||
+ | 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: | ||
+ | Free blocks: | ||
+ | Free inodes: | ||
+ | First block: | ||
+ | Block size: 1024 | ||
+ | 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 22 11:40:33 2015 | ||
+ | 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: | ||
+ | Journal inode: | ||
+ | Default directory hash: | ||
+ | Directory Hash Seed: 454137e5-3ce9-40c9-911b-d4274808d86f | ||
+ | Journal backup: | ||
+ | Journal features: | ||
+ | Journal size: 4113k | ||
+ | Journal length: | ||
+ | Journal sequence: | ||
+ | Journal start: | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Le drapeau **Filesystem features: | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# dumpe2fs --help | ||
+ | dumpe2fs 1.42.9 (28-Dec-2013) | ||
+ | dumpe2fs: invalid option -- ' | ||
+ | Usage: dumpe2fs [-bfhixV] [-o superblock=< | ||
+ | </ | ||
+ | |||
+ | Pour supprimer Ext3 sur cette partition, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# tune2fs -O ^has_journal /dev/sda12 | ||
+ | tune2fs 1.42.9 (28-Dec-2013) | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# tune2fs --help | ||
+ | tune2fs 1.42.9 (28-Dec-2013) | ||
+ | tune2fs: invalid option -- ' | ||
+ | Usage: tune2fs [-c max_mounts_count] [-e errors_behavior] [-g group] | ||
+ | [-i interval[d|m|w]] [-j] [-J journal_options] [-l] | ||
+ | [-m reserved_blocks_percent] [-o [^]mount_options[, | ||
+ | [-r reserved_blocks_count] [-u user] [-C mount_count] [-L volume_label] | ||
+ | [-M last_mounted_dir] [-O [^]feature[, | ||
+ | [-E extended-option[, | ||
+ | [ -I new_inode_size ] device | ||
+ | </ | ||
+ | |||
+ | Constatez le résultat de cette commande : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# dumpe2fs -h /dev/sda12 | ||
+ | dumpe2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem volume name: < | ||
+ | Last mounted on: <not available> | ||
+ | Filesystem UUID: ee905f90-e7cd-41a0-aa75-a3eb9e94b183 | ||
+ | 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: | ||
+ | Free blocks: | ||
+ | Free inodes: | ||
+ | First block: | ||
+ | Block size: 1024 | ||
+ | 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 22 11:43:18 2015 | ||
+ | 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: | ||
+ | Default directory hash: | ||
+ | Directory Hash Seed: 454137e5-3ce9-40c9-911b-d4274808d86f | ||
+ | Journal backup: | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Notez que le drapeau **Filesystem features: | ||
+ | </ | ||
+ | |||
+ | Supprimez maintenant l' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# fsck /dev/sda12 | ||
+ | fsck from util-linux 2.23.2 | ||
+ | e2fsck 1.42.9 (28-Dec-2013) | ||
+ | /dev/sda12: clean, 11/51200 files, 8013/204800 blocks | ||
+ | </ | ||
+ | |||
+ | Sous RHEL/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mkdir /mnt/sda12 | ||
+ | </ | ||
+ | |||
+ | Sous RHEL/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mount -t ext3 /dev/sda12 /mnt/sda12 | ||
+ | mount: wrong fs type, bad option, bad superblock on /dev/sda12, | ||
+ | | ||
+ | |||
+ | In some cases useful info is found in syslog - try | ||
+ | dmesg | tail or so. | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Notez l' | ||
+ | </ | ||
+ | |||
+ | Montez maintenant le système de fichiers en tant que Ext2 : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mount -t ext2 /dev/sda12 /mnt/sda12 | ||
+ | [root@centos7 ~]# | ||
+ | </ | ||
+ | |||
+ | ===LAB #8 - Convertir un Système de Fichiers Ext2 en Ext3=== | ||
+ | |||
+ | Sous RHEL/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# umount /mnt/sda12 | ||
+ | |||
+ | [root@centos7 ~]# tune2fs -j /dev/sda12 | ||
+ | tune2fs 1.42.9 (28-Dec-2013) | ||
+ | Creating journal inode: done | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Notez que vous avez du démonter la partition avant d' | ||
+ | </ | ||
+ | |||
+ | ===LAB #9 - 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. | ||
+ | |||
+ | Dans votre VM RHEL/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mke2fs -O journal_dev /dev/sda11 | ||
+ | mke2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem label= | ||
+ | OS type: Linux | ||
+ | Block size=1024 (log=0) | ||
+ | Fragment size=1024 (log=0) | ||
+ | Stride=0 blocks, Stripe width=0 blocks | ||
+ | 0 inodes, 512000 blocks | ||
+ | 0 blocks (0.00%) reserved for the super user | ||
+ | First data block=1 | ||
+ | 0 block group | ||
+ | 8192 blocks per group, 8192 fragments per group | ||
+ | 0 inodes per group | ||
+ | Superblock backups stored on blocks: | ||
+ | |||
+ | Zeroing journal device: [root@centos7 ~]# | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Notez l' | ||
+ | </ | ||
+ | |||
+ | Sous RHEL/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mke2fs -j -J device=/ | ||
+ | mke2fs 1.42.9 (28-Dec-2013) | ||
+ | Using journal device' | ||
+ | Filesystem label= | ||
+ | OS type: Linux | ||
+ | Block size=1024 (log=0) | ||
+ | Fragment size=1024 (log=0) | ||
+ | Stride=0 blocks, Stripe width=0 blocks | ||
+ | 51200 inodes, 204800 blocks | ||
+ | 10240 blocks (5.00%) reserved for the super user | ||
+ | First data block=1 | ||
+ | Maximum filesystem blocks=67371008 | ||
+ | 25 block groups | ||
+ | 8192 blocks per group, 8192 fragments per group | ||
+ | 2048 inodes per group | ||
+ | Superblock backups stored on blocks: | ||
+ | 8193, 24577, 40961, 57345, 73729 | ||
+ | |||
+ | Allocating group tables: done | ||
+ | Writing inode tables: done | ||
+ | Adding journal to device /dev/sda11: done | ||
+ | Writing superblocks and filesystem accounting information: | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Notez que le journal a été placé sur /dev/sda11 graĉe à l' | ||
+ | </ | ||
+ | |||
+ | ===LAB #10 - Modifier la Fréquence de Vérification du Système de Fichiers Ext3=== | ||
+ | |||
+ | Sous RHEL/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# tune2fs -i 100d /dev/sda12 | ||
+ | tune2fs 1.42.9 (28-Dec-2013) | ||
+ | Setting interval between checks to 8640000 seconds | ||
+ | </ | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# dumpe2fs /dev/sda12 | grep UUID | ||
+ | dumpe2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem UUID: 80e060ac-f2d1-4e6d-8c56-0ac0baf5bcfc | ||
+ | Journal UUID: | ||
+ | </ | ||
+ | |||
+ | ====Ext4==== | ||
+ | |||
+ | Le système de fichiers **Ext4** fut 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' | ||
+ | |||
+ | ===LAB #11 - Créer un Système de Fichiers Ext4=== | ||
+ | |||
+ | Sous RHEL/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mkfs.ext4 /dev/sda11 | ||
+ | mke2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem label= | ||
+ | OS type: Linux | ||
+ | Block size=1024 (log=0) | ||
+ | Fragment size=1024 (log=0) | ||
+ | Stride=0 blocks, Stripe width=0 blocks | ||
+ | 128016 inodes, 512000 blocks | ||
+ | 25600 blocks (5.00%) reserved for the super user | ||
+ | First data block=1 | ||
+ | Maximum filesystem blocks=34078720 | ||
+ | 63 block groups | ||
+ | 8192 blocks per group, 8192 fragments per group | ||
+ | 2032 inodes per group | ||
+ | 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: | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mkfs.ext4 --help | ||
+ | mkfs.ext4: invalid option -- ' | ||
+ | Usage: mkfs.ext4 [-c|-l filename] [-b block-size] [-C cluster-size] | ||
+ | [-i bytes-per-inode] [-I inode-size] [-J journal-options] | ||
+ | [-G flex-group-size] [-N number-of-inodes] | ||
+ | [-m reserved-blocks-percentage] [-o creator-os] | ||
+ | [-g blocks-per-group] [-L volume-label] [-M last-mounted-directory] | ||
+ | [-O feature[, | ||
+ | [-t fs-type] [-T usage-type ] [-U UUID] [-jnqvDFKSV] device [blocks-count] | ||
+ | </ | ||
+ | |||
+ | Consultez maintenant les caractéristiques du système de fichier : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# dumpe2fs /dev/sda11 | more | ||
+ | dumpe2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem volume name: < | ||
+ | Last mounted on: <not available> | ||
+ | Filesystem UUID: 6300bd45-458a-40bd-a994-20c8fb202d93 | ||
+ | Filesystem magic number: | ||
+ | Filesystem revision #: 1 (dynamic) | ||
+ | Filesystem features: | ||
+ | size | ||
+ | Filesystem flags: | ||
+ | Default mount options: | ||
+ | Filesystem state: | ||
+ | Errors behavior: | ||
+ | Filesystem OS type: Linux | ||
+ | Inode count: | ||
+ | Block count: | ||
+ | Reserved block count: | ||
+ | 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: | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | ===LAB #12 - Ajouter une Etiquette au Système de Fichiers Ext4=== | ||
+ | |||
+ | Utilisez la commande **e2label** pour associer une étiquette au système de fichiers : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# e2label /dev/sda11 my_ext4 | ||
+ | [root@centos7 ~]# dumpe2fs /dev/sda11 | more | ||
+ | dumpe2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem volume name: | ||
+ | Last mounted on: <not available> | ||
+ | Filesystem UUID: 6300bd45-458a-40bd-a994-20c8fb202d93 | ||
+ | Filesystem magic number: | ||
+ | Filesystem revision #: 1 (dynamic) | ||
+ | Filesystem features: | ||
+ | size | ||
+ | Filesystem flags: | ||
+ | Default mount options: | ||
+ | Filesystem state: | ||
+ | Errors behavior: | ||
+ | Filesystem OS type: Linux | ||
+ | Inode count: | ||
+ | Block count: | ||
+ | Reserved block count: | ||
+ | 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: | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** - Notez que l' | ||
+ | </ | ||
+ | |||
+ | Sous RHEL/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mkdir /mnt/sda11 | ||
+ | |||
+ | [root@centos7 ~]# mount -t ext3 /dev/sda11 /mnt/sda11 | ||
+ | mount: wrong fs type, bad option, bad superblock on /dev/sda11, | ||
+ | | ||
+ | |||
+ | In some cases useful info is found in syslog - try | ||
+ | dmesg | tail or so. | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** - Notez l' | ||
+ | </ | ||
+ | |||
+ | Montez de nouveau la partition **sans** stipuler le type de système de fichiers : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mount /dev/sda11 /mnt/sda11 | ||
+ | |||
+ | [root@centos7 ~]# mount | grep sda11 | ||
+ | /dev/sda11 on /mnt/sda11 type ext4 (rw, | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** - Constatez que la partition a été monté en tant qu' | ||
+ | </ | ||
+ | |||
+ | ===LAB #13 - Convertir un Système de Fichiers Ext3 en Ext4=== | ||
+ | |||
+ | Créez un système de fichiers ext3 sur /dev/sda12 : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mkfs.ext3 /dev/sda12 | ||
+ | mke2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem label= | ||
+ | OS type: Linux | ||
+ | Block size=1024 (log=0) | ||
+ | Fragment size=1024 (log=0) | ||
+ | Stride=0 blocks, Stripe width=0 blocks | ||
+ | 51200 inodes, 204800 blocks | ||
+ | 10240 blocks (5.00%) reserved for the super user | ||
+ | First data block=1 | ||
+ | Maximum filesystem blocks=67371008 | ||
+ | 25 block groups | ||
+ | 8192 blocks per group, 8192 fragments per group | ||
+ | 2048 inodes per group | ||
+ | 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@centos7 ~]# mount /dev/sda12 /mnt/sda12 | ||
+ | |||
+ | [root@centos7 ~]# ls -l /mnt/sda12 | ||
+ | total 12 | ||
+ | drwx------. 2 root root 12288 Oct 22 11:57 lost+found | ||
+ | </ | ||
+ | |||
+ | Créez le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# touch / | ||
+ | </ | ||
+ | |||
+ | Injectez la chaine **check file** dans le fichier / | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# echo "check file" > / | ||
+ | |||
+ | [root@centos7 ~]# umount /dev/sda12 | ||
+ | </ | ||
+ | |||
+ | Exécutez e2fsck sur /dev/sda12 : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# e2fsck /dev/sda12 | ||
+ | e2fsck 1.42.9 (28-Dec-2013) | ||
+ | /dev/sda12: clean, 12/51200 files, 12128/ | ||
+ | </ | ||
+ | |||
+ | Convertissez /dev/sda12 en Ext4 : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# tune2fs -O extents, | ||
+ | tune2fs 1.42.9 (28-Dec-2013) | ||
+ | </ | ||
+ | |||
+ | Optimisez le système de fichiers : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# e2fsck -fDC0 /dev/sda12 | ||
+ | e2fsck 1.42.9 (28-Dec-2013) | ||
+ | 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/sda12: ***** FILE SYSTEM WAS MODIFIED ***** | ||
+ | /dev/sda12: 12/51200 files (0.0% non-contiguous), | ||
+ | </ | ||
+ | |||
+ | Essayez de monter **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mount -t ext3 /dev/sda12 /mnt/sda12 | ||
+ | mount: wrong fs type, bad option, bad superblock on /dev/sda12, | ||
+ | | ||
+ | |||
+ | In some cases useful info is found in syslog - try | ||
+ | dmesg | tail or so. | ||
+ | </ | ||
+ | |||
+ | Montez /dev/sda12 sans spécifier le type de fichiers Ext3 et vérifiez le contenu du fichier **check_file** : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mount /dev/sda12 /mnt/sda12 | ||
+ | |||
+ | [root@centos7 ~]# ls -l /mnt/sda12 | ||
+ | total 14 | ||
+ | -rw-r--r--. 1 root root 11 Oct 22 11:59 check_file | ||
+ | drwx------. 2 root root 12288 Oct 22 11:57 lost+found | ||
+ | |||
+ | [root@centos7 ~]# cat / | ||
+ | check file | ||
+ | </ | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# dumpe2fs /dev/sda11 | grep UUID | ||
+ | dumpe2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem UUID: 6300bd45-458a-40bd-a994-20c8fb202d93 | ||
+ | |||
+ | [root@centos7 ~]# dumpe2fs /dev/sda12 | grep UUID | ||
+ | dumpe2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem UUID: 090106dc-6331-41fe-aab6-0e9138af8f9e | ||
+ | </ | ||
+ | |||
+ | ====XFS==== | ||
+ | |||
+ | XFS est un système de fichiers 64-bit journalisé de haute performance crée par SGI pour son système d' | ||
+ | |||
+ | Debian propose aussi une version 32 bits du système de fichiers XFS. | ||
+ | |||
+ | Pour plus d' | ||
+ | |||
+ | ===LAB #14 - Créer un Système de Fichiers XFS=== | ||
+ | |||
+ | Démontez **/ | ||
+ | |||
+ | < | ||
+ | SUSE12SP1:~ # umount /dev/sda12 | ||
+ | </ | ||
+ | |||
+ | Créez un système de fichiers XFS sur la partition **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mkfs.xfs /dev/sda12 | ||
+ | mkfs.xfs: /dev/sda12 appears to contain an existing filesystem (ext4). | ||
+ | mkfs.xfs: Use the -f option to force overwrite. | ||
+ | [root@centos7 ~]# mkfs.xfs -f /dev/sda12 | ||
+ | meta-data=/ | ||
+ | | ||
+ | | ||
+ | data | ||
+ | | ||
+ | naming | ||
+ | log =internal log | ||
+ | | ||
+ | realtime =none | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** - Notez l' | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mkfs.xfs --help | ||
+ | mkfs.xfs: invalid option -- ' | ||
+ | unknown option -- | ||
+ | Usage: mkfs.xfs | ||
+ | /* blocksize */ [-b log=n|size=num] | ||
+ | /* metadata */ [-m crc=0|1, | ||
+ | /* data subvol */ [-d agcount=n, | ||
+ | (sunit=value, | ||
+ | sectlog=n|sectsize=num | ||
+ | /* force overwrite */ [-f] | ||
+ | /* inode size */ [-i log=n|perblock=n|size=num, | ||
+ | projid32bit=0|1] | ||
+ | /* no discard */ [-K] | ||
+ | /* log subvol */ [-l agnum=n, | ||
+ | sunit=value|su=num, | ||
+ | lazy-count=0|1] | ||
+ | /* label */ [-L label (maximum 12 characters)] | ||
+ | /* naming */ [-n log=n|size=num, | ||
+ | /* no-op info only */ [-N] | ||
+ | /* prototype file */ [-p fname] | ||
+ | /* quiet */ [-q] | ||
+ | /* realtime subvol */ [-r extsize=num, | ||
+ | /* sectorsize */ [-s log=n|size=num] | ||
+ | /* version */ [-V] | ||
+ | devicename | ||
+ | < | ||
+ | <num> is xxx (bytes), xxxs (sectors), xxxb (fs blocks), xxxk (xxx KiB), | ||
+ | xxxm (xxx MiB), xxxg (xxx GiB), xxxt (xxx TiB) or xxxp (xxx PiB). | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | Consultez maintenant les caractéristiques du système de fichier : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# xfs_info /dev/sda12 | ||
+ | xfs_info: /dev/sda12 is not a mounted XFS filesystem | ||
+ | |||
+ | [root@centos7 ~]# mkdir /mnt/sda12 | ||
+ | |||
+ | [root@centos7 ~]# mount -t xfs /dev/sda12 /mnt/sda12 | ||
+ | |||
+ | [root@centos7 ~]# xfs_info /dev/sda12 | ||
+ | meta-data=/ | ||
+ | | ||
+ | | ||
+ | data | ||
+ | | ||
+ | naming | ||
+ | log =internal | ||
+ | | ||
+ | realtime =none | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | Notez que la partition XFS doit être monté pour pouvoir utiliser la commande **xfs_info**. | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# xfs_info --help | ||
+ | / | ||
+ | Usage: xfs_info [-V] [-t mtab] mountpoint | ||
+ | </ | ||
+ | |||
+ | ===LAB #15 - Ajouter une Etiquette au Système de Fichiers XFS=== | ||
+ | |||
+ | Utilisez la commande **xfs_admin** pour associer une étiquette au système de fichiers : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# xfs_admin -L my_xfs /dev/sda12 | ||
+ | xfs_admin: /dev/sda12 contains a mounted filesystem | ||
+ | |||
+ | fatal error -- couldn' | ||
+ | |||
+ | [root@centos7 ~]# umount /dev/sda12 | ||
+ | |||
+ | [root@centos7 ~]# xfs_admin -L my_xfs /dev/sda12 | ||
+ | writing all SBs | ||
+ | new label = " | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | Notez que la partition XFS doit être démonté pour pouvoir utiliser la commande **xfs_admin**. | ||
+ | </ | ||
+ | |||
+ | Pour voir l' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# xfs_admin -l /dev/sda12 | ||
+ | label = " | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | Notez que l' | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# xfs_admin --help | ||
+ | / | ||
+ | Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-U uuid] device | ||
+ | </ | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# xfs_admin -u /dev/sda12 | ||
+ | UUID = 15db1b62-0866-4aa4-9ac1-3ac325a4e20f | ||
+ | </ | ||
+ | |||
+ | <WRAP center round 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> | ||
+ | **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 | | ||
+ | |||
+ | =====Le Swap===== | ||
+ | |||
+ | ====Taille du swap==== | ||
+ | |||
+ | Le tableau suivant résume la taille du swap recommandée en fonction de la mémoire de la machine : | ||
+ | |||
+ | ^ Mémoire ^ Taille du swap ^ | ||
+ | | 4 Go ou moins | 2 Go | | ||
+ | | 4 Go à 16 Go | 4 Go | | ||
+ | | 16 Go à 64 Go | 8 Go | | ||
+ | | 64 Go à 256 Go | 16 Go | | ||
+ | |||
+ | ====Partitions de swap==== | ||
+ | |||
+ | Une partition de swap peut être créée sur : | ||
+ | |||
+ | * une partition du disque dur | ||
+ | * un RAID logiciel | ||
+ | * un Volume Logique | ||
+ | |||
+ | ====La Commande swapon==== | ||
+ | |||
+ | Pour préparer un espace de swap, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# swapon -s | ||
+ | Filename Type Size Used Priority | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Vous noterez que dans l' | ||
+ | </ | ||
+ | |||
+ | ===Options de la Commande=== | ||
+ | |||
+ | Les options de la commande swapon sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# swapon --help | ||
+ | |||
+ | Usage: | ||
+ | | ||
+ | |||
+ | Options: | ||
+ | -a, --all enable all swaps from /etc/fstab | ||
+ | -d, --discard[=< | ||
+ | -e, --ifexists | ||
+ | -f, --fixpgsz | ||
+ | -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 columns (for --show): | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | For more details see swapon(8). | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : L' | ||
+ | </ | ||
+ | |||
+ | ====La Commande swapoff==== | ||
+ | |||
+ | Dans le cas de notre exemple, la partition de swap se trouve sur **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# swapoff /dev/sda3 | ||
+ | [root@centos7 ~]# swapon -s | ||
+ | [root@centos7 ~]# | ||
+ | </ | ||
+ | |||
+ | ===Options de la Commande=== | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# swapoff --help | ||
+ | |||
+ | Usage: | ||
+ | | ||
+ | |||
+ | Options: | ||
+ | -a, --all disable all swaps from /proc/swaps | ||
+ | -v, --verbose | ||
+ | |||
+ | -h, --help | ||
+ | -V, --version | ||
+ | |||
+ | The < | ||
+ | -L < | ||
+ | -U < | ||
+ | | ||
+ | | ||
+ | < | ||
+ | < | ||
+ | |||
+ | For more details see swapoff(8). | ||
+ | </ | ||
+ | |||
+ | ====LAB #16 - 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 268Mo, appelé **swap**, saisissez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# dd if=/ | ||
+ | 256+0 records in | ||
+ | 256+0 records out | ||
+ | 268435456 bytes (268 MB) copied, 0.263327 s, 1.0 GB/s | ||
+ | </ | ||
+ | |||
+ | Pour préparer le fichier en tant qu' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mkswap /swap | ||
+ | Setting up swapspace version 1, size = 262140 KiB | ||
+ | no label, UUID=30b30bab-19b2-42f5-bec7-8a6f9eca1b3c | ||
+ | </ | ||
+ | |||
+ | Pour activer le fichier avec une priorité de **3**, saisissez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# swapon -p3 /swap | ||
+ | swapon: /swap: insecure permissions 0644, 0600 suggested. | ||
+ | [root@centos7 ~]# swapon /dev/sda3 | ||
+ | </ | ||
+ | |||
+ | Pour visualiser les éspaces swap, saisissez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# swapon -s | ||
+ | Filename Type Size Used Priority | ||
+ | /swap file 262140 0 3 | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Le fichier de swap ayant une priorité de 3 sera utilisé avant la partition de swap ayant une priorité de -1. | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Pour activer le fichier swap d'une manière permanente, il convient d' | ||
+ | </ | ||
+ | |||
+ | Désactivez maintenant le fichier swap : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# swapoff /swap | ||
+ | [root@centos7 ~]# swapon -s | ||
+ | Filename Type Size Used Priority | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Supprimez maintenant le fichier de swap : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# rm /swap | ||
+ | rm: remove regular file ‘/ | ||
+ | </ | ||
+ | |||
+ | =====Gestion des Droits===== | ||
+ | |||
+ | Dans sa conception de base, Linux utilise une approche sécurité de type **DAC**. Cette approche est maintenue dans la mise en place et l' | ||
+ | |||
+ | ^ Type de Sécurité | ||
+ | | DAC | // | ||
+ | |||
+ | ====Préparation==== | ||
+ | |||
+ | Dans votre répertoire personnel, créez un fichier tux.jpg grâce à la commande **touch**: | ||
+ | |||
+ | $ touch tux.jpg [Entrée] | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ pwd | ||
+ | / | ||
+ | [trainee@centos7 ~]$ touch tux.jpg | ||
+ | [trainee@centos7 ~]$ ls -l | grep tux.jpg | ||
+ | -rw-rw-r--. 1 trainee trainee | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Notez que le fichier créé est un fichier **texte**. En effet, Linux ne tient pas compte de l' | ||
+ | </ | ||
+ | |||
+ | ====Les Droits Unix Simples==== | ||
+ | |||
+ | Les autorisations ou droits d’accès en Linux sont communiqués comme suit : | ||
+ | |||
+ | {{free: | ||
+ | |||
+ | ou r = lecture, w = écriture et x = exécutable | ||
+ | |||
+ | Dans chaque inode est stocké le numéro de l’utilisateur à qui appartient le fichier concerné ainsi que le numéro du groupe. Quand le fichier est ouvert le système compare le numéro de l’utilisateur (UID) avec le numéro de l’utilisateur stocké dans l’inode ( Utilisateur de Référence ). Si ces deux numéros sont identiques, l’utilisateur obtient les droits du propriétaire du fichier. Si les numéros diffèrent, le système vérifie si l’utilisateur est dans le groupe référencé dans l’inode. Si oui, l’utilisateur aura les droits spécifiés pour le groupe. Si aucune condition n’est remplie, l’utilisateur se voit attribuer les droits des «autres». | ||
+ | |||
+ | Les droits pour les répertoires sont légèrement différents : | ||
+ | |||
+ | ^ r | Les éléments du répertoire sont accessible en lecture ( lister ) | | ||
+ | ^ w | Les éléments du répertoire sont modifiables ( création et suppression ). | | ||
+ | ^ x | Le nom du répertoire peut apparaître dans un chemin d' | ||
+ | |||
+ | ===La Modification des Droits=== | ||
+ | |||
+ | == La Commande chmod== | ||
+ | |||
+ | ==Mode Symbolique== | ||
+ | |||
+ | Afin de modifier les droits d’accès aux fichiers, on utilise la commande chmod dont le syntaxe est le suivant : | ||
+ | |||
+ | chmod [ -R ] catégorie opérateur permissions nom_du_fichier | ||
+ | |||
+ | ou | ||
+ | |||
+ | chmod [ -R ] ugoa +-= rwxXst nom_du_fichier | ||
+ | |||
+ | où | ||
+ | |||
+ | ^ u | user | | ||
+ | ^ g | group | | ||
+ | ^ o | other | | ||
+ | ^ a | all | | ||
+ | ^ + | autorise un accès | | ||
+ | ^ - | interdit | ||
+ | ^ = | autorise exclusivement l’accès indiqué | | ||
+ | ^ r | read | | ||
+ | ^ w | write | | ||
+ | ^ x | execute | | ||
+ | ^ X | exécution si la cible est un répertoire ou si c'est un\\ fichier est déjà exécutable pour une des // | ||
+ | ^ s | SUID/SGID bit | | ||
+ | ^ t | sticky bit | | ||
+ | |||
+ | par exemple : | ||
+ | |||
+ | $ chmod o+w tux.jpg [Entrée] | ||
+ | |||
+ | donnera aux autres l’accès en écriture sur le fichier tux.jpg : | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ chmod o+w tux.jpg | ||
+ | [trainee@centos7 ~]$ ls -l | grep tux.jpg | ||
+ | -rw-rw-rw-. 1 trainee trainee | ||
+ | </ | ||
+ | |||
+ | Tandis que : | ||
+ | |||
+ | $ chmod ug-w tux.jpg [Entrée] | ||
+ | |||
+ | ôtera les droit d’accès en écriture pour l’utilisateur et le groupe : | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ chmod ug-w tux.jpg | ||
+ | [trainee@centos7 ~]$ ls -l | grep tux.jpg | ||
+ | -r--r--rw-. 1 trainee trainee | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Seul le propriétaire du fichier ou root peuvent modifier les permissions. | ||
+ | </ | ||
+ | |||
+ | ==Mode Octal== | ||
+ | |||
+ | La commande chmod peut également être utilisée avec une représentation octale ( base de 8 ). Les valeurs octales des droits d’accès sont : | ||
+ | |||
+ | {{free: | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Ainsi les droits rwx rwx rwx correspondent à un chiffre de 777. | ||
+ | </ | ||
+ | |||
+ | La commande chmod prend donc la forme suivante: | ||
+ | |||
+ | chmod [ -R ] mode_octal nom_fichier | ||
+ | |||
+ | La commande suivante : | ||
+ | |||
+ | $ chmod 644 tux.jpg [Entrée] | ||
+ | |||
+ | Correspond donc à l’attribution des droits : rw- r-- r-- | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ chmod 644 tux.jpg | ||
+ | [trainee@centos7 ~]$ ls -l | grep tux.jpg | ||
+ | -rw-r--r--. 1 trainee trainee | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Les droits d’accès par défaut lors de la création d’un objet sont : | ||
+ | ^ Répertoires | rwx rwx rwx | 777 | | ||
+ | ^ Fichier normal | rw– rw– rw- | 666 | | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ chmod --help | ||
+ | Usage: chmod [OPTION]... MODE[, | ||
+ | or: chmod [OPTION]... OCTAL-MODE FILE... | ||
+ | or: chmod [OPTION]... --reference=RFILE FILE... | ||
+ | Change the mode of each FILE to MODE. | ||
+ | With --reference, | ||
+ | |||
+ | -c, --changes | ||
+ | -f, --silent, --quiet | ||
+ | -v, --verbose | ||
+ | --no-preserve-root | ||
+ | --preserve-root | ||
+ | --reference=RFILE | ||
+ | -R, --recursive | ||
+ | --help | ||
+ | --version | ||
+ | |||
+ | Each MODE is of the form ' | ||
+ | |||
+ | GNU coreutils online help: < | ||
+ | For complete documentation, | ||
+ | </ | ||
+ | |||
+ | ==La Commande umask== | ||
+ | |||
+ | L’utilisateur peut changer sa masque de permissions défaut lors de la création d’objets en utilisant la commande umask. | ||
+ | |||
+ | La valeur par défaut de l' | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ umask | ||
+ | 0002 | ||
+ | [trainee@centos7 ~]$ su - | ||
+ | Password: fenestros | ||
+ | Last login: Tue Oct 20 05:47:19 CEST 2015 on pts/0 | ||
+ | [root@centos7 ~]# umask | ||
+ | 0022 | ||
+ | [root@centos7 ~]# exit | ||
+ | logout | ||
+ | </ | ||
+ | |||
+ | Par exemple dans le cas où l’utilisateur souhaite que les fichiers créés dans le futur comportent des droits d’écriture et de lecture pour l’utilisateur mais uniquement des droits de lecture pour le groupe et pour les autres, il utiliserait la commande : | ||
+ | |||
+ | $ umask 022 [Entrée] | ||
+ | |||
+ | avant de créer son fichier. | ||
+ | |||
+ | <WRAP center round important> | ||
+ | umask sert à enlever des droits des droits maximaux : | ||
+ | ^ Masque maximum lors de la création d’un fichier | rw- rw- rw- | 666 | | ||
+ | ^ Droits à retirer | --- -w- -w- | 022 | | ||
+ | ^ Résultat | rw- r-- r-- | 644 | | ||
+ | </ | ||
+ | |||
+ | Dans l' | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ umask 044 | ||
+ | [trainee@centos7 ~]$ touch tux1.jpg | ||
+ | [trainee@centos7 ~]$ ls -l | grep tux1.jpg | ||
+ | -rw--w--w-. 1 trainee trainee | ||
+ | [trainee@centos7 ~]$ umask 002 | ||
+ | [trainee@centos7 ~]$ umask | ||
+ | 0002 | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ help umask | ||
+ | umask: umask [-p] [-S] [mode] | ||
+ | Display or set file mode mask. | ||
+ | | ||
+ | Sets the user file-creation mask to MODE. If MODE is omitted, prints | ||
+ | the current value of the mask. | ||
+ | | ||
+ | If MODE begins with a digit, it is interpreted as an octal number; | ||
+ | otherwise it is a symbolic mode string like that accepted by chmod(1). | ||
+ | | ||
+ | Options: | ||
+ | -p if MODE is omitted, output in a form that may be reused as input | ||
+ | -S makes the output symbolic; otherwise an octal number is output | ||
+ | | ||
+ | Exit Status: | ||
+ | Returns success unless MODE is invalid or an invalid option is given. | ||
+ | </ | ||
+ | |||
+ | ===Modifier le propriétaire ou le groupe=== | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** - Le changement de propriétaire d’un fichier se fait uniquement par l' | ||
+ | </ | ||
+ | |||
+ | ==La Commande chown== | ||
+ | |||
+ | Dans le cas du fichier tux.jpg appartenant à trainee, root peut changer le propriétaire de trainee à root avec la commande suivante : | ||
+ | |||
+ | # chown root tux.jpg [Entrée] | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ su - | ||
+ | Password: fenestros | ||
+ | Last login: Tue Oct 20 07:35:01 CEST 2015 on pts/0 | ||
+ | [root@centos7 ~]# cd / | ||
+ | [root@centos7 trainee]# chown root tux.jpg | ||
+ | [root@centos7 trainee]# ls -l | grep tux.jpg | ||
+ | -rw-r--r--. 1 root trainee | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 trainee]# chown --help | ||
+ | Usage: chown [OPTION]... [OWNER][: | ||
+ | or: chown [OPTION]... --reference=RFILE FILE... | ||
+ | Change the owner and/or group of each FILE to OWNER and/or GROUP. | ||
+ | With --reference, | ||
+ | |||
+ | -c, --changes | ||
+ | -f, --silent, --quiet | ||
+ | -v, --verbose | ||
+ | --dereference | ||
+ | the default), rather than the symbolic link itself | ||
+ | -h, --no-dereference | ||
+ | | ||
+ | | ||
+ | --from=CURRENT_OWNER: | ||
+ | | ||
+ | its current owner and/or group match those specified | ||
+ | | ||
+ | is not required for the omitted attribute | ||
+ | --no-preserve-root | ||
+ | --preserve-root | ||
+ | --reference=RFILE | ||
+ | | ||
+ | -R, --recursive | ||
+ | |||
+ | The following options modify how a hierarchy is traversed when the -R | ||
+ | option is also specified. | ||
+ | one takes effect. | ||
+ | |||
+ | -H if a command line argument is a symbolic link | ||
+ | to a directory, traverse it | ||
+ | -L | ||
+ | | ||
+ | -P do not traverse any symbolic links (default) | ||
+ | |||
+ | --help | ||
+ | --version | ||
+ | |||
+ | Owner is unchanged if missing. | ||
+ | to login group if implied by a ':' | ||
+ | OWNER and GROUP may be numeric as well as symbolic. | ||
+ | |||
+ | Examples: | ||
+ | chown root /u Change the owner of /u to " | ||
+ | chown root:staff /u Likewise, but also change its group to " | ||
+ | chown -hR root /u Change the owner of /u and subfiles to " | ||
+ | |||
+ | GNU coreutils online help: < | ||
+ | For complete documentation, | ||
+ | </ | ||
+ | |||
+ | ==La Commande chgrp== | ||
+ | |||
+ | Le même cas de figure s’applique au groupe : | ||
+ | |||
+ | # chgrp root tux.jpg [Entrée] | ||
+ | |||
+ | affectera le fichier au groupe root : | ||
+ | |||
+ | < | ||
+ | [root@centos7 trainee]# chgrp root tux.jpg | ||
+ | [root@centos7 trainee]# ls -l | grep tux.jpg | ||
+ | -rw-r--r--. 1 root root 0 Oct 20 07:21 tux.jpg | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Rappel** : Seul root peut changer le propriétaire d'un fichier. | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Le droit de supprimer un fichier dépend des droits sur le répertoire dans lequel le fichier est stocké et non des droits du fichier lui-même. | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 trainee]# chgrp --help | ||
+ | Usage: chgrp [OPTION]... GROUP FILE... | ||
+ | or: chgrp [OPTION]... --reference=RFILE FILE... | ||
+ | Change the group of each FILE to GROUP. | ||
+ | With --reference, | ||
+ | |||
+ | -c, --changes | ||
+ | -f, --silent, --quiet | ||
+ | -v, --verbose | ||
+ | --dereference | ||
+ | the default), rather than the symbolic link itself | ||
+ | -h, --no-dereference | ||
+ | | ||
+ | | ||
+ | --no-preserve-root | ||
+ | --preserve-root | ||
+ | --reference=RFILE | ||
+ | GROUP value | ||
+ | -R, --recursive | ||
+ | |||
+ | The following options modify how a hierarchy is traversed when the -R | ||
+ | option is also specified. | ||
+ | one takes effect. | ||
+ | |||
+ | -H if a command line argument is a symbolic link | ||
+ | to a directory, traverse it | ||
+ | -L | ||
+ | | ||
+ | -P do not traverse any symbolic links (default) | ||
+ | |||
+ | --help | ||
+ | --version | ||
+ | |||
+ | Examples: | ||
+ | chgrp staff /u Change the group of /u to " | ||
+ | chgrp -hR staff /u Change the group of /u and subfiles to " | ||
+ | |||
+ | GNU coreutils online help: < | ||
+ | For complete documentation, | ||
+ | </ | ||
+ | |||
+ | ====Les Droits Unix Etendus==== | ||
+ | |||
+ | ===SUID/ | ||
+ | |||
+ | Malgré ce que vous venez de voir, dans la première des deux fenêtres ci-dessous, vous noterez que le fichier **passwd** se trouvant dans le répertoire **/etc** possède les permissions **rw- r-- r--** et qu'il appartient à **root**. Autrement dit **seul** root peut écrire dans ce fichier. Or, quand un utilisateur normal change son mot de passe, il écrit dans ce fichier. Ceci semble donc être une contradiction. | ||
+ | |||
+ | < | ||
+ | [root@centos7 trainee]# ls -l /etc/passwd / | ||
+ | -rw-r--r--. 1 root root 2062 Oct 19 15:38 /etc/passwd | ||
+ | -rwsr-xr-x. 1 root root 27832 Jun 10 2014 / | ||
+ | </ | ||
+ | |||
+ | Pour remédier à cette apparente contradiction, | ||
+ | |||
+ | * Set %%UserID%% bit ( SUID bit ) | ||
+ | * Set %%GroupID%% bit ( SGID bit ) | ||
+ | |||
+ | Quand le SUID bit est placé sur un programme, l’utilisateur qui lance ce programme se voit affecté le numéro d’utilisateur du propriétaire de ce programme et ce pour la durée de son exécution. | ||
+ | |||
+ | Dans le cas du changement de mot de passe, chaque utilisateur qui lance le programme / | ||
+ | |||
+ | La même fonction existe pour le groupe à l’aide du SGID bit. | ||
+ | |||
+ | Pour assigner les droits, vous utiliserez la commande chmod : | ||
+ | |||
+ | * chmod u+s nom_du_fichier | ||
+ | * chmod g+s nom_du_fichier | ||
+ | |||
+ | En base huit les valeurs sont les suivants : | ||
+ | |||
+ | * SUID = 4000 | ||
+ | * SGID = 2000 | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Afin d' | ||
+ | |||
+ | # find / -type f \( -perm -4000 -o -perm -2000 \) -exec ls {} \; [Entrée] | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===Inheritance Flag=== | ||
+ | |||
+ | Le SGID bit peut également être affecté à un répertoire. De cette façon, les fichiers et répertoires créés à l' | ||
+ | |||
+ | Par exemple : | ||
+ | |||
+ | < | ||
+ | [root@centos7 trainee]# cd /tmp | ||
+ | [root@centos7 tmp]# mkdir inherit | ||
+ | [root@centos7 tmp]# chown root: | ||
+ | [root@centos7 tmp]# chmod g+s inherit | ||
+ | [root@centos7 tmp]# touch inherit/ | ||
+ | [root@centos7 tmp]# mkdir inherit/ | ||
+ | [root@centos7 tmp]# cd inherit; ls -l | ||
+ | total 0 | ||
+ | drwxr-sr-x. 2 root trainee 6 Oct 20 07:58 testrep | ||
+ | -rw-r--r--. 1 root trainee 0 Oct 20 07:58 test.txt | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Notez que malgré le fait que root a créé les deux objets, ceux-ci ne sont pas associés avec le groupe **root** mais avec le groupe **trainee**, | ||
+ | </ | ||
+ | |||
+ | ===Sticky bit=== | ||
+ | |||
+ | Il existe un dernier cas qui s’appelle le sticky bit. Le sticky bit est utilisé pour des répertoires ou tout le monde a tous les droits. Dans ce cas, tout le monde peut supprimer des fichiers dans le répertoire. En ajoutant le sticky bit, uniquement le propriétaire du fichier peut le supprimer. | ||
+ | |||
+ | # chmod o+t / | ||
+ | |||
+ | ou | ||
+ | |||
+ | # chmod 1777 / | ||
+ | |||
+ | Par exemple la ligne de commande: | ||
+ | |||
+ | # mkdir / | ||
+ | |||
+ | ou | ||
+ | |||
+ | # mkdir / | ||
+ | |||
+ | créera un répertoire **repertoire_public** dans /tmp avec les droits suivants : | ||
+ | |||
+ | < | ||
+ | [root@centos7 inherit]# mkdir / | ||
+ | [root@centos7 tmp]# ls -l | grep repertoire_public | ||
+ | drwxr-xr-t. 2 root root 6 Oct 20 07:59 repertoire_public | ||
+ | </ | ||
+ | |||
+ | ====Les Droits Unix Avancés==== | ||
+ | |||
+ | ===Les ACL=== | ||
+ | |||
+ | Au delà des droits étendus d' | ||
+ | |||
+ | Pour connaître les ACL positionnés sur un fichier, il convient d' | ||
+ | |||
+ | # getfacl / | ||
+ | |||
+ | En utilisant cette commande, vous obtiendrez un résultat similaire à celui-ci : | ||
+ | |||
+ | < | ||
+ | [root@centos7 tmp]# getfacl / | ||
+ | getfacl: Removing leading '/' | ||
+ | # file: home/ | ||
+ | # owner: root | ||
+ | # group: root | ||
+ | user::rw- | ||
+ | group::r-- | ||
+ | other::r-- | ||
+ | |||
+ | </ | ||
+ | |||
+ | Pour positionner des ACL sur un fichier, il convient d' | ||
+ | |||
+ | # setfacl --set u:: | ||
+ | |||
+ | Utilisez la commande **getfacl** pour visualiser le résultat : | ||
+ | |||
+ | # getfacl / | ||
+ | |||
+ | Vous obtiendrez un résultat similaire à celui-ci : | ||
+ | |||
+ | < | ||
+ | [root@centos7 tmp]# setfacl --set u:: | ||
+ | [root@centos7 tmp]# getfacl / | ||
+ | getfacl: Removing leading '/' | ||
+ | # file: home/ | ||
+ | # owner: root | ||
+ | # group: root | ||
+ | user::rwx | ||
+ | user: | ||
+ | group::r-x | ||
+ | mask::rwx | ||
+ | other::--- | ||
+ | |||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** - Veuillez noter l' | ||
+ | </ | ||
+ | |||
+ | Regardez maintenant l' | ||
+ | |||
+ | # mkdir / | ||
+ | |||
+ | Positionnez des ACL le répertoire avec la commande **setfacl** : | ||
+ | |||
+ | # setfacl --set d: | ||
+ | |||
+ | Notez l' | ||
+ | |||
+ | Créez maintenant un fichier appelé fichier1 dans / | ||
+ | |||
+ | # touch / | ||
+ | |||
+ | Utilisez la commande **getfacl** pour visualiser le résultat : | ||
+ | |||
+ | # getfacl / | ||
+ | |||
+ | # getfacl home/ | ||
+ | |||
+ | Vous obtiendrez un résultat similaire à celui-ci : | ||
+ | |||
+ | < | ||
+ | [root@centos7 tmp]# mkdir / | ||
+ | [root@centos7 tmp]# setfacl --set d: | ||
+ | [root@centos7 tmp]# touch / | ||
+ | [root@centos7 tmp]# getfacl / | ||
+ | getfacl: Removing leading '/' | ||
+ | # file: home/ | ||
+ | # owner: root | ||
+ | # group: root | ||
+ | user::rwx | ||
+ | group::r-x | ||
+ | other::r-x | ||
+ | default: | ||
+ | default: | ||
+ | default: | ||
+ | |||
+ | [root@centos7 tmp]# getfacl / | ||
+ | getfacl: Removing leading '/' | ||
+ | # file: home/ | ||
+ | # owner: root | ||
+ | # group: root | ||
+ | user::r-- | ||
+ | group::--- | ||
+ | other::--- | ||
+ | |||
+ | </ | ||
+ | |||
+ | Notez que le fichier créé possède les ACL positionnés sur le répertoire rep1. | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | # getfacl -R --skip-base . > backup.acl [Entrée] | ||
+ | |||
+ | La restauration des ACL se fait avec la commande **setfacl** : | ||
+ | |||
+ | # setfacl --restore=backup.acl [Entrée] | ||
+ | |||
+ | Les options de la commande **getfacl** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 tmp]# getfacl --help | ||
+ | getfacl 2.2.51 -- get file access control lists | ||
+ | Usage: getfacl [-aceEsRLPtpndvh] file ... | ||
+ | -a, --access | ||
+ | -d, --default | ||
+ | -c, --omit-header | ||
+ | -e, --all-effective | ||
+ | -E, --no-effective | ||
+ | -s, --skip-base | ||
+ | -R, --recursive | ||
+ | -L, --logical | ||
+ | -P, --physical | ||
+ | -t, --tabular | ||
+ | -n, --numeric | ||
+ | -p, --absolute-names | ||
+ | -v, --version | ||
+ | -h, --help | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **setfacl** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 tmp]# setfacl --help | ||
+ | setfacl 2.2.51 -- set file access control lists | ||
+ | Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ... | ||
+ | -m, --modify=acl | ||
+ | -M, --modify-file=file | ||
+ | -x, --remove=acl | ||
+ | -X, --remove-file=file | ||
+ | -b, --remove-all | ||
+ | -k, --remove-default | ||
+ | --set=acl | ||
+ | --set-file=file | ||
+ | --mask | ||
+ | -n, --no-mask | ||
+ | -d, --default | ||
+ | -R, --recursive | ||
+ | -L, --logical | ||
+ | -P, --physical | ||
+ | --restore=file | ||
+ | --test | ||
+ | -v, --version | ||
+ | -h, --help | ||
+ | </ | ||
+ | |||
+ | ===Les Attributs Etendus=== | ||
+ | |||
+ | Les attributs s' | ||
+ | |||
+ | Les principaux attributs sont : | ||
+ | |||
+ | ^ Attribut ^ Description ^ | ||
+ | | a | Fichier journal - uniquement l' | ||
+ | | i | Le fichier ne peut ni être modifié, ni être détruit, ni être déplacé. Le placement d'un lien sur le fichier n'est pas permis | | ||
+ | | s | Le fichier sera physiquement détruit lors de sa suppression | | ||
+ | | D | Répertoire synchrone | | ||
+ | | S | Fichier synchrone | | ||
+ | | A | La date et l' | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** - Un fichier synchrone et un répertoire synchrone impliquent que les modifications seront immédiatement inscrites sur disque. | ||
+ | </ | ||
+ | |||
+ | Les commandes associées avec les attributs sont : | ||
+ | |||
+ | ^ Commande ^ description ^ | ||
+ | | chattr | Modifie les attributs | | ||
+ | | lsattr | Visualise les attributs | | ||
+ | |||
+ | Pour mieux comprendre, créez le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 tmp]# cd /root | ||
+ | [root@centos7 ~]# mkdir -p attributs/ | ||
+ | </ | ||
+ | |||
+ | Créez ensuite les fichier **fichier** et **rep/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# touch attributs/ | ||
+ | [root@centos7 ~]# touch attributs/ | ||
+ | </ | ||
+ | |||
+ | Modifiez les attributs d'une manière récursive sur le répertoire **attributs** : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# chattr +i -R attributs/ | ||
+ | </ | ||
+ | |||
+ | Visualisez les attributs de l' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# lsattr -R attributs | ||
+ | ----i----------- attributs/ | ||
+ | |||
+ | attributs/ | ||
+ | ----i----------- attributs/ | ||
+ | |||
+ | ----i----------- attributs/ | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** - Notez que l' | ||
+ | </ | ||
+ | |||
+ | Essayez maintenant de déplacer le fichier **fichier**. Vous obtiendrez un résultat similaire à celui-ci : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# cd attributs; mv / | ||
+ | mv: cannot move ‘/ | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **chattr** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# chattr --help | ||
+ | Usage: chattr [-RVf] [-+=aAcCdDeijsStTu] [-v version] files... | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **lsattr** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# lsattr --help | ||
+ | lsattr: invalid option -- ' | ||
+ | Usage: lsattr [-RVadlv] [files...] | ||
+ | </ | ||
+ | |||
+ | =====Rôle du noyau===== | ||
+ | |||
+ | Le noyau ou //kernel// est la partie du système d' | ||
+ | |||
+ | * la diminution de la taille du noyau, | ||
+ | * la prise en charge de nouveau matériel, | ||
+ | * l' | ||
+ | * l' | ||
+ | * la correction de bogues, | ||
+ | * le besoin d'une fonctionnalité expérimentale. | ||
+ | |||
+ | Commencez par identifier le noyau utilisé par votre machine : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# uname -r | ||
+ | 3.10.0-327.13.1.el7.x86_64 | ||
+ | </ | ||
+ | |||
+ | Dans le cas d'une utilisation courante de Linux, il est cependant préférable de faire appel aux **modules**. Les modules se trouvent dans le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# ls / | ||
+ | build | ||
+ | extra | ||
+ | kernel | ||
+ | </ | ||
+ | |||
+ | Les commandes pour manipuler les modules sont : | ||
+ | |||
+ | * insmod | ||
+ | * rmmod | ||
+ | * lsmod | ||
+ | * modprobe | ||
+ | |||
+ | Par exemple : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# lsmod | ||
+ | Module | ||
+ | ip6t_rpfilter | ||
+ | ip6t_REJECT | ||
+ | ipt_REJECT | ||
+ | xt_conntrack | ||
+ | ebtable_nat | ||
+ | ebtable_broute | ||
+ | bridge | ||
+ | stp 12976 1 bridge | ||
+ | llc 14552 2 stp,bridge | ||
+ | ebtable_filter | ||
+ | ebtables | ||
+ | ip6table_nat | ||
+ | nf_conntrack_ipv6 | ||
+ | nf_defrag_ipv6 | ||
+ | nf_nat_ipv6 | ||
+ | ip6table_mangle | ||
+ | ip6table_security | ||
+ | ip6table_raw | ||
+ | ip6table_filter | ||
+ | ip6_tables | ||
+ | iptable_nat | ||
+ | nf_conntrack_ipv4 | ||
+ | nf_defrag_ipv4 | ||
+ | nf_nat_ipv4 | ||
+ | nf_nat | ||
+ | nf_conntrack | ||
+ | iptable_mangle | ||
+ | iptable_security | ||
+ | iptable_raw | ||
+ | iptable_filter | ||
+ | dm_mirror | ||
+ | dm_region_hash | ||
+ | dm_log | ||
+ | dm_mod | ||
+ | crc32_pclmul | ||
+ | ghash_clmulni_intel | ||
+ | aesni_intel | ||
+ | lrw 13286 1 aesni_intel | ||
+ | gf128mul | ||
+ | glue_helper | ||
+ | snd_intel8x0 | ||
+ | ablk_helper | ||
+ | cryptd | ||
+ | snd_ac97_codec | ||
+ | ac97_bus | ||
+ | ppdev 17671 0 | ||
+ | snd_seq | ||
+ | snd_seq_device | ||
+ | snd_pcm | ||
+ | pcspkr | ||
+ | sg | ||
+ | parport_pc | ||
+ | parport | ||
+ | snd_timer | ||
+ | snd 83425 8 snd_ac97_codec, | ||
+ | soundcore | ||
+ | i2c_piix4 | ||
+ | video 24400 0 | ||
+ | i2c_core | ||
+ | nfsd 302418 | ||
+ | auth_rpcgss | ||
+ | nfs_acl | ||
+ | lockd 93600 1 nfsd | ||
+ | grace 13295 2 nfsd,lockd | ||
+ | sunrpc | ||
+ | ip_tables | ||
+ | xfs | ||
+ | libcrc32c | ||
+ | sd_mod | ||
+ | crc_t10dif | ||
+ | crct10dif_generic | ||
+ | sr_mod | ||
+ | cdrom 42556 1 sr_mod | ||
+ | ata_generic | ||
+ | pata_acpi | ||
+ | ahci | ||
+ | libahci | ||
+ | ata_piix | ||
+ | crct10dif_pclmul | ||
+ | crct10dif_common | ||
+ | crc32c_intel | ||
+ | serio_raw | ||
+ | libata | ||
+ | e1000 | ||
+ | </ | ||
+ | |||
+ | Pour ajouter un module, on peut utiliser la commande **insmod** ou **modprobe**. Cette dernière ajoute non seulement le module passé en argument mais également ses dépendances : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# modprobe bonding | ||
+ | [root@centos7 ~]# lsmod | more | ||
+ | Module | ||
+ | bonding | ||
+ | ip6t_rpfilter | ||
+ | ip6t_REJECT | ||
+ | ipt_REJECT | ||
+ | xt_conntrack | ||
+ | ebtable_nat | ||
+ | ebtable_broute | ||
+ | bridge | ||
+ | stp 12976 1 bridge | ||
+ | llc 14552 2 stp,bridge | ||
+ | ebtable_filter | ||
+ | ebtables | ||
+ | ip6table_nat | ||
+ | nf_conntrack_ipv6 | ||
+ | nf_defrag_ipv6 | ||
+ | nf_nat_ipv6 | ||
+ | ip6table_mangle | ||
+ | ip6table_security | ||
+ | ip6table_raw | ||
+ | ip6table_filter | ||
+ | ip6_tables | ||
+ | y, | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | Pour supprimer un module, on peut utiliser la commande **rmmod** ou **modprobe -r**. Cette dernière essaie de supprimer les dépendances non-utilisées : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# modprobe -r bonding | ||
+ | [root@centos7 ~]# lsmod | more | ||
+ | Module | ||
+ | ip6t_rpfilter | ||
+ | ip6t_REJECT | ||
+ | ipt_REJECT | ||
+ | xt_conntrack | ||
+ | ebtable_nat | ||
+ | ebtable_broute | ||
+ | bridge | ||
+ | stp 12976 1 bridge | ||
+ | llc 14552 2 stp,bridge | ||
+ | ebtable_filter | ||
+ | ebtables | ||
+ | ip6table_nat | ||
+ | nf_conntrack_ipv6 | ||
+ | nf_defrag_ipv6 | ||
+ | nf_nat_ipv6 | ||
+ | ip6table_mangle | ||
+ | ip6table_security | ||
+ | ip6table_raw | ||
+ | ip6table_filter | ||
+ | ip6_tables | ||
+ | y, | ||
+ | iptable_nat | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | Les dépendances des modules sont résolues par la commande **modprobe** grâce aux fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# more / | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | to/lrw.ko kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | el/ | ||
+ | kernel/ | ||
+ | helper.ko kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | f128mul.ko kernel/ | ||
+ | kernel/ | ||
+ | --More--(0%) | ||
+ | </ | ||
+ | |||
+ | Il est possible d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# modinfo bonding | ||
+ | filename: | ||
+ | author: | ||
+ | description: | ||
+ | version: | ||
+ | license: | ||
+ | alias: | ||
+ | rhelversion: | ||
+ | srcversion: | ||
+ | depends: | ||
+ | intree: | ||
+ | vermagic: | ||
+ | signer: | ||
+ | sig_key: | ||
+ | sig_hashalgo: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | </ | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# ls / | ||
+ | mlx4.conf | ||
+ | |||
+ | [root@centos7 ~]# cat / | ||
+ | # This file is intended for users to select the various module options | ||
+ | # they need for the mlx4 driver. | ||
+ | # any user made changes to this file are preserved. | ||
+ | # to the libmlx4.conf file in this directory are overwritten on | ||
+ | # pacakge upgrade. | ||
+ | # | ||
+ | # Some sample options and what they would do | ||
+ | # Enable debugging output, device managed flow control, and disable SRIOV | ||
+ | #options mlx4_core debug_level=1 log_num_mgm_entry_size=-1 probe_vf=0 num_vfs=0 | ||
+ | # | ||
+ | # Enable debugging output and create SRIOV devices, but don't attach any of | ||
+ | # the child devices to the host, only the parent device | ||
+ | #options mlx4_core debug_level=1 probe_vf=0 num_vfs=7 | ||
+ | # | ||
+ | # Enable debugging output, SRIOV, and attach one of the SRIOV child devices | ||
+ | # in addition to the parent device to the host | ||
+ | #options mlx4_core debug_level=1 probe_vf=1 num_vfs=7 | ||
+ | # | ||
+ | # Enable per priority flow control for send and receive, setting both priority | ||
+ | # 1 and 2 as no drop priorities | ||
+ | #options mlx4_en pfctx=3 pfcrx=3 | ||
+ | </ | ||
+ | |||
+ | =====Gestion des Quotas===== | ||
+ | |||
+ | Sous Linux il est possible de mettre en place des quotas par utilisateur et par groupe. Ceci étant, Linux ne sait pas gérer des quotas par répertoire, | ||
+ | quotas par partition. L' | ||
+ | |||
+ | Déconnectez-vous et reconnectez-vous en tant que root. | ||
+ | |||
+ | Avant de mettre en place des quotas, configurer SELINUX en mode **permissive** afin de ne pas avoir d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# getenforce | ||
+ | Enforcing | ||
+ | [root@centos7 ~]# setenforce permissive | ||
+ | [root@centos7 ~]# getenforce | ||
+ | Permissive | ||
+ | </ | ||
+ | |||
+ | Editez ensuite le fichier / | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# vi / | ||
+ | [root@centos7 ~]# cat / | ||
+ | |||
+ | # This file controls the state of SELinux on the system. | ||
+ | # SELINUX= can take one of these three values: | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | SELINUX=permissive | ||
+ | # SELINUXTYPE= can take one of three two values: | ||
+ | # | ||
+ | # | ||
+ | # mls - Multi Level Security protection. | ||
+ | SELINUXTYPE=targeted | ||
+ | </ | ||
+ | |||
+ | ====Déplacer /home==== | ||
+ | |||
+ | Créez une seule partition sur **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# fdisk /dev/sdb | ||
+ | Welcome to fdisk (util-linux 2.23.2). | ||
+ | |||
+ | Changes will remain in memory only, until you decide to write them. | ||
+ | Be careful before using the write command. | ||
+ | |||
+ | Device does not contain a recognized partition table | ||
+ | Building a new DOS disklabel with disk identifier 0x88708329. | ||
+ | |||
+ | Command (m for help): n | ||
+ | Partition type: | ||
+ | | ||
+ | | ||
+ | Select (default p): p | ||
+ | Partition number (1-4, default 1): | ||
+ | First sector (2048-41943039, | ||
+ | Using default value 2048 | ||
+ | Last sector, +sectors or +size{K, | ||
+ | Using default value 41943039 | ||
+ | Partition 1 of type Linux and of size 20 GiB is set | ||
+ | |||
+ | Command (m for help): w | ||
+ | The partition table has been altered! | ||
+ | |||
+ | Calling ioctl() to re-read partition table. | ||
+ | Syncing disks. | ||
+ | </ | ||
+ | |||
+ | Créez maintenant un système de fichiers ext4 sur **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mkfs.ext4 /dev/sdb1 | ||
+ | mke2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem label= | ||
+ | OS type: Linux | ||
+ | Block size=4096 (log=2) | ||
+ | Fragment size=4096 (log=2) | ||
+ | Stride=0 blocks, Stripe width=0 blocks | ||
+ | 1310720 inodes, 5242624 blocks | ||
+ | 262131 blocks (5.00%) reserved for the super user | ||
+ | First data block=0 | ||
+ | Maximum filesystem blocks=2153775104 | ||
+ | 160 block groups | ||
+ | 32768 blocks per group, 32768 fragments per group | ||
+ | 8192 inodes per group | ||
+ | Superblock backups stored on blocks: | ||
+ | 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, | ||
+ | 4096000 | ||
+ | |||
+ | Allocating group tables: done | ||
+ | Writing inode tables: done | ||
+ | Creating journal (32768 blocks): done | ||
+ | Writing superblocks and filesystem accounting information: | ||
+ | </ | ||
+ | |||
+ | Montez **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mount /dev/sdb1 /mnt | ||
+ | </ | ||
+ | |||
+ | Copiez le contenu de /home vers /mnt : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# cp -a /home/* /mnt | ||
+ | </ | ||
+ | |||
+ | Démontez /dev/sdb1 et déplacez /home vers /root : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# umount /mnt | ||
+ | [root@centos7 ~]# mv /home /root | ||
+ | </ | ||
+ | |||
+ | Identifiez l'UUID de /dev/sdb1 : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 10 9 août 06:47 a5e2457f-7337-41f4-b958-e403eb419f94 -> ../../sdb1 | ||
+ | </ | ||
+ | |||
+ | Editez le fichier **/ | ||
+ | |||
+ | <file txt / | ||
+ | # | ||
+ | # /etc/fstab | ||
+ | # Created by anaconda on Sat Apr 30 11:27:02 2016 | ||
+ | # | ||
+ | # Accessible filesystems, | ||
+ | # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info | ||
+ | # | ||
+ | UUID=e65fe7da-cda8-4f5a-a827-1b5cabe94bed / | ||
+ | UUID=2d947276-66e8-41f4-8475-b64b67d7a249 /boot | ||
+ | UUID=3181601a-7295-4ef0-a92c-f21f76b18e64 swap swap defaults | ||
+ | UUID=a5e2457f-7337-41f4-b958-e403eb419f94 / | ||
+ | |||
+ | </ | ||
+ | |||
+ | Créez le point de montage /home : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mkdir /home | ||
+ | </ | ||
+ | |||
+ | Montez /dev/sdb1 : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mount -a | ||
+ | [root@centos7 ~]# mount | ||
+ | sysfs on /sys type sysfs (rw, | ||
+ | proc on /proc type proc (rw, | ||
+ | devtmpfs on /dev type devtmpfs (rw, | ||
+ | securityfs on / | ||
+ | tmpfs on /dev/shm type tmpfs (rw, | ||
+ | devpts on /dev/pts type devpts (rw, | ||
+ | tmpfs on /run type tmpfs (rw, | ||
+ | tmpfs on / | ||
+ | cgroup on / | ||
+ | pstore on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | configfs on / | ||
+ | /dev/sda2 on / type xfs (rw, | ||
+ | selinuxfs on / | ||
+ | systemd-1 on / | ||
+ | debugfs on / | ||
+ | hugetlbfs on / | ||
+ | mqueue on /dev/mqueue type mqueue (rw, | ||
+ | tmpfs on /tmp type tmpfs (rw, | ||
+ | sunrpc on / | ||
+ | nfsd on / | ||
+ | /dev/sda1 on /boot type xfs (rw, | ||
+ | /dev/sdb1 on /home type ext4 (rw, | ||
+ | tmpfs on / | ||
+ | </ | ||
+ | |||
+ | Notez la taille de /home : | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ df -h | ||
+ | Sys. de fichiers Taille Utilisé Dispo Uti% Monté sur | ||
+ | / | ||
+ | devtmpfs | ||
+ | tmpfs 245M | ||
+ | tmpfs 245M 4,7M 240M 2% /run | ||
+ | tmpfs 245M | ||
+ | tmpfs 245M | ||
+ | / | ||
+ | / | ||
+ | tmpfs | ||
+ | </ | ||
+ | |||
+ | <WRAP center round todo> | ||
+ | Fermez la session de root et connectez-vous en tant que trainee. | ||
+ | </ | ||
+ | |||
+ | ====Mettre en Place des Quotas==== | ||
+ | |||
+ | Commencez par vérifiez que le paquet **quota** est bien installé : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# rpm -qa | grep quota | ||
+ | quota-4.01-11.el7_2.1.x86_64 | ||
+ | quota-nls-4.01-11.el7_2.1.noarch | ||
+ | </ | ||
+ | |||
+ | Editez le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# vi /etc/fstab | ||
+ | [root@centos7 ~]# cat /etc/fstab | ||
+ | |||
+ | # | ||
+ | # /etc/fstab | ||
+ | # Created by anaconda on Sat Apr 30 11:27:02 2016 | ||
+ | # | ||
+ | # Accessible filesystems, | ||
+ | # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info | ||
+ | # | ||
+ | UUID=e65fe7da-cda8-4f5a-a827-1b5cabe94bed / | ||
+ | UUID=2d947276-66e8-41f4-8475-b64b67d7a249 /boot | ||
+ | UUID=3181601a-7295-4ef0-a92c-f21f76b18e64 swap swap defaults | ||
+ | UUID=a080ac6a-d15c-48e2-8461-a7b1aa3ebf1a / | ||
+ | </ | ||
+ | |||
+ | Démontez puis remontez /home : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# umount /home | ||
+ | [root@centos7 ~]# mount -a | ||
+ | </ | ||
+ | |||
+ | Déconnectez-vous et reconnectez-vous en tant que trainee. Vérifiez ensuite que les options soient prises en compte : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# cat /etc/mtab | ||
+ | rootfs / rootfs rw 0 0 | ||
+ | sysfs /sys sysfs rw, | ||
+ | proc /proc proc rw, | ||
+ | devtmpfs /dev devtmpfs rw, | ||
+ | securityfs / | ||
+ | tmpfs /dev/shm tmpfs rw, | ||
+ | devpts /dev/pts devpts rw, | ||
+ | tmpfs /run tmpfs rw, | ||
+ | tmpfs / | ||
+ | cgroup / | ||
+ | pstore / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | configfs / | ||
+ | /dev/sda2 / xfs rw, | ||
+ | selinuxfs / | ||
+ | systemd-1 / | ||
+ | debugfs / | ||
+ | hugetlbfs / | ||
+ | tmpfs /tmp tmpfs rw,seclabel 0 0 | ||
+ | mqueue /dev/mqueue mqueue rw, | ||
+ | sunrpc / | ||
+ | nfsd / | ||
+ | /dev/sda1 /boot xfs rw, | ||
+ | tmpfs /run/user/0 tmpfs rw, | ||
+ | /dev/sdb1 /home ext4 rw, | ||
+ | </ | ||
+ | |||
+ | ====La Commande quotacheck==== | ||
+ | |||
+ | Pour activer les quotas sur /home, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# quotacheck -cugvm -f /dev/sdb1 | ||
+ | quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown. | ||
+ | quotacheck: Parcours de /dev/sdb1 [/home] terminé | ||
+ | quotacheck: Cannot stat old user quota file / | ||
+ | quotacheck: Cannot stat old group quota file / | ||
+ | quotacheck: Cannot stat old user quota file / | ||
+ | quotacheck: Cannot stat old group quota file / | ||
+ | quotacheck: Vérifié 100 répertoires et 230 fichiers | ||
+ | quotacheck: Ancien fichier non trouvé. | ||
+ | quotacheck: Ancien fichier non trouvé. | ||
+ | </ | ||
+ | |||
+ | Les options de la commande quotacheck sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# quotacheck --help | ||
+ | Utility for checking and repairing quota files. | ||
+ | quotacheck [-gucbfinvdmMR] [-F < | ||
+ | |||
+ | -u, --user | ||
+ | -g, --group | ||
+ | -c, --create-files | ||
+ | -b, --backup | ||
+ | -f, --force | ||
+ | -i, --interactive | ||
+ | -n, --use-first-dquot | ||
+ | -v, --verbose | ||
+ | -d, --debug | ||
+ | -m, --no-remount | ||
+ | -M, --try-remount | ||
+ | continue even if it fails | ||
+ | -R, --exclude-root | ||
+ | -F, --format=formatname | ||
+ | -a, --all check all filesystems | ||
+ | -h, --help | ||
+ | -V, --version | ||
+ | |||
+ | Rapports de bugs à jack@suse.cz | ||
+ | </ | ||
+ | |||
+ | Les quotas ont été activés et les fichier **aquota.user** et **aquota.group** ont été créés dans le répertoire /home : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# ls -la /home | ||
+ | total 44 | ||
+ | drwxr-xr-x. | ||
+ | dr-xr-xr-x. 18 root root 4096 11 août 13:27 .. | ||
+ | -rw-------. | ||
+ | -rw-------. | ||
+ | drwx------. | ||
+ | drwx------. 14 trainee trainee | ||
+ | </ | ||
+ | |||
+ | Créez maintenant un utilisateur **fenestros** avec le mot de passe **fenestros** : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# groupadd fenestros && useradd fenestros -c FenestrOs -d / | ||
+ | [root@centos7 ~]# passwd fenestros | ||
+ | Changement de mot de passe pour l' | ||
+ | Nouveau mot de passe : fenestros | ||
+ | MOT DE PASSE INCORRECT : Le mot de passe contient le nom d' | ||
+ | Retapez le nouveau mot de passe : fenestros | ||
+ | passwd : mise à jour réussie de tous les jetons d' | ||
+ | [root@centos7 ~]# | ||
+ | </ | ||
+ | |||
+ | ====La Commande edquota==== | ||
+ | |||
+ | Mettez en place maintenant un quota de 10Mo pour l' | ||
+ | |||
+ | < | ||
+ | [root@centos ~]# edquota -u fenestros -f /home | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | Quotas disque pour user fenestros (uid 1001) : | ||
+ | | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Modifiez ce fichier ainsi : | ||
+ | |||
+ | < | ||
+ | Quotas disque pour user fenestros (uid 1001) : | ||
+ | | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **edquota** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# edquota --help | ||
+ | edquota: Usage: | ||
+ | edquota [-rm] [-u] [-F formatname] [-p username] [-f filesystem] username ... | ||
+ | edquota [-rm] -g [-F formatname] [-p groupname] [-f filesystem] groupname ... | ||
+ | edquota [-u|g] [-F formatname] [-f filesystem] -t | ||
+ | edquota [-u|g] [-F formatname] [-f filesystem] -T username|groupname ... | ||
+ | |||
+ | -u, --user | ||
+ | -g, --group | ||
+ | -r, --remote | ||
+ | -m, --no-mixed-pathnames | ||
+ | -F, --format=formatname | ||
+ | -p, --prototype=name | ||
+ | --always-resolve | ||
+ | composed only of digits | ||
+ | -f, --filesystem=filesystem | ||
+ | -t, --edit-period | ||
+ | -T, --edit-times | ||
+ | -h, --help | ||
+ | -V, --version | ||
+ | |||
+ | Rapports de bugs à : jack@suse.cz | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | Pour mettre en place un quota par group, la procédure est similaire. Il suffit d' | ||
+ | </ | ||
+ | |||
+ | ====La Commande quotaon==== | ||
+ | |||
+ | Appliquez maintenant les quotas : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# quotaon -a | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **quotaon** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# quotaon --help | ||
+ | quotaon: Usage: | ||
+ | quotaon [-guvp] [-F quotaformat] [-x state] -a | ||
+ | quotaon [-guvp] [-F quotaformat] [-x state] filesys ... | ||
+ | |||
+ | -a, --all turn quotas on for all filesystems | ||
+ | -f, --off turn quotas off | ||
+ | -u, --user | ||
+ | -g, --group | ||
+ | -p, --print-state | ||
+ | -x, --xfs-command=cmd | ||
+ | -F, --format=formatname | ||
+ | -v, --verbose | ||
+ | -h, --help | ||
+ | -V, --version | ||
+ | </ | ||
+ | |||
+ | De cette manière vous avez mis en place un quota **souple** pour fenestros de 8 000 Ko et un quota **stricte** de 10 000 Ko. | ||
+ | |||
+ | Quand l' | ||
+ | |||
+ | Il est à noter que vous pouvez soit mettre en place un quota en taille, soit mettre en place un quota basé sur le nombre d' | ||
+ | |||
+ | <WRAP center round important> | ||
+ | La commande pour désactivez les quotas est **quotaoff**. | ||
+ | </ | ||
+ | |||
+ | ====La Commande repquota==== | ||
+ | |||
+ | Pour visualiser les quotas utilisez la commande **repquota** : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# repquota /home | ||
+ | *** Rapport pour les quotas user sur le périphérique /dev/sdb1 | ||
+ | Période de sursis bloc : 7days ; période de sursis inode : 7days | ||
+ | Block limits | ||
+ | Utilisateur | ||
+ | ---------------------------------------------------------------------- | ||
+ | root -- 20 | ||
+ | trainee | ||
+ | |||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | Notez que l' | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **repquota** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# repquota --help | ||
+ | repquota: Utility for reporting quotas. | ||
+ | Usage: | ||
+ | repquota [-vugsi] [-c|C] [-t|n] [-F quotaformat] (-a | mntpoint) | ||
+ | |||
+ | -v, --verbose | ||
+ | -u, --user | ||
+ | -g, --group | ||
+ | -s, --human-readable | ||
+ | -t, --truncate-names | ||
+ | -p, --raw-grace | ||
+ | -n, --no-names | ||
+ | -i, --no-autofs | ||
+ | -c, --cache | ||
+ | -C, --no-cache | ||
+ | -F, --format=formatname | ||
+ | -a, --all | ||
+ | -h, --help | ||
+ | -V, --version | ||
+ | |||
+ | Rapports de bugs à jack@suse.cz | ||
+ | </ | ||
+ | |||
+ | ====La Commande quota==== | ||
+ | |||
+ | Pour visualiser les quotas d'un utilisateur spécifique, | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# quota fenestros | ||
+ | Disk quotas for user fenestros (uid 1001): aucun | ||
+ | [root@centos7 ~]# su - fenestros | ||
+ | [fenestros@centos7 ~]$ touch test | ||
+ | [fenestros@centos7 ~]$ exit | ||
+ | logout | ||
+ | [root@centos7 ~]# quota fenestros | ||
+ | Disk quotas for user fenestros (uid 1001): | ||
+ | Système fichiers | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **quota** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# quota --help | ||
+ | quota: Usage: quota [-guqvswim] [-l | [-Q | -A]] [-F quotaformat] | ||
+ | quota [-qvswim] [-l | [-Q | -A]] [-F quotaformat] -u username ... | ||
+ | quota [-qvswim] [-l | [-Q | -A]] [-F quotaformat] -g groupname ... | ||
+ | quota [-qvswugQm] [-F quotaformat] -f filesystem ... | ||
+ | |||
+ | -u, --user | ||
+ | -g, --group | ||
+ | -q, --quiet | ||
+ | -v, --verbose | ||
+ | -s, --human-readable | ||
+ | --always-resolve | ||
+ | composed of only digits | ||
+ | -w, --no-wrap | ||
+ | -p, --raw-grace | ||
+ | -l, --local-only | ||
+ | -Q, --quiet-refuse | ||
+ | not respond | ||
+ | -i, --no-autofs | ||
+ | -F, --format=formatname | ||
+ | -f, --filesystem-list | ||
+ | -A, --all-nfs | ||
+ | -m, --no-mixed-pathnames | ||
+ | --show-mntpoint | ||
+ | --hide-device | ||
+ | -h, --help | ||
+ | -V, --version | ||
+ | |||
+ | Rapports de bugs à : jack@suse.cz | ||
+ | </ | ||
+ | |||
+ | ====La Commande warnquota==== | ||
+ | |||
+ | La commande **warnquota** vérifie le ou les disques et envoie un message par mail à tout utilisateur qui a dépassé la limite soft. Elle est enrègle générale appelée par un job cron. Cependant elle peut aussi est appelée d'une manière intéractive. | ||
+ | |||
+ | Sous RHEL/CentOS 7, warnquota n'est pas installé par défaut : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# yum install quota-warnquota | ||
+ | Modules complémentaires chargés : fastestmirror, | ||
+ | base | 3.6 kB 00: | ||
+ | extras | ||
+ | updates | ||
+ | Loading mirror speeds from cached hostfile | ||
+ | * base: centos.quelquesmots.fr | ||
+ | * extras: miroir.univ-paris13.fr | ||
+ | * updates: miroir.univ-paris13.fr | ||
+ | Résolution des dépendances | ||
+ | --> Lancement de la transaction de test | ||
+ | ---> Le paquet quota-warnquota.x86_64 1: | ||
+ | --> Résolution des dépendances terminée | ||
+ | |||
+ | Dépendances résolues | ||
+ | |||
+ | ======================================================================================================================================================================== | ||
+ | | ||
+ | ======================================================================================================================================================================== | ||
+ | Installation : | ||
+ | | ||
+ | |||
+ | Résumé de la transaction | ||
+ | ======================================================================================================================================================================== | ||
+ | Installation | ||
+ | |||
+ | Taille totale des téléchargements : 76 k | ||
+ | Taille d' | ||
+ | Is this ok [y/d/N]: y | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **warnquota** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# warnquota --help | ||
+ | warnquota: Usage: | ||
+ | warnquota [-ugsid] [-F quotaformat] [-c configfile] [-q quotatabfile] [-a adminsfile] [filesystem...] | ||
+ | |||
+ | -u, --user | ||
+ | -g, --group | ||
+ | -s, --human-readable | ||
+ | -i, --no-autofs | ||
+ | -d, --no-details | ||
+ | -F, --format=formatname | ||
+ | -c, --config=config-file | ||
+ | -q, --quota-tab=quotatab-file | ||
+ | -a, --admins-file=admins-file | ||
+ | -h, --help | ||
+ | -v, --version | ||
+ | |||
+ | Rapports de bugs à jack@suse.cz | ||
+ | </ | ||
----- | ----- | ||
- | Copyright © 2023 Hugh Norris. | + | Copyright © 2024 Hugh Norris. |