Score:0

mdadm check raid1 - does it even make sense?

cn flag
rp0

what does a raid1 check actually do?

I have a simple setup, two drives as mdadm raid1 (Ubuntu 20.04). I run a check and it says everything OK. I changed one byte on one of the physical drives using a disk editor, ran the check again and it still says everything is OK.

How can that be?

I know of course that there are no CRCs but I would at least expect it to compare the two drives and let me know there's a discrepancy, otherwise what is it point. What is it doing anyway, just reading every sector to see if it can?

The test I did was in a VM and only took a minute but my actual server has two 20TB drives and that takes close to 30 hours.

The command I used: echo check > /sys/block/md0/md/sync_action

Output:

Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] 
md0 : active raid1 sdb1[0] sdc1[1]
      10475456 blocks super 1.2 [2/2] [UU]
      [====>................]  check = 23.5% (2463488/10475456) finish=0.6min speed=205290K/sec

Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] 
md0 : active raid1 sdb1[0] sdc1[1]
      10475456 blocks super 1.2 [2/2] [UU]
Terrance avatar
id flag
Your question seems to be missing context like the checks that you are actually running and the output of them. I would recommend that you add more details to your question like the commands that you are running and their outputs. I can say though that if you are not modifying the partitions themselves, then the RAID1 should still work fine. Also, a RAID1 doesn't have any CRC or any other types of checks like that as it will copy blindly to the mirror, so if there are any errors with the primary they will transfer to the mirror.
Terrance avatar
id flag
`sdb1[0] sdc1[1]` shows that the RAID1 is partition 1 of both drives and that drive `sdb` is the active drive at the moment. If there is no change to the partitions then it will always pass the checks. Partitions don't use all the space of the physical drives anyways. The best way to check a RAID1 is to fail one of the drives with `mdadm` to remove it from the array then add it back later. I would see https://tldp.org/HOWTO/Software-RAID-HOWTO-6.html to go through how to test RAIDs on a system.
rp0 avatar
cn flag
rp0
I have seen that page, didn't help. My question is, what is mdadm doing, why isn't it comparing the data (would be easy to do) and should I turn off the monthly check? Also, I use partitions since it is saver, no one will ask to create a partition table...
Terrance avatar
id flag
Read section 6.4 of that link: "RAID cannot and is not supposed to guard against data corruption on the media. Therefore, it doesn't make any sense either, to purposely corrupt data (using dd for example) on a disk to see how the RAID system will handle that. It is most likely (unless you corrupt the RAID superblock) that the RAID layer will never find out about the corruption, but your filesystem on the RAID device will be corrupted." So, it is up to you if you keep the monthly checks or not.
rp0 avatar
cn flag
rp0
I have seen that, of course. I still think it should do the compare. Anyway, what is mdadm doing? Does it really just read all sectors?
Terrance avatar
id flag
All the check is doing is checking the integrity of the array and the corresponding blocks. If a block becomes unreadable it will recommend a repair or do it itself. It does not perform file repairs. See https://www.thomas-krenn.com/en/wiki/Mdadm_checkarray_function All surface scans or like the app badblocks will not protect data against corruption, but will check the drive for integrity and make sure that all the blocks are good. If they are not good it can try to save data, but if it cannot fix the block it will mark it unusable.
rp0 avatar
cn flag
rp0
Thanks. I guess all I can do is to keep the block scan and assume a write to the second drive works fine, unless I want to create something to check the individual drives, which might be complicated.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.