Guide des technologies

Préparer /dev/hda et configurer GRUB pour RAID1

3 min read Linux Mis à jour 17 Oct 2025
Préparer /dev/hda et GRUB pour RAID1
Préparer /dev/hda et GRUB pour RAID1

7 Préparation de /dev/hda

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

df -h
[root@server1 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md2              4.4G  757M  3.4G  18% /
/dev/md0              167M  9.0M  150M   6% /boot
[root@server1 ~]#

La sortie de

cat /proc/mdstat

devrait ressembler à ceci :

[root@server1 ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 hdb5[1]
      417536 blocks [2/1] [_U]

md0 : active raid1 hdb1[1]
      176576 blocks [2/1] [_U]

md2 : active raid1 hdb6[1]
      4642688 blocks [2/1] [_U]

unused devices: 
[root@server1 ~]#

Maintenant il faut changer le type de partition de nos trois partitions sur /dev/hda en “Linux raid autodetect” :

fdisk /dev/hda

Exemple de session fdisk (conservez la sortie telle quelle) :

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

Command (m for help): <-- t
Partition number (1-6): <-- 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-6): <-- 5
Hex code (type L to list codes): <-- fd
Changed system type of partition 5 to fd (Linux raid autodetect)

Command (m for help): <-- t
Partition number (1-6): <-- 6
Hex code (type L to list codes): <-- fd
Changed system type of partition 6 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/hda1, /dev/hda5 et /dev/hda6 aux ensembles RAID correspondants :

mdadm --add /dev/md0 /dev/hda1
mdadm --add /dev/md1 /dev/hda5
mdadm --add /dev/md2 /dev/hda6

Regardez à nouveau :

cat /proc/mdstat

… et vous devriez voir que les ensembles RAID se synchronisent :

[root@server1 ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 hda5[2] hdb5[1]
      417536 blocks [2/1] [_U]
        resync=DELAYED

md0 : active raid1 hda1[0] hdb1[1]
      176576 blocks [2/2] [UU]

md2 : active raid1 hda6[2] hdb6[1]
      4642688 blocks [2/1] [_U]
      [======>..............]  recovery = 34.4% (1597504/4642688) finish=1.0min speed=50349K/sec

unused devices: 
[root@server1 ~]#

(Vous pouvez exécuter

watch cat /proc/mdstat

pour surveiller en continu. Pour quitter watch, appuyez sur CTRL+C.)

Attendez la fin de la synchronisation — la sortie devrait alors ressembler à :

[root@server1 ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 hda5[0] hdb5[1]
      417536 blocks [2/2] [UU]

md0 : active raid1 hda1[0] hdb1[1]
      176576 blocks [2/2] [UU]

md2 : active raid1 hda6[0] hdb6[1]
      4642688 blocks [2/2] [UU]

unused devices: 
[root@server1 ~]#

Important : ne débranchez pas de disque et n’arrêtez pas la machine durant la resynchronisation.

Puis ajustez /etc/mdadm.conf à la nouvelle situation :

cp -f /etc/mdadm.conf_orig /etc/mdadm.conf
mdadm --examine --scan >> /etc/mdadm.conf

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

cat /etc/mdadm.conf

| # mdadm configuration file # # mdadm will function properly without the use of a configuration file, # but this file is useful for keeping track of arrays and member disks. # In general, a mdadm.conf file is created, and updated, after arrays # are created. This is the opposite behavior of /etc/raidtab which is # created prior to array construction. # # # the config file takes two types of lines: # # DEVICE lines specify a list of devices of where to look for # potential member disks # # ARRAY lines specify information about how to identify arrays so # so that they can be activated # # You can have more than one device line and use wild cards. The first # example includes SCSI the first partition of SCSI disks /dev/sdb, # /dev/sdc, /dev/sdd, /dev/sdj, /dev/sdk, and /dev/sdl. The second # line looks for array slices on IDE disks. # #DEVICE /dev/sd[bcdjkl]1 #DEVICE /dev/hda1 /dev/hdb1 # # If you mount devfs on /dev, then a suitable way to list all devices is: #DEVICE /dev/discs/*/* # # # # ARRAY lines specify an array to assemble and a method of identification. # Arrays can currently be identified by using a UUID, superblock minor number, # or a listing of devices. # # super-minor is usually the minor number of the metadevice # UUID is the Universally Unique Identifier for the array # Each can be obtained using # # mdadm -D # #ARRAY /dev/md0 UUID=3aaa0122:29827cfa:5331ad66:ca767371 #ARRAY /dev/md1 super-minor=1 #ARRAY /dev/md2 devices=/dev/hda1,/dev/hdb1 # # ARRAY lines can also specify a "spare-group" for each array. mdadm --monitor # will then move a spare between arrays in a spare-group if one array has a failed # drive but no spare #ARRAY /dev/md4 uuid=b23f3c6d:aec43a9f:fd65db85:369432df spare-group=group1 #ARRAY /dev/md5 uuid=19464854:03f71b1b:e0df2edd:246cc977 spare-group=group1 # # When used in --follow (aka --monitor) mode, mdadm needs a # mail address and/or a program. This can be given with "mailaddr" # and "program" lines to that monitoring can be started using # mdadm --follow --scan & echo $! > /var/run/mdadm # If the lines are not found, mdadm will exit quietly #MAILADDR [email protected] #PROGRAM /usr/sbin/handle-mdadm-events ARRAY /dev/md0 level=raid1 num-devices=2 UUID=6b4f013f:6fe18719:5904a9bd:70e9cee6 ARRAY /dev/md1 level=raid1 num-devices=2 UUID=63194e2e:c656857a:3237a906:0616f49e ARRAY /dev/md2 level=raid1 num-devices=2 UUID=edec7105:62700dc0:643e9917:176563a7 |

8 Préparation de GRUB — Partie 2

Nous avons presque terminé. Il faut modifier à nouveau /boot/grub/menu.lst. Actuellement il est configuré pour démarrer depuis /dev/hdb (hd1,0). Pour permettre le démarrage si /dev/hdb échoue, copiez le premier bloc kernel (qui contient hd1), collez-le en dessous et remplacez hd1 par hd0. Commentez les autres stanzas kernel. Par exemple :

vi /boot/grub/menu.lst

| timeout 10 color black/cyan yellow/cyan default 0 fallback 1 title linux kernel (hd1,0)/vmlinuz BOOT_IMAGE=linux root=/dev/md2 resume=/dev/md1 initrd (hd1,0)/initrd.img title linux kernel (hd0,0)/vmlinuz BOOT_IMAGE=linux root=/dev/md2 resume=/dev/md1 initrd (hd0,0)/initrd.img #title linux #kernel (hd0,0)/vmlinuz BOOT_IMAGE=linux root=/dev/hda6 resume=/dev/hda5 #initrd (hd0,0)/initrd.img #title failsafe #kernel (hd0,0)/vmlinuz BOOT_IMAGE=failsafe root=/dev/hda6 failsafe #initrd (hd0,0)/initrd.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`

Puis redémarrez la machine :

reboot

Le système devrait démarrer normalement.

Important : après le redémarrage, vérifiez que les arrays sont bien montés et que /boot est accessible depuis les deux disques :

cat /proc/mdstat
mount | grep /boot
ls -l /boot

Liste de vérification rapide (avant et après reboot)

  • /dev/md0, /dev/md1, /dev/md2 présents dans cat /proc/mdstat
  • Partitions de /dev/hda typées en fd (Linux raid autodetect)
  • mdadm –add exécutés pour hda1, hda5, hda6
  • Synchronisation terminée ([_U] → [UU])
  • /etc/mdadm.conf mis à jour
  • menu.lst modifié avec entrée hd0 et hd1
  • initrd reconstruit et reboot sans erreur

Dépannage rapide

  • Si la resynchronisation n’avance pas : vérifiez les logs (dmesg, /var/log/messages) pour erreurs de disque. Un disque défectueux peut bloquer la reconstruction.
  • Si GRUB ne démarre pas sur hda : bootez depuis le disque de secours, vérifiez que /boot contient initrd et vmlinuz et réinstallez GRUB si besoin.
  • Si vous voyez des UUID manquants dans /etc/mdadm.conf, exécutez mdadm –examine –scan et intégrez les lignes manquantes.

Critères d’acceptation

  • Les trois ensembles RAID montrent [UU] dans /proc/mdstat.
  • Le serveur démarre correctement avec la nouvelle configuration GRUB (testé en retirant temporairement hdb si possible en environnement de test).
  • /etc/mdadm.conf contient les lignes ARRAY pertinentes et mdadm –assemble fonctionne sans erreur.

Résumé

Vous avez ajouté /dev/hda aux ensembles RAID1 existants, mis à jour /etc/mdadm.conf et adapté GRUB pour un démarrage redondant. Vérifiez la synchronisation, reconstruisez l’initrd et testez le démarrage pour valider la configuration.

Cheat sheet (commandes essentielles)

fdisk /dev/hda
mdadm --add /dev/md0 /dev/hda1
mdadm --add /dev/md1 /dev/hda5
mdadm --add /dev/md2 /dev/hda6
watch cat /proc/mdstat
mdadm --examine --scan >> /etc/mdadm.conf
mv /boot/initrd-`uname -r`.img /boot/initrd-`uname -r`.img_orig2
mkinitrd /boot/initrd-`uname -r`.img `uname -r`
reboot

Notes finales

  • Ce guide est destiné à un système Mandriva 2008.0 avec RAID logiciel (mdadm). Adaptez les chemins si vous utilisez une autre distribution. Ne réalisez ces opérations qu’avec des sauvegardes valides ou en environnement de test si possible.
Auteur
Édition

Matériaux similaires

Mettre à jour Windows 8.1 Preview vers la finale
Windows

Mettre à jour Windows 8.1 Preview vers la finale

Installer GitLab CE sur Ubuntu 16.04
DevOps

Installer GitLab CE sur Ubuntu 16.04

Réparer YouTube Vanced : l'app s'arrête
Applications

Réparer YouTube Vanced : l'app s'arrête

Donner la puissance de votre PC avec BOINC
Open Source

Donner la puissance de votre PC avec BOINC

Partager mot de passe Wi‑Fi par QR code
Wi-Fi

Partager mot de passe Wi‑Fi par QR code

Désactiver User OOBE Broker sur Windows
Windows

Désactiver User OOBE Broker sur Windows