Subject: Reuniting disks in a raid1 array

From: Frédéric Marchal <[email-masked]>
Date: Tue, 30 Aug 2016 07:33:02 +0200

Hello,

I had two disks in a mdadm software raid1 on an old computer.

I moved sda to a new computer. It ran there in a degraded raid1 for months.

The second disk, sdb, kept running as the lone survivor of the original raid1 
on the old computer.

Now, it's time for the old computer to retire and sdb to join its partner in 
the new raid1 on the new computer.

How can I do this safely?

Do I have to wipe sdb before adding it to the new computer? If so, how do I 
make sure raid data is gone from every one of the three partitions?

Or maybe mdadm will see that sda was used more recently than sdb and will 
synchronize sda onto sdb?

Thanks,

Frederic

---

From: Mirko Parthey <[email-masked]>
Date: Tue, 30 Aug 2016 12:14:45 +0200

> make sure raid data is gone from every one of the three partitions?

The wipefs tool can remove RAID signatures.

Deleting and recreating the partitions with the same size doesn't help
on its own, because it will not affect the signatures.
Overwriting the beginning of the disk or the partitions may not be
sufficient either, because depending on the RAID superblock version, it
might be stored at the end.

> synchronize sda onto sdb?

I would advise against such experiments. It's best to wipe the signatures
while the disk is still in the old computer, then transfer it to the new
one. A bootable rescue system such as GRML can be very handy for this job.

Regards
Mirko

---

From: Pascal Hambourg <[email-masked]>
Date: Tue, 30 Aug 2016 20:12:00 +0200

> The wipefs tool can remove RAID signatures.

Or mdadm --zero-superblock

> might be stored at the end.

The default superblock format 1.2 stores the superblock 4 KiB after the 
beginning. However the OP wrote the disk was divided in several RAID 
partitions, so it would not erase all the superblocks.

> one.

I second this advice.

> A bootable rescue system such as GRML can be very handy for this job.

Or you can just use the initramfs shell. Add "break" to the kernel 
command line to trigger it. Or the Debian installer shell.

---

From: Lars Noodén <[email-masked]>
Date: Tue, 30 Aug 2016 11:32:55 +0300

On 08/30/2016 08:33 AM, Frédéric Marchal wrote:
>...

Here is what I did when I restored a drive to a RAID 1 array.  I'm not
an expert, so you'll want to verify these steps.

First I cleared the start of the drive-to-be-added using "dd" reading
from /dev/zero for 1MB (probably unnecessarily large).  Then I copied
the partition table from the existing disk in the array to the
disk-to-be-added.  I used a different method, but looking around the
correct way might have been to pipe output from "sfdisk -d" on the
existing drive to  "sfdisk" on the drive-to-be-added.  That put the
partition(s) in the right place(s).  Then I added the "new" RAID
partition to the array using "mdadm".  e.g.

	mdadm --add /dev/md129 /dev/sdb3

Then it was just a matter of waiting and checking.  e.g.

	mdadm -D /dev/md129

When it was finished, it showed that it was again clean and that both
devices were present and in use.

          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

YMMV

Regards,
Lars

---

From: Frédéric Marchal <[email-masked]>
Date: Tue, 30 Aug 2016 11:04:40 +0200

On Tuesday 30 August 2016 11:32:55 Lars Noodén wrote:
> > Now, it's time for the old computer to retire and sdb to join its partner
> > in the new raid1 on the new computer.
> > 
> partition(s) in the right place(s).

I suspect this step won't work because the second hard disk was part of the 
array in the past. Its partition table is identical to the one on the active 
disk currently in the array..

If I wipe the partition table from sdb and clone the partition table from sda, 
sdb will end up with the exact same partition table as before. I suspect the 
raid superblocks and file systems will be detected as if I hadn't changed 
anything.

The only difference between sda and sdb is that they lived, as degraded raid1, 
on different computers for a few months.

I would like to avoid dd'ing a 1TB disk with /dev/zero. Syncing the two disks 
will take long enough…

Frederic

---

From: Lars Noodén <[email-masked]>
Date: Tue, 30 Aug 2016 11:44:25 +0300

>> How can I do this safely?

PS.  It goes without saying, and thus I forgot to say it, but start this
by making a fresh backup of your new system.  Preferably you have
multiple, older backups around, too, and not just one.  Sorry if that's
obvious but its importance can't be overemphasized.

Regards,
Lars