Linux RAID1 repair

By telleropnul, June 22, 2016

See below for detailed command output.
So there are two RAID1 (= hard disk mirror) volumes (=’drive letters’) in use by Koozali.
The first one is called /dev/md1 and is 106MB in size.
The second one is called /dev/md2 and is 79GB in size.
The new hard disk showed up as /dev/sdb.
It was not partitioned.
Using fdisk, I partitioned the hard disk to match the 80GB hard disk /dev/sda.
Both /dev/sda1 and /dev/sda2 start at cylinder 1 and stop at cylinder 13 (106MB).
Both /dev/sda2 and /dev/sdb2 start at cylinder 14 and stop at [end of free hard disk space]
When /dev/sdb was partitioned in two partitions (/dev/sdb1 and /dev/sdb2) I added the partitions to the RAID1 hard disk mirror volumes /dev/md1 and /dev/md2
/dev/md1 showed 2/2 hard disks inside the mirror.
/dev/md2 showed it only had 2/1 hard disks inside the mirror, but also that is was busy syncing the mirror….1.1% done….1.5% done….etc.
Eventually /dev/md2 showed 2/2 hard disks inside the mirror as well.

==========================================================

fdisk -l

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   fd  Linux raid autodetect
/dev/sda2              14        9729    78043770   fd  Linux raid autodetect

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn’t contain a valid partition table

==========================================================

cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sda1[1]
104320 blocks [2/1] [_U]

md2 : active raid1 sda2[1]
78043648 blocks [2/1] [_U]

==========================================================

[root@cloudserver ~]# mdadm -D /dev/md1
/dev/md1:
Version : 00.90.03
Creation Time : Tue Feb  9 18:23:06 2010
Raid Level : raid1
Array Size : 104320 (101.89 MiB 106.82 MB)
Used Dev Size : 104320 (101.89 MiB 106.82 MB)
Raid Devices : 2
Total Devices : 1
Preferred Minor : 1
Persistence : Superblock is persistent

Update Time : Sat Oct 29 14:29:04 2011
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0

UUID : 75033f39:83173411:7e4c09d0:950cf5d3
Events : 0.50

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

============================================================

[root@cloudserver ~]# mdadm -D /dev/md2
/dev/md2:
Version : 00.90.03
Creation Time : Tue Feb  9 18:23:06 2010
Raid Level : raid1
Array Size : 78043648 (74.43 GiB 79.92 GB)
Used Dev Size : 78043648 (74.43 GiB 79.92 GB)
Raid Devices : 2
Total Devices : 1
Preferred Minor : 2
Persistence : Superblock is persistent

Update Time : Sat Oct 29 14:36:08 2011
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0

UUID : e2d7cddf:055ea73c:0bdde8e9:f9e08fd4
Events : 0.67312

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

=============================================================

[root@cloudserver ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 60801.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-60801, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-60801, default 60801): 13

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-60801, default 14): 14
Last cylinder or +size or +sizeM or +sizeK (14-60801, default 60801):
Using default value 60801

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

============================================================

[root@cloudserver ~]# mdadm –add /dev/md1 /dev/sdb1
mdadm: added /dev/sdb1

============================================================

[root@cloudserver ~]# mdadm –add /dev/md2 /dev/sdb2
mdadm: added /dev/sdb2

============================================================

[root@cloudserver ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb1[0] sda1[1]
104320 blocks [2/2] [UU]

md2 : active raid1 sdb2[2] sda2[1]
78043648 blocks [2/1] [_U]
[>………………..]  recovery =  1.1% (881536/78043648) finish=27.7min speed=46396K/sec

============================================================

unused devices:
[root@cloudserver ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb1[0] sda1[1]
104320 blocks [2/2] [UU]

md2 : active raid1 sdb2[2] sda2[1]
78043648 blocks [2/1] [_U]
[>………………..]  recovery =  1.5% (1248704/78043648) finish=27.6min speed=46248K/sec

unused devices:

===========================================================

Note:

If a hard disk is not faulty, but you want to remove it from the RAID1 mirror for some reason(i.e. you made a mistake), you first have to mark the partition as faulty before it can be removed:

mdadm /dev/md1 –faulty /dev/sdb1
mdadm /dev/md1 –remove /dev/sdb1

mdadm /dev/md2 –faulty /dev/sdb2
mdadm /dev/md2 –remove /dev/sdb2

Unplug /dev/sdb

Replace with a proper hard disk

fdisk /dev/sdb (+create partitions)

mdadm –add /dev/md1 /dev/sdb1
mdadm –add /dev/md2 /dev/sdb2