logo.png

LOCALES
DATE
CRON

SSH
IPTABLES

BIND9
EXIM4

RAID
NFS
RSYNC

HOBBIT
ROOTKITS

APACHE2
MYSQL
LDAP

MULE
APT

DEBIAN
GENTOO
UBUNTU

XORG

LIVE CD

Home Up


Contents


L'utilitaire et les devices sont nommés par MD en réfétrence à Meta Device.


1 Installation

# modprobe raid1

KERNEL:
  Device Drivers
  * Multi device support (RAID and LVM)
  M   Raid Support
  M   ... RAID-1 (mirroring) mode

# apt-get install mdadm


2 Informations


2.1 Enumération des méta-devices

$ cat /proc/mdstat

Personalities : [raid1] [raid0] 
md6 : active raid1 sdd1[0] sde1[1]
      4393844564 blocks super 1.0 [2/2] [UU]
      
md2 : active raid0 sdb3[1] sda3[0]
      8192512 blocks 256k chunks
      
md3 : active raid1 sdb5[1] sda5[0]
      56114944 blocks [2/2] [UU]
      
md0 : active raid1 sdc1[2](S) sdb1[1] sda1[0]
      104320 blocks [2/2] [UU]
      
md5 : active raid1 sdg1[0]
      1318663296 blocks [2/1] [U_]

Les U nous donnent un rapide apperçu du bon fonctionnement des disques en RAID1.


2.2 Identification des méta-devices

# mdadm --detail /dev/md6

/dev/md6:
        Version : 01.00.03
  Creation Time : Tue Sep 16 09:16:10 2008
     Raid Level : raid1
     Array Size : 4393844564 (4190.30 GiB 4499.30 GB)
  Used Dev Size : 8787689128
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 6
    Persistence : Superblock is persistent

    Update Time : Mon Oct  6 17:37:38 2008
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : 6
           UUID : c0997472:a1b5725c:7adcf733:faa95824
         Events : 2

    Number   Major   Minor   RaidDevice State
       0       8       49        0      active sync   /dev/sdd1
       1       8       65        1      active sync   /dev/sde1

Il s'agit du UUID que l'on retrouve également dans le fichier /etc/mdadm.conf. Cf $man mdadm.conf.

DEVICE partitions containers
MAILADDR root
ARRAY /dev/md0 level=raid1 num-devices=2 devices=/dev/sda9,/dev/sdb1


2.3 Identification des composants

# mdadm --examine /dev/sdd1

/dev/sdd1:
          Magic : a92b4efc
        Version : 1.0
    Feature Map : 0x0
     Array UUID : c0997472:a1b5725c:7adcf733:faa95824
           Name : 6
  Creation Time : Tue Sep 16 09:16:10 2008
     Raid Level : raid1
   Raid Devices : 2

 Avail Dev Size : 8787689256 (4190.30 GiB 4499.30 GB)
     Array Size : 8787689128 (4190.30 GiB 4499.30 GB)
  Used Dev Size : 8787689128 (4190.30 GiB 4499.30 GB)
   Super Offset : 8787689384 sectors
          State : clean
    Device UUID : 21b2d04b:ff7bdedd:03de1d87:84431ec4

    Update Time : Mon Oct  6 17:43:55 2008
       Checksum : fa6581ad - correct
         Events : 2


    Array Slot : 0 (0, 1)
   Array State : Uu

L'identifiant Array UUID permet de retouver le tableau auquel participe ce disque.


3 Création d'un méta-devices

# mdadm --create /dev/md0 --level=1 --raid-devices=2 --run /dev/sda9 /dev/sdb1
# cat /proc/mdstat
...
# mke2fs -j /dev/md0


4 Assemblage de 2 disques RAID

Là je ne comprends pas tout... (à priori pas besoin)

# mdadm --assemble /dev/md0 /dev/sda9 /dev/sdb1


5 Exemple de dépanage

$ cat /proc/mdstat

Personalities : [raid1] 
md0 : active raid1 sda14[0] sdb8[1]
      97659008 blocks [2/2] [UU]
      
unused devices: <none>


# mdadm --detail /dev/md0
/dev/md0:
        Version : 0.90
  Creation Time : Thu Jul  3 17:30:08 2008
     Raid Level : raid1
     Array Size : 97659008 (93.13 GiB 100.00 GB)
  Used Dev Size : 97659008 (93.13 GiB 100.00 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Sat Sep  5 19:58:58 2009
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : 2c1b5075:68a897c4:ad6c6860:42e1fd6e (local to host narval)
         Events : 0.12426

    Number   Major   Minor   RaidDevice State
       0       8       14        0      active sync   /dev/sda14
       1       8       24        1      active sync   /dev/sdb8

# mdadm --examine /dev/sda14
/dev/sda14:
          Magic : a92b4efc
        Version : 0.90.00
           UUID : 2c1b5075:68a897c4:ad6c6860:42e1fd6e (local to host narval)
  Creation Time : Thu Jul  3 17:30:08 2008
     Raid Level : raid1
  Used Dev Size : 97659008 (93.13 GiB 100.00 GB)
     Array Size : 97659008 (93.13 GiB 100.00 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0

    Update Time : Sat Sep  5 20:00:27 2009
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0
       Checksum : c71fbf18 - correct
         Events : 12426


      Number   Major   Minor   RaidDevice State
this     0       8       14        0      active sync   /dev/sda14

   0     0       8       14        0      active sync   /dev/sda14
   1     1       8       24        1      active sync   /dev/sdb8


# mdadm --examine /dev/sdb8
/dev/sdb8:
          Magic : a92b4efc
        Version : 0.90.00
           UUID : 2c1b5075:68a897c4:ad6c6860:42e1fd6e (local to host narval)
  Creation Time : Thu Jul  3 17:30:08 2008
     Raid Level : raid1
  Used Dev Size : 97659008 (93.13 GiB 100.00 GB)
     Array Size : 97659008 (93.13 GiB 100.00 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0

    Update Time : Sat Sep  5 20:01:19 2009
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0
       Checksum : c71fbf58 - correct
         Events : 12426


      Number   Major   Minor   RaidDevice State
this     1       8       24        1      active sync   /dev/sdb8

   0     0       8       14        0      active sync   /dev/sda14
   1     1       8       24        1      active sync   /dev/sdb8


5.1 Retrait d'une partition

# mdadm --manage /dev/md0 -f detached /dev/sda14
mdadm: set /dev/sda14 faulty in /dev/md0

# cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 sda14[2](F) sdb8[1]
      97659008 blocks [2/1] [_U]
      
unused devices: <none>


# mdadm --detail /dev/md0
/dev/md0:
        Version : 0.90
  Creation Time : Thu Jul  3 17:30:08 2008
     Raid Level : raid1
     Array Size : 97659008 (93.13 GiB 100.00 GB)
  Used Dev Size : 97659008 (93.13 GiB 100.00 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Sat Sep  5 20:13:33 2009
          State : clean, degraded
 Active Devices : 1
Working Devices : 1
 Failed Devices : 1
  Spare Devices : 0

           UUID : 2c1b5075:68a897c4:ad6c6860:42e1fd6e (local to host narval)
         Events : 0.12430

    Number   Major   Minor   RaidDevice State
       0       0        0        0      removed
       1       8       24        1      active sync   /dev/sdb8

       2       8       14        -      faulty spare   /dev/sda14


# mdadm --examine /dev/sda14
/dev/sda14:
          Magic : a92b4efc
        Version : 0.90.00
           UUID : 2c1b5075:68a897c4:ad6c6860:42e1fd6e (local to host narval)
  Creation Time : Thu Jul  3 17:30:08 2008
     Raid Level : raid1
  Used Dev Size : 97659008 (93.13 GiB 100.00 GB)
     Array Size : 97659008 (93.13 GiB 100.00 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0

    Update Time : Sat Sep  5 20:06:29 2009
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0
       Checksum : c71fc082 - correct
         Events : 12426


      Number   Major   Minor   RaidDevice State
this     0       8       14        0      active sync   /dev/sda14

   0     0       8       14        0      active sync   /dev/sda14
   1     1       8       24        1      active sync   /dev/sdb8

# mdadm --manage /dev/md0 -r detached /dev/sda14
mdadm: hot removed /dev/sda14

# cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 sdb8[1]
      97659008 blocks [2/1] [_U]
      
unused devices: <none>


# mdadm --detail /dev/md0
/dev/md0:
        Version : 0.90
  Creation Time : Thu Jul  3 17:30:08 2008
     Raid Level : raid1
     Array Size : 97659008 (93.13 GiB 100.00 GB)
  Used Dev Size : 97659008 (93.13 GiB 100.00 GB)
   Raid Devices : 2
  Total Devices : 1
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Sat Sep  5 20:16:38 2009
          State : clean, degraded
 Active Devices : 1
Working Devices : 1
 Failed Devices : 0
  Spare Devices : 0

           UUID : 2c1b5075:68a897c4:ad6c6860:42e1fd6e (local to host narval)
         Events : 0.12438

    Number   Major   Minor   RaidDevice State
       0       0        0        0      removed
       1       8       24        1      active sync   /dev/sdb8


5.2 Ajout d'une partition

# mdadm --manage /dev/md0 -a /dev/sda13
mdadm: added /dev/sda13

# watch cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 sda13[2] sdb8[1]
      97659008 blocks [2/1] [_U]
      [>....................]  recovery =  0.7% (690240/97659008) finish=30.4min speed=53095K/sec
      
unused devices: <none>

...
# cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 sda13[0] sdb8[1]
      97659008 blocks [2/2] [UU]
      
unused devices: <none>


# mdadm --detail /dev/md0
/dev/md0:
        Version : 0.90
  Creation Time : Thu Jul  3 17:30:08 2008
     Raid Level : raid1
     Array Size : 97659008 (93.13 GiB 100.00 GB)
  Used Dev Size : 97659008 (93.13 GiB 100.00 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Sun Sep  6 18:41:09 2009
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : 2c1b5075:68a897c4:ad6c6860:42e1fd6e (local to host narval)
         Events : 0.12528

    Number   Major   Minor   RaidDevice State
       0       8       13        0      active sync   /dev/sda13
       1       8       24        1      active sync   /dev/sdb8

Home Up

This document is also available in PDF and PostScript format.



2018-12-06