Home Contact Download


Welcome to Bruno Bonfils's (aka asyd homepage).

Managing software raid1 with mdadm


mdadm is a tool designed to replace raidtools under GNU/Linux.


Linux with md devices support and RAID 1 support.

Usefull commands

Task Command
Create a new mirror mdadm -C -n 2 -l 1 /dev/md0 /dev/sda /dev/sdb
Verify mirror status mdadm –detail /dev/md0
Hot remove a drive mdadm –manage -r /dev/md0 /dev/sda
Hot add a drive mdadm –manage -a /dev/md0 /dev/sda
Simulating a faulty disk mdadm –manage /dev/md0 –set-faulty /dev/sda

Disk Failure

If a disk fails, you should replace the disk and tell Linux to resync the array. First, you'll need to identify the faulty disk. (using the dmesg for example)

Then, you should stop the Linux host, and replace the faulty disk. Once the disks is changed, restart the host.

Now, you should reintegrate the new disk to the array:

(note: you should replace sdc and md1 with correct values you've identified before)

#> mdadm --manage /dev/md1 -r /dev/sdc
#> mdadm --manage /dev/md1 -a /dev/sdc

Now, enjoy reconstruction !

You could get informed on sync status:

#> mdadm --detail /dev/md1

Sample output:

        Version : 00.90.01
  Creation Time : Thu Mar 23 23:09:39 2006
     Raid Level : raid1
     Array Size : 160086464 (152.67 GiB 163.93 GB)
    Device Size : 160086464 (152.67 GiB 163.93 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 1
    Persistence : Superblock is persistent

    Update Time : Fri Mar 24 06:56:27 2006
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : 6965fc49:6b5790d8:2ca8dc68:1afb7fbd
         Events : 0.14319

    Number   Major   Minor   RaidDevice State
       0       8       32        0      active sync   /dev/sdc
       1       8       48        1      active sync   /dev/sdd


mdadm has an optional config file, which could be used to specify less informations on the command line.

Sample config file:

DEVICE partitions
ARRAY /dev/md0 level=raid1 num-devices=2
ARRAY /dev/md1 level=raid1 num-devices=2

MAILADDR your@mail.to.be.informed.in.case.of.disk.failure