CentOS / RHEL : How to remove a mirror with mdadm

The post describes the procedure to remove the mirror with mdadm. The example used here has RAID1 created with devices /dev/sdb and /dev/sdc. We are going to remove the device /dev/sdb. To start with lest create the RAID1 mirror first.

Steps

1. Create a raid1 device with the disks /dev/sdb and /dv/sdc :

# mdadm -Cv /dev/md0 -l1 -n2 /dev/sdb /dev/sdc
mdadm: /dev/sdb appears to contain an ext2fs file system
    size=2097152K  mtime=Wed May  8 12:39:49 2013
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
mdadm: /dev/sdc appears to contain an ext2fs file system
    size=2097152K  mtime=Wed May  8 12:39:53 2013
mdadm: size set to 2096116K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

2. Check the md device status :

# cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 sdc[1] sdb[0]
      2096116 blocks super 1.2 [2/2] [UU]

unused devices: &ltnone&gt

3. Mark the /dev/sdb disk as failed in the mirror:

# mdadm /dev/md0 --fail /dev/sdb
mdadm: set /dev/sdb faulty in /dev/md0

4. Remove the /dev/sdb disk from the mirror :

# mdadm /dev/md0 --remove /dev/sdb
mdadm: hot removed /dev/sdb from /dev/md0

5. Check the md device status again :

# cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 sdc[1]
      2096116 blocks super 1.2 [2/1] [_U]

unused devices: &ltnone&gt
Related Post