Outils pour utilisateurs

Outils du site


disk_raid

Ceci est une ancienne révision du document !


Disks en RAID

Accélérer la reconstruction

parfois

Chaque 1er dimanche du mois:

# mdadm --detail /dev/md0 | grep -i state
        State : clean, resyncing

Resynchro des disks…

mdadm et des trucs simples

Voir l'etat des RAID

# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sda2[0] sdb2[1]
      2000000 blocks [2/2] [UU]

md0 : active raid1 sda1[0] sdb1[1]
      388708608 blocks [2/2] [UU]
unused devices: <none>

Voir les details

# mdadm --detail /dev/md0

Ajouter un disk au RAID

# mdadm /dev/md0 --add /dev/sda1

Casser un RAID en retirant un disk

# mdadm /dev/md0 --fail /dev/sdb1
# mdadm /dev/md0 --remove /dev/sdb1

Arreter un RAID et liberer toutes les ressources:

# mdadm --stop /dev/md0

Forcer un monitoring avec envoi de l'etat dans un mail (si configuré):

# mdadm --monitor /dev/md0 -1 --test

Ce qui envoi un truc dans ce genre a “root”:

This is an automatically generated mail message from mdadm running on <machine>

A TestMessage event had been detected on md device /dev/md0.

Faithfully yours, etc.

P.S. The /proc/mdstat file currently contains the following:

Personalities : [raid1] 
md1 : active raid1 sdb2[1] sda2[0]
      292969280 blocks [2/2] [UU]
      
md0 : active raid1 sdb1[1] sda1[0]
      248896 blocks [2/2] [UU]
      
unused devices: <none>

Voir: man mdadm

RAID 1 et double boot

Methode 1

Lien: http://wickerl.bechelaren.at/Bechelaren/web/wickerl_blog.nsf/d6plinks/HWSR-6XZ8ZR

Dans une configuration RAID 1, il peut être utile que si l'un disque est mort, l'autre soit bootable aussi.
Donc, soit 2 disks: hde et hdg .

Alors on fait:

# grub
GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ]

grub> 

Installer le bootloader sur le premier disk (dans notre cas /dev/hde)

grub> device (hd0) /dev/hde
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded
Done.

Maintenant, installer sur le second disk (dans notre cas /dev/hdg)

grub> device (hd0) /dev/hdg
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded
Done.

Fin.

grub> quit

J'ai testé (sur un RAID en SATA) et ça fonctionne.

Methode 1b

:!: Cette methode présupose que le fichier device.map est coohérent (et il devrait!)

Grace a l'existence du fichier device.map, on peut aussi faire:

# grub --device-map=/boot/grub/device.map
>> root (hd0,0)
>> setup (hd0)
>> root (hd1,0)
>> setup (hd1)
>> quit

Shrink RAID

Lien: http://www.howtoforge.com/how-to-resize-raid-partitions-shrink-and-grow-software-raid

Le calcul etait mauvais: le 2ieme disk du RAID 1 ne peut booter…

On va recommencer sans rien casser…

On a une partition LVM sur un RAID …

On boot sur “systemrescuecd” …

Le disk /dev/sda:

% sfdisk -d /dev/sda
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=     2048, size=   974848, Id=fd, bootable
/dev/sda2 : start=   976896, size=779296768, Id=fd
/dev/sda3 : start=        0, size=        0, Id= 0
/dev/sda4 : start=        0, size=        0, Id= 0

Et /dev/sdb :

% sfdisk -d /dev/sdb
# partition table of /dev/sdb
unit: sectors

/dev/sdb1 : start=       63, size=   974848, Id=fd, bootable
/dev/sdb2 : start=   974911, size=779296768, Id=fd
/dev/sdb3 : start=        0, size=        0, Id= 0
/dev/sdb4 : start=        0, size=        0, Id= 0

Le probleme, c'est que le nombre de secteur au debut, partant de 0, est different… et GRUB2 ne demarre pas sur /dev/sdb … et pourtant, le RAID 1 est UP, mais on s'en fout un peu:

% cat /proc/mdstat 
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
md126 : active raid1 sda1[0] sdb1[2]
      487412 blocks super 1.2 [2/2] [UU]
      
md127 : active raid1 sda2[0] sdb2[2]
      389647224 blocks super 1.2 [2/2] [UU]
      
unused devices: <none>

Et la on voit:

% pvs
PV         VG   Fmt  Attr PSize   PFree 
/dev/md127 vg0  lvm2 a-   371.59g 74.10g

On est un peu au dessus de 371G …

On reduit a 350G … /dev/md127

% pvresize --setphysicalvolumesize 350G /dev/md127    
Physical volume "/dev/md127" changed
1 physical volume(s) resized / 0 physical volume(s) not resized

Verifions

% pvs
PV         VG   Fmt  Attr PSize   PFree 
/dev/md127 vg0  lvm2 a-   350.00g 52.50g

Maintenant, on réduit la taille du RAID !

Une petite vue d'abord:

% mdadm --detail /dev/md127 
/dev/md127:
      Version : 1.2
Creation Time : Mon Feb  7 18:47:19 2011
   Raid Level : raid1
   Array Size : 389647224 (371.60 GiB 399.00 GB)
Used Dev Size : 389647224 (371.60 GiB 399.00 GB)
 Raid Devices : 2
Total Devices : 2
  Persistence : Superblock is persistent

  Update Time : Fri Feb 11 15:39:33 2011
        State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

         Name : k8:1  (local to host k8)
         UUID : 35a2c269:40cdcca3:d63b29c2:7c9f4067
       Events : 49934

  Number   Major   Minor   RaidDevice State
     0       8        2        0      active sync   /dev/sda2
     2       8       18        1      active sync   /dev/sdb2

On note que:

% echo $(( 389647224 / ( 1024 * 1024 ) ))        
371

Donc, on va specifier 360G, soit:

% echo $(( 377487360 / ( 1024 * 1024 ) ))
360

Donc 377487360 :

% mdadm --grow /dev/md127 --size=377487360
mdadm: component size of /dev/md127 has been set to 377487360K

Vérifions:

% mdadm --detail /dev/md127               
/dev/md127:
      Version : 1.2
Creation Time : Mon Feb  7 18:47:19 2011
   Raid Level : raid1
   Array Size : 377487360 (360.00 GiB 386.55 GB)
Used Dev Size : 377487360 (360.00 GiB 386.55 GB)
 Raid Devices : 2
Total Devices : 2
  Persistence : Superblock is persistent

  Update Time : Fri Feb 11 15:54:44 2011
        State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

         Name : k8:1  (local to host k8)
         UUID : 35a2c269:40cdcca3:d63b29c2:7c9f4067
       Events : 49935

  Number   Major   Minor   RaidDevice State
     0       8        2        0      active sync   /dev/sda2
     2       8       18        1      active sync   /dev/sdb2

Ce n'est que la couche “systeme de fichiers” en fait.

Maintenant, il faut reduire les PARTITIONS DES DISKS, qui sont (toujours) :

% sfdisk -d /dev/sda
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=     2048, size=   974848, Id=fd, bootable
/dev/sda2 : start=   976896, size=779296768, Id=fd
/dev/sda3 : start=        0, size=        0, Id= 0
/dev/sda4 : start=        0, size=        0, Id= 0

On remarque que :

% echo $(( ( 779296768 * 512 ) / ( 1024 * 1024 * 1024 ) ))
371

Ce qui est la taille en GIGA qu'on a pour la partition.

On vise maintenant, pour 365 G:

% echo $(( ( 365 * 1024 * 1024 * 1024 ) / 512 ))
765460480

Ce qu'on mettre comme nouvelle taille de partition !

Mais il faut demonter le disk de son RAID d'abord !

Umount de LVM

% /etc/init.d/lvm stop

Puis arret du RAID:

% mdadm --stop /dev/md126
mdadm: stopped /dev/md126
% mdadm --stop /dev/md127
mdadm: stopped /dev/md127

On recupere les confs:

% sfdisk -d /dev/sda >sda.txt
% sfdisk -d /dev/sdb >sdb.txt

On edite “sda.txt” et “sdb.txt” pour avoir a la fin:

% cat sda.txt 
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=     2048, size=   974848, Id=fd, bootable
/dev/sda2 : start=   976896, size=765460480, Id=fd
/dev/sda3 : start=        0, size=        0, Id= 0
/dev/sda4 : start=        0, size=        0, Id= 0

Et go!

% cat sda.txt | sfdisk /dev/sda
% cat sdb.txt | sfdisk /dev/sda

( Ajouter “–force” si nécessaire)

% sync

Et voila ?

disk_raid.1297441362.txt.gz · Dernière modification : 2011/02/11 16:22 de thierry