Greetings This is the first time in my life I'm writing on a linux mailing list, hope I'm doing things right :) I'm setting up a NAS system on a raspberry PI, I want the data to be stored on a RAID-5 setup. I currently have 3 2TB WD-red drives assembled into a RAID-5, connected to the PI via a USB-SATA adapter and an external power source (which also powers the PI by the way). The issue is this: sometimes it happens, that when you move the PI or just slightly touch the cabling, that a drive would disappear from the system, to suddenly reappear, as if it was plugged out and immediatly plugged in again. This of course registeres in mdadm as a failed drive, even though all data is still correct, and it could be reassembled to a fully functioning array (event counts are the same in the superblock), in fact running `mdam --assemble --force /dev/md127 <devices>` puts the array back in its normal running state (If event counts still match on all the disks). Only problem arises if this was to happen during a write to the array, in which case the array will probably have to be rebuilt, which takes 2-3 days because of the PI-s bad IO capabilyties. This is the scenario I want to avoid whenever possible. I would like to set up mdadm in a way that it automatically puts an array into read-only mode when a drive is failing, or being forcefully removed, or when a drive is missing, to maximaize the chances of a successfull reassembly without a rebuild (since the data is still there and in tact, the drives arent dead, its just a bad cabling,which I cant fix to a 100% right now) I've written a script, and set mdadm up to call it with --monitor: ``` #!/bin/bash logfile="/home/ganter/temp/mdadmEvents.log" echo ".--==== $(date) ====--." >> "$logfile" echo "$@" >> "$logfile" case "$1" in "Fail") echo "sudo mdadm --readonly $2" 2>&1 >> "$logfile" mdadm --readonly "$2" ;; "DegradedArray") echo "mdadm --readonly $2" 2>&1 >> "$logfile" mdadm --readonly "$2" ;; esac ``` but its as if the call `mdadm --readonly` gets ignored, everything else works as expected (the switch, the echo calls), showing up in the logfile, its just that the array stays in readwrite mode, which in my case is very very bad. Logging `echo "$(which mdadm)" >> "$logfile"` shows fine (/usr/bin/mdadm), so the command is found, also `echo "$(mdadm -D /dev/md127)" >> "$logfile"` works the same as if run from terminal, echo `"$(whoami)" >> "$logfile"` says I'm root. I really don't understand what could be wrong here, is mdadm set up to somehow filter and ignore calling itself like this from the monitoring program for some reason? Or am I missing something. Running the script manually from the command line passing arguments like so: `script.sh Fail /dev/md127` works just fine, the array switches to read only mode. No amount of google-ing helped me in this regard, I didn't find any questions regarding this topic anywhere, this mailing list is my last hope. Any advice is appreciated :) I'm currently not running the system on the PI, all of the above happened on an Arch Linux distro with KDE desktop, if that counts in any way. Best regards, thank you for your time