Page 1 of 1

Move Linux software RAID1 between machines

Posted: Tue Mar 11, 2014 12:21 pm
by peter_b
1) Unmount and stop the RAID:
On the computer you currently have the RAID1 running, unmount it if it's still mounted.
Then type:

Code: Select all

$ mdadm -S /dev/mdx
Replace "mdx" with the actual RAID device on your setup (md0, md127, ...)

NOTE: Stopping the software RAID is important, because with unmounting alone you will cause the softraid to think that the harddisk "disappeared" and it will require a complete re-sync.

2) Unplug the disks and move them to the target computer

3) Attach the disks individually:
I prefer to attach the disks one by one, check it's softraid status and make sure it's not automatically starting without having all its drives present.
Attaching a disk should list the RAID as inactive, with the disk present marked as spare.
/proc/mdstat might look something like this:
md127 : inactive sdg1[2](S)
524156928 blocks super 1.2
4) That should be it.
Once all disks are present, the array automatically assigns them to the same array as before and starts it.
Check /proc/mdstat to be sure. It should look something like this:
md127 : active (auto-read-only) raid1 sdh1[0] sdg1[2]
524156736 blocks super 1.2 [2/2] [UU]
Important is the part with "[UU]", which means that both disks are up. If you see a "[U_]" or "[_U]" it means that one device is considered missing. Do not start the array while in that state, or you will have to re-sync.

Re: Move Linux software RAID1 between machines

Posted: Tue Mar 11, 2014 12:22 pm
by peter_b
Troubleshooting:
In case you need to manually re-assemble the array, the following command might help:

Code: Select all

$ mdadm --assemble --scan --verbose --no-degraded
If this gives you some errors containing:
mdadm: /dev/sdx1 has wrong uuid.
you can try the following:

Code: Select all

$ mdadm --assemble /dev/mdX /dev/disks
Where "mdX" is the md-device you want to assign the disks (/dev/disks) to.

Troubleshooting: "/dev/sdX1 has wrong uuid."

Posted: Tue Dec 16, 2014 2:03 pm
by peter_b
[PROBLEM]
I just had the case where assembling of the RAIDs didn't work and failed with messages like:
mdadm: no RAID superblock on /dev/sda
mdadm: /dev/sda1 has wrong uuid.
mdadm: no RAID superblock on /dev/sdb
mdadm: /dev/sdb1 has wrong uuid.
...
[SOLUTION]
I checked the uuid of the partitions with "mdadm --examine /dev/sdX1", and the uuid matched the one stored in "/etc/mdadm/mdadm.conf".
Hm...

Yet, what was not matching was the array name (because I've renamed the SoftRAID arrays before restarting).

So, I updated "/etc/mdadm/mdadm.conf" to contain the current array names shown with "--examine".
Then I re-executed the assembling command:

Code: Select all

$ sudo mdadm --assemble --scan --verbose --no-degraded
For some (still unknown reason), the warning about wrong uuids were still shown, but the arrays were assembled properly. 8)