An identical copy of your data is stored on each disk (provided the array is not "dirty"—e.g., if power is lost after writing to disk 0, but before writing to disk 1). However, the metadata is different; it allows mdadm & md to tell the two disks apart.
Can you swap the cables around?
You can swap the cables on the two disks. When you (or your distro's boot scripts) do
mdadm --assemble on the array, mdadm looks at the metadata on each disk, and from that figures out which is disk 1 and which is disk 2.
This is in fact extremely flexible—you could, for example, remove one of the disks, put it in a USB-SATA enclosure, and attach it to a USB port, and mdraid would still be perfectly happy.
Can I recover a degraded array by using
No. If you did that, you'd have two disk 1's, or two disk 2's, and mdadm would be confused (and, I haven't tested this, but I assume it'd refuse to assemble the array).
In general, all array management is done with
mdadm and further it is seldom a good idea to go around mdraid. To recover your array, you add the new disk/partition to it. Something like this, assuming
sdb1 is the partition on the replacement disk:
mdadm --add /dev/md0 /dev/sdb1
mdraid will then copy the data, and you can watch the status by
cat /proc/mdstat. You are free to continue using the array during the re-sync. There is no need to boot from a live CD or similar (you should be able to boot from the degraded array). In fact, if you have hot-swap trays in your machine, you can replace a failed sdb like this:
mdadm -r /dev/md0 /dev/sdb1
- Remove the drive
- Put in new drive
- Partition the new drive (often, but not always, will be sdb again).
mdadm -a /dev/md0 /dev/sdb1
This does not require any downtime.
Note also that if you're booting from a mirror, you need to make sure the bootloader (e.g., grub) is installed to both disks. How to do this depends on your distro.
mdadm --create is not a recovery step. It is used to create a new, blank array, and the next step would typically be
mkfs. Already existing arrays are started using
mdadm --assemble. (This seems to be a common enough error, and has the potential to destroy data.)
You should probably take a bit to familiarize yourself with the mdraid documentation (you are trusting it with your data, after all). In particular, read through the
mdadm manual page, any RAID documentation your distro puts out, and Documentation/md.txt (from the kernel sources, corresponding to your kernel version). These are probably not the most understandable documents, but they are all generally up-to-date.
There is also a Linux Raid wiki, but beware that not everything there is fully up-to-date.
There are other pages out there, but be especially cautious of anything mentioning
/etc/raidtab other than as a historical note, as those tools have be obsolete for a decade.