How does RAID 1 determine whether a disk is corrupted?
Solution 1:
RAID 1 or RAID 5 would not protect against the sort of problem you are describing. They are mainly meant to protect against the hardware failure of a single drive (and, therefore, to reduce system downtime). With RAID 5, the parity information is not used until the failure of a drive is detected.
Although quite rare, bits can seemingly randomly change state due to a variety of causes - it's called bit rot. To protect against bit rot you can:
- Add further redundancy, e.g., by using RAID 6, combined with regular data integrity checks.
- Use a file system which actively checks for data integrity, such as ZFS. By using ZFS with RAID-Z1 (single-drive redundancy), when reading any bit that randomly "flipped", the error will be detected because the calculated checksum does not match the stored checksum. Then, where possible, ZFS will automatically correct the error using parity information.
It's worth pointing out that hard drives do have built-in data redundancy to partly mitigate bit rot.
Solution 2:
RAID1 is not a backup solution at all. What RAID1 does is to protect you from a single-drive failure. That's all. Well, okay, it also speeds up your read speeds a little. But it's not a backup solution. If you delete a file, it's deleted from both drives. If you format your RAID1, both drives are formatted. If your files are infected with a virus, you can't recover. That's why RAID1 is not a backup solution.
To answer your other question, if the data is mismatched on the drives, there's no way to tell which is correct. However, the odds of this are perhaps not as high as you may think. See, for example, Wikipedia's section on error handling on modern hard drives.
It's not impossible to add additional error-detection and error-correction, but that is not typically done at the level of the RAID controller. Some file systems such as ZFS add additional protection for your data integrity.