How to wait for mdadm RAID array's resync process to fully complete?

224 Views Asked by At

I currently have a logic to wait for the resync process to finish by looking at /sys/block/mdXXX/md/raid_state to be clean and assume that the resync has finished. However, I don't think this is correct as the raid can be in clean state while the resync is still happening.

What is a guaranteed way to ensure that newly created raid1 array using mdadm has fully completed the resync process?

Does mdadm have an inbuilt way of specifying whether we want to wait for resync to finish or not?

I have a Rust program that is orchestrating RAID creation using mdadm.

    // above create RAID-1 using mdadm --create
    loop {
        // seems like the file below is always having "clean" even when resync is happening
        let raid_state = read_file("/sys/block/mdXXX/md/raid_state")
        let sync_complete = raid_state == "clean";

        if sync_complete {
            // do more
        }
    }
0

There are 0 best solutions below