traduction + revision

master
Grégory Lebreton 1 year ago
parent a7dd01ec7e
commit 0b88d42a29

@ -1,216 +1,207 @@
# How to Set Up Software RAID 1 on an Existing Linux Distribution
# Comment mettre en place un RAID 1 logiciel sur une distribution Linux existante
In this tutorial, well be talking about RAID, specifically we will set up software RAID 1 on a running Linux distribution.
What is RAID?
Qu'est-ce que le RAID ?
RAID stands for Redundant Array of Inexpensive Disks. RAID allows you to turn multiple physical hard drives into a single logical hard drive. There are many RAID levels such as RAID 0, RAID 1, RAID 5, RAID 10 etc.
> RAID signifie Redundant Array of Inexpensive Disks (ensemble redondant de disques bon marché). RAID vous permet de transformer plusieurs disques durs physiques en un seul disque dur logique. Il existe de nombreux niveaux de RAID, tels que RAID 0, RAID 1, RAID 5, RAID 10, etc.
Le RAID 1 crée des copies identiques des données. Si vous avez deux disques durs en RAID 1, les données seront écrites sur les deux disques. Les deux disques durs auront les mêmes données.
Here we will discuss about RAID 1 which is also known as disk mirroring. RAID 1 creates identical copies of data. If you have two hard drives in RAID 1, then data will be written to both drives. The two hard drives have the same data.
- Avantage:
L'avantage du RAID 1 est que si l'un de vos disques durs tombe en panne, votre ordinateur ou serveur continuera de fonctionner car vous disposez d'une copie complète et intacte des données sur l'autre disque dur. Vous pouvez retirer le disque dur défaillant pendant que l'ordinateur fonctionne, insérer un nouveau disque dur, et il reconstruira automatiquement le miroir.
- Inconvénient:
L'inconvénient du RAID 1 est que vous n'obtenez pas d'espace disque supplémentaire. Si vos deux disques durs font tous les deux 1 To, alors le volume utilisable total sera de 1 To au lieu de 2 To.
RAID matériel vs RAID logiciel.
The nice part about RAID 1 is that if one of your hard drive fails, your computer or server would still be up and running because you have a complete, intact copy of the data on the other hard drive. You can pull the failed hard drive out while the computer is running, insert a new hard drive and it will automatically rebuilds the mirror.
Étapes de base pour créer un RAID 1 logiciel sous Linux:
The downside of RAID 1 is that you dont get any extra disk space. If your two hard drives are both 1TB, then the total usable volume is 1TB instead of 2TB.
Hardware RAID vs Software RAID
- Tout d'abord, vous devez avoir une distribution Linux installée sur votre disque dur. Ici /dev/sda.
To set up RAID, you can either use a hard drive controller, or use a piece of software to create it. A hard drive controller is a PCIe card that you put into a computer. Then you connect your hard drives to this card. When you boot up the computer, you are going to see an option that allows you to configure the RAID. You can install an operating system on top of hardware RAID which can increase uptime.
- Vous avez besoin de deux disques durs qui seront nommés /dev/sdb et /dev/sdc Ces deux disques durs peuvent avoir des tailles différentes.
> N'oubliez pas de sauvegarder vos données existantes avant de formater vos disques durs.
Software RAID requires you already installed an operating system. Its good for storing data.
Basic Steps to Create Software RAID 1 on Linux
- Ensuite, nous créerons des systèmes de fichiers spéciaux sur /dev/sdb et /dev/sdc.
## process:
- Enfin, créez le tableau RAID 1 à l'aide de l'utilitaire mdadm.
- First you need to have a Linux distribution installed on your hard drive. In this tutorial we will name it /dev/sda.
## Étape 1 : Formater le disque dur
- You need two hard drives which will be named /dev/sdb and /dev/sdc in this post. These two hard drives can be of different sizes. Remember to back up your existing data before formating your hard drives.
- Next, we will create special file systems on /dev/sdb and /dev/sdc.
- Finally create the RAID 1 array using the mdadm utility.
## Step 1: Format Hard Drive
Insert two hard drives into your Linux computer, then open up a terminal window. Run the following command to check the device name.
Insérez deux disques durs dans votre ordinateur Linux, puis ouvrez une fenêtre de terminal. Exécutez la commande suivante pour vérifier le nom du dispositif.
```bash
sudo fdisk -l
```
![](docs/image1.png)
```
![img1](docs/image1.png)
```bash
linux fdisk partition
```
You can see mine is /dev/sdb and /dev/sdc.
Vous pouvez voir que le mien est /dev/sdb et /dev/sdc.
Then run the following 2 commands to make new MBR partition table on the two hard drives. (Note: this is going to wipe out all existing partitions and data from these two hard drives. Make sure your data is backed up.)
- Ensuite, exécutez les deux commandes suivantes pour créer une nouvelle table de partition MBR sur les deux disques durs. (Remarque : cela effacera toutes les partitions et les données existantes de ces deux disques durs. Assurez-vous de sauvegarder vos données.)
```bash
sudo parted /dev/sdb mklabel msdos
sudo parted /dev/sdc mklabel msdos
```
You can create GPT partition table by replacing msdos with gpt, but for the sake of compatibility, this tutorial will create MBR partition table.
Vous pouvez créer une table de partition GPT en remplaçant "msdos" par "gpt", mais pour des raisons de compatibilité, ce tutoriel créera une table de partition MBR.
Next, use the fdisk command to create a new partition on each drive and format them as a Linux raid autodetect file system. First do this on /dev/sdb.
Ensuite, utilisez la commande fdisk pour créer une nouvelle partition sur chaque disque et formatez-les en tant que système de fichiers Linux autodétecté en RAID. Commencez par le faire sur /dev/sdb.
```bash
sudo fdisk /dev/sdb
```
Follow these instructions:
- Type n to create a new partition.
- Type p to select primary partition.
- Type 1 to create /dev/sdb1.
- Press Enter to choose the default first sector
- Press Enter to choose the default last sector. This partition will span across the entire drive.
- Typing p will print information about the newly created partition. By default the partition type is Linux.
- We need to change the partition type, so type t.
- Enter fd to set partition type to Linux raid autodetect.
- Type p again to check the partition type.
- Type w to apply the above changes.
![](docs/images2.png)
software raid 1 linux raid autodetect
Follow the same instruction to create a Linux raid autodetect partition on /dev/sdc.
Now we have two raid devices /dev/sdb1 and /dev/sdc1.
## Step 2: Install mdadm
![img1](docs/image2.png)
mdadm is used for managing MD (multiple devices) devices, also known as Linux software RAID.
Suivez les mêmes instructions pour créer une partition Linux autodétectée en RAID sur /dev/sdc:
Debian/Ubuntu: sudo apt install mdadm
- Tapez "n" pour créer une nouvelle partition.
- Tapez "p" pour sélectionner une partition principale.
- Tapez "1" pour créer /dev/sdb1.
- Appuyez sur Entrée pour choisir le premier secteur par défaut.
- Appuyez sur Entrée pour choisir le dernier secteur par défaut. Cette partition s'étendra sur l'ensemble du disque.
- En tapant "p", vous pouvez afficher des informations sur la partition nouvellement créée. Par défaut, le type de partition est Linux.
- Nous devons changer le type de partition, alors tapez "t".
- Tapez "fd" pour définir le type de partition sur Linux autodétecté en RAID.
- Tapez à nouveau "p" pour vérifier le type de partition.
- Tapez "w" pour appliquer les changements ci-dessus.
CentOS/Redhat: sudo yum install mdadm
> Maintenant, nous avons deux dispositifs RAID, /dev/sdb1 et /dev/sdc1.
SUSE: sudo zypper install mdadm
## Étape 2 : Installer mdadm
Arch Linux sudo pacman -S mdadm
[MDADM](https://fr.wikipedia.org/wiki/Mdadm) est utilisé pour gérer les dispositifs MD (multiples dispositifs), également connus sous le nom de RAID logiciel Linux.
Pour installer mdadm selon votre distribution de Linux:
* Debian/Ubuntu : sudo apt install mdadm
* CentOS/Redhat : sudo yum install mdadm
* SUSE : sudo zypper install mdadm
* Arch Linux : sudo pacman -S mdadm
Lets examine the two devices.
Examinons les deux dispositifs:
```bash
sudo mdadm --examine /dev/sdb /dev/sdc
```
![](docs/image3.png)
![img2](docs/image3.png)
You can see that both are the type fd (Linux raid autodetect). At this stage, theres no RAID setup on /dev/sdb1 and /dev/sdc1 which can be inferred with this command.
Vous pouvez voir que les deux sont de type "fd" (Linux autodétecté en RAID). À ce stade, il n'y a pas de configuration RAID sur /dev/sdb1 et /dev/sdc1, ce qui peut être déduit avec cette commande:
```bash
sudo mdadm --examine /dev/sdb1 /dev/sdc1
```
![](docs/image4.png)
![img2](docs/image4.png)
## Step 3: Create RAID 1 Logical Drive
## Étape 3 : Créer un lecteur logique RAID 1
Execute the following command to create RAID 1. The logical drive will be named /dev/md0.
#### Exécutez la commande suivante pour créer un RAID 1. Le lecteur logique sera nommé /dev/md0.
```bash
sudo mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdc1
```
![](docs/image5.png)
![img2](docs/image5.png)
> :warning: Note: If you see this message: “Device or resource busy”, then you may need to reboot the OS.
:warning: Remarque : Si vous voyez ce message : "Device or resource busy" (Appareil ou ressource occupé), vous devrez peut-être redémarrer le système d'exploitation.
Now we can check it with:
Maintenant, nous pouvons le vérifier avec :
```bash
cat /proc/mdstat
```
![](docs/image6.png)
![img2](docs/image6.png)
You can see that md0 is active and is a RAID 1 setup. To get more detailed information about /dev/md0, we can use the below commands:
Vous pouvez voir que md0 est actif et qu'il s'agit d'une configuration RAID 1. Pour obtenir des informations plus détaillées sur /dev/md0, vous pouvez utiliser les commandes ci-dessous :
```bash
sudo mdadm --detail /dev/md0
```
![](docs/image7.png)
![img2](docs/image7.png)
To obtain detailed information about each raid device, run this command:
Pour obtenir des informations détaillées sur chaque dispositif RAID, exécutez cette commande :
```bash
sudo mdadm --examine /dev/sdb1 /dev/sdc1
```
![](docs/image8.png)
![img2](docs/image8.png)
## Step 4: Create File System on the RAID 1 Logical Drive
## Étape 4 : Créer un système de fichiers sur le lecteur logique RAID 1
Lets format it to ext4 file system.
#### Formatez-le en système de fichiers ext4.
```bash
sudo mkfs.ext4 /dev/md0
```
Then create a mount point /mnt/raid1 and mount the RAID 1 drive.
#### Créer un point de montage /mnt/raid1 et montez le lecteur RAID 1
```bash
sudo mkdir /mnt/raid1
sudo mount /dev/md0 /mnt/raid1
```
You can use this command to check how much disk space you have.
Vous pouvez utiliser cette commande pour vérifier la quantité d'espace disque dont vous disposez.
```bash
df -h /mnt/raid1
```
![](docs/image8.png)
![img2](docs/image9.png)
> Rappelez-vous que si vous utilisez un logiciel de sauvegarde de disque tel que Clonezilla, vous devez restaurer les données sur le lecteur logique RAID, pas sur le disque physique.
raid recovery
Remember that if you use disk backup software such as Clonezilla, you need to restore data to the RAID logical drive, not the physical drive.
Its very important to save our RAID1 configuration with the below command.
#### Sauvegarder notre configuration RAID1 avec la commande suivante:
```bash
sudo mdadm --detail --scan --verbose | sudo tee -a /etc/mdadm/mdadm.conf
```
Output:
Sortie :
ARRAY /dev/md/0 level=raid1 num-devices=2 metadata=1.2 spares=1 name=xenial:0 UUID=c7a2743d:f1e0d872:b2ad29cd:e2bee48c
devices=/dev/sdb1,/dev/sdc1
```bash
ARRAY /dev/md/0 level=raid1 num-devices=2 metadata=1.2 spares=1 name=xenial:0 UUID=c7a2743d:f1e0d872:b2ad29cd:e2bee48c
- devices=/dev/sdb1,/dev/sdc1
```
On some Linux distribution such as CentOS, the config file for mdadm is /etc/mdadm.conf. You should run the following command to generate a new initramfs image after running the above command.
> Sur certaines distributions Linux telles que CentOS, le fichier de configuration pour mdadm se trouve dans /etc/mdadm/mdadm.conf. Vous devrez exécuter la commande suivante pour générer une nouvelle image initramfs après avoir exécuté la commande ci-dessus.
```bash
sudo update-initramfs -u
```
```
To automatically mount the RAID 1 logical drive on boot time, add an entry in /etc/fstab file like below.
#### Pour monter automatiquement le lecteur logique RAID 1 au démarrage, ajouter une entrée dans le fichier /etc/fstab comme suit:
```bash
/dev/md0 /mnt/raid1 ext4 defaults 0 0
```
You may want to use the x-gvfs-show option, will let you see your RAID1 in the sidebar of your file manager.
Vous pouvez également utiliser l'option x-gvfs-show, qui vous permettra de voir votre RAID1 dans la barre latérale de votre gestionnaire de fichiers.
```bash
/dev/md0 /mnt/raid1 ext4 defaults,x-gvfs-show 0 0
/dev/md0 /mnt/raid1 ext4- defaults,x-gvfs-show 0 0
```
## How to Remove the RAID
#### Comment supprimer le RAID:
If you dont want to use the RAID anymore, run the following command to remove the RAID.
Si vous ne souhaitez plus utiliser le RAID, exécutez la commande suivante pour le supprimer.
```bash
sudo umount /mnt/raid1
sudo mdadm --remove /dev/md0
```
Then edit the mdadm.conf file and comment out the RAID definition:
Ensuite, éditez le fichier mdadm.conf et commentez la définition RAID :
```bash
#ARRAY /dev/md0 level=raid1 num-devices=2 metadata=1.2 spares=1 name=bionic:0 UUID=76c80bd0:6b1fe526:90807435:99030af9
# devices=/dev/sda1,/dev/sdb1
```
> :warning: Also, edit /etc/fstab file and comment out the line that enables auto-mount of the RAID device.
:warning: De plus, éditez le fichier /etc/fstab et commentez la ligne qui active le montage automatique du dispositif RAID.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Loading…
Cancel
Save