Guide des technologies

Configurer RAID1 logiciel sur Fedora 8

4 min read Linux RAID Mis à jour 01 Oct 2025
RAID1 logiciel sur Fedora 8 — préparer /dev/sda
RAID1 logiciel sur Fedora 8 — préparer /dev/sda

7 Préparer /dev/sda

Si tout s’est bien passé, vous devez maintenant voir /dev/md0 et /dev/md2 dans la sortie de la commande suivante :

df -h
[root@server1 ~]# df -h  
Filesystem            Size  Used Avail Use% Mounted on  
/dev/md2              4.4G  2.4G  1.8G  58% /  
/dev/md0               99M   15M   80M  16% /boot  
tmpfs                 185M     0  185M   0% /dev/shm  
[root@server1 ~]#

La sortie de :

cat /proc/mdstat

devrait ressembler à ceci :

[root@server1 ~]# cat /proc/mdstat  
Personalities : [raid1] [raid6] [raid5] [raid4]  
md0 : active raid1 sdb1[1]  
      104320 blocks [2/1] [_U]  
  
md1 : active raid1 sdb2[1]  
      513984 blocks [2/1] [_U]  
  
md2 : active raid1 sdb3[1]  
      4618560 blocks [2/1] [_U]  
  
unused devices:   
[root@server1 ~]#

Maintenant, nous devons modifier le type de partition des trois partitions sur /dev/sda pour les passer en « Linux raid autodetect » :

fdisk /dev/sda

Exemple d’interaction :

[root@server1 ~]# fdisk /dev/sda

Command (m for help): <-- t  
Partition number (1-4): <-- 1  
Hex code (type L to list codes): <-- fd  
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): <-- t  
Partition number (1-4): <-- 2  
Hex code (type L to list codes): <-- fd  
Changed system type of partition 2 to fd (Linux raid autodetect)

Command (m for help): <-- t  
Partition number (1-4): <-- 3  
Hex code (type L to list codes): <-- fd  
Changed system type of partition 3 to fd (Linux raid autodetect)

Command (m for help): <-- w  
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@server1 ~]#

Ensuite, ajoutez /dev/sda1, /dev/sda2 et /dev/sda3 aux arrays RAID correspondants :

mdadm --add /dev/md0 /dev/sda1  
mdadm --add /dev/md1 /dev/sda2  
mdadm --add /dev/md2 /dev/sda3

Vérifiez l’état avec :

cat /proc/mdstat

Vous devriez voir la synchronisation en cours :

[root@server1 ~]# cat /proc/mdstat  
Personalities : [raid1] [raid6] [raid5] [raid4]  
md0 : active raid1 sda1[0] sdb1[1]  
      104320 blocks [2/2] [UU]  
  
md1 : active raid1 sda2[0] sdb2[1]  
      513984 blocks [2/2] [UU]  
  
md2 : active raid1 sda3[2] sdb3[1]  
      4618560 blocks [2/1] [_U]  
      [=====>...............]  recovery = 29.9% (1384256/4618560) finish=2.3min speed=22626K/sec  
  
unused devices:   
[root@server1 ~]#

Important — Pour surveiller en continu la progression, utilisez :

watch cat /proc/mdstat

Pour quitter watch, appuyez sur CTRL+C.

Attendez la fin de la synchronisation. Lorsque c’est terminé, la sortie ressemblera à :

[root@server1 ~]# cat /proc/mdstat  
Personalities : [raid1] [raid6] [raid5] [raid4]  
md0 : active raid1 sda1[0] sdb1[1]  
      104320 blocks [2/2] [UU]  
  
md1 : active raid1 sda2[0] sdb2[1]  
      513984 blocks [2/2] [UU]  
  
md2 : active raid1 sda3[0] sdb3[1]  
      4618560 blocks [2/2] [UU]  
  
unused devices:   
[root@server1 ~]#

Ensuite, mettez à jour /etc/mdadm.conf pour refléter l’état actuel :

mdadm --examine --scan > /etc/mdadm.conf

/etc/mdadm.conf devrait maintenant ressembler à quelque chose comme ceci :

cat /etc/mdadm.conf

| ARRAY /dev/md0 level=raid1 num-devices=2 UUID=2848a3f5:cd1c26b6:e762ed83:696752f9 ARRAY /dev/md1 level=raid1 num-devices=2 UUID=8a004bac:92261691:227767de:4adf6592 ARRAY /dev/md2 level=raid1 num-devices=2 UUID=939f1c71:be9c10fd:d9e5f8c6:a46bcd49 |

8 Préparer GRUB — Partie 2

Nous en sommes presque à la fin. Il faut maintenant modifier /boot/grub/menu.lst. Actuellement, il est configuré pour démarrer depuis /dev/sdb (hd1,0). Pour que la machine puisse toujours démarrer si /dev/sdb tombe en panne, copiez la première entrée du noyau (qui contient hd1), collez-la en dessous et remplacez hd1 par hd0. Commentez les autres stanzas de noyau.

Ouvrez le fichier :

vi /boot/grub/menu.lst

Le fichier mis à jour devrait ressembler à ceci :

| # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/sda3 # initrd /initrd-version.img #boot=/dev/sda default=0 fallback=1 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Fedora (2.6.23.1-42.fc8) root (hd1,0) kernel /vmlinuz-2.6.23.1-42.fc8 ro root=/dev/md2 rhgb quiet initrd /initrd-2.6.23.1-42.fc8.img title Fedora (2.6.23.1-42.fc8) root (hd0,0) kernel /vmlinuz-2.6.23.1-42.fc8 ro root=/dev/md2 rhgb quiet initrd /initrd-2.6.23.1-42.fc8.img #title Fedora (2.6.23.1-42.fc8) # root (hd0,0) # kernel /vmlinuz-2.6.23.1-42.fc8 ro root=LABEL=/ rhgb quiet # initrd /initrd-2.6.23.1-42.fc8.img |

Ensuite, mettez à jour votre ramdisk :

mv /boot/initrd-`uname -r`.img /boot/initrd-`uname -r`.img_orig2  
mkinitrd /boot/initrd-`uname -r`.img `uname -r`

Enfin, redémarrez :

reboot

Le système devrait démarrer normalement et être capable de démarrer depuis /dev/sda ou /dev/sdb.

Félicitations — vous avez configuré avec succès un RAID1 logiciel sur votre système Fedora 8 en fonctionnement.


Checklist rapide pour l’administrateur

  • Vérifier la présence de /dev/md0, /dev/md1, /dev/md2 avec df -h et cat /proc/mdstat
  • Changer le type des partitions sda1..sda3 en fd via fdisk
  • Ajouter les partitions avec mdadm –add
  • Surveiller la synchronisation avec watch cat /proc/mdstat
  • Regénérer /etc/mdadm.conf
  • Mettre à jour /boot/grub/menu.lst pour ajouter une entrée hd0
  • Regénérer l’initrd et redémarrer

Risques courants et mitigations

  • Risque : modification erronée de la table de partitions.
    Mitigation : sauvegarder la table (sfdisk -d /dev/sda > sda.part) avant les changements.

  • Risque : démarrage impossible après modification de GRUB.
    Mitigation : conservez une entrée de secours non commentée et un LiveCD/USB pour réparation.

  • Risque : synchronisation interrompue.
    Mitigation : laissez la reconstruction se terminer; évitez d’éteindre le serveur pendant la resynchronisation.

Mini-méthodologie (étapes condensées)

  1. Confirmer l’état initial des arrays (/proc/mdstat).
  2. Changer le type de partitions sur sda en fd.
  3. Ajouter sda1/2/3 aux mdX correspondants.
  4. Surveiller la reconstruction jusqu’à [UU].
  5. Regénérer /etc/mdadm.conf et l’initrd.
  6. Mettre à jour GRUB et tester le redémarrage.

Arbre de décision rapide (Mermaid)

flowchart TD
  A[Arrays existent ?] -->|Non| B[Créer arrays avec mdadm]
  A -->|Oui| C[Changer type partitions sur sda]
  C --> D[Ajouter partitions à mdadm]
  D --> E[Surveiller /proc/mdstat]
  E --> F{Reconstruction OK ?}
  F -->|Oui| G[Mettre à jour mdadm.conf et initrd]
  F -->|Non| H[Diagnostic et correction]
  G --> I[Mise à jour GRUB]
  I --> J[Redémarrage et test]

Glossaire (1 ligne chacun)

  • mdadm : utilitaire pour gérer des arrays RAID logiciels Linux.
  • RAID1 : miroir de disques pour redondance en lecture/écriture.
  • initrd/initramfs : image initiale chargée au démarrage contenant les modules nécessaires au montage du root.
  • GRUB : chargeur d’amorçage qui sélectionne le noyau à démarrer.

Résumé

  • Changez les types de partitions de sda en « Linux raid autodetect ».
  • Ajoutez les partitions sda1..sda3 aux arrays existants et attendez la synchronisation.
  • Mettez à jour /etc/mdadm.conf, regénérez l’initrd, adaptez GRUB et redémarrez pour valider le basculement.

Notes importantes : conservez un accès de secours (console, IPMI, LiveCD) lors des opérations sur la table de partitions et le chargeur d’amorçage.

Auteur
Édition

Matériaux similaires

Miroir intelligent mural pour le prix d'un smartphone
DIY

Miroir intelligent mural pour le prix d'un smartphone

Protégez-vous du malvertising
Sécurité

Protégez-vous du malvertising

Réparer Windows 11 avec DISM
Systèmes

Réparer Windows 11 avec DISM

Désinstaller KB5063878 : corriger 0x800f0905
Windows 11

Désinstaller KB5063878 : corriger 0x800f0905

Protection rançongiciels Windows 11 — Guide pratique
Sécurité Windows

Protection rançongiciels Windows 11 — Guide pratique

iPhone SE 2020 gratuit via échange Sprint
Offres

iPhone SE 2020 gratuit via échange Sprint