RAID-1 (Mirroring)

Setting up a mirror is slightly different from using linear mode or RAID-0. We already know that mirroring replicates data across all member disks. This allows a RAID-1 to continue functioning even if a disk fails. The simplest RAID-1 configuration must contain at least two member disks. In this example, /dev/sdb1 and /dev/sdc1 are member disks of the RAID-1 at /dev/md0:

# A RAID-1 with two member disks

raiddev                /dev/md0
 raid-level            1
 nr-raid-disks         2
 chunk-size            64

 device                /dev/sdb1
 raid-disk             0

 device                /dev/sdc1
 raid-disk             1

chunk-size has no effect on RAID-1 because no disk striping is involved. But chunk-size is still required as a placeholder. Note also that the persistent-superblock isn’t needed for RAID-1. Use mkraid to create this array:

# mkraid /dev/md0
handling MD device /dev/md0
analyzing super-block
disk 0: /dev/sdb1, 17920476kB, raid superblock at 17920384kB
disk 1: /dev/sdc1, 17920476kB, raid superblock at 17920384kB

Or, using mdadm:

# mdadm -Cv -l1 -n2 /dev/md0 /dev/sd{b,c}1
mdadm: array /dev/md0 started.

Whenever a new mirror is created, resynchronization occurs:

# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid5]
read_ahead 1024 sectors
md0 : active raid1 sdc1[1] sdb1[0]
      17920384 blocks [2/2] [UU]
      [=  =  =  =  =  =  =  =>............]  resync = 40.2% (7212864/17920384)
finish=6.4min speed=27652K/sec
unused devices: <none>

Now /proc/mdstat reports information about the array and also includes information about the resynchronization process. Resynchronization ...

Get Managing RAID on Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.