To update /etc/mdadm/mdadm.conf
after changing the RAID layout, I use the following code snippet:
( echo DEVICE partitions mdadm --examine --scan \ | sed -n \ -eN \ -e's/\n *devices=\(\/dev\/.d[a-z][0-9].*\)$/ # \1/' \ -eT \ -ep \ | sort ) >mdadm.conf.new
This script will convert the mdadm --examine --scan
output into an mdadm.conf
file. It will remove any explicit device name and keep only this raid devices which are based on harddisk partitions.