mdadm/SOURCES/md-auto-readd.sh
2023-09-21 19:25:27 +00:00

18 lines
401 B
Bash

#!/usr/bin/bash
MDADM=/sbin/mdadm
DEVNAME=$1
export $(${MDADM} --examine --export ${DEVNAME})
if [ -z "${MD_UUID}" ]; then
exit 1
fi
UUID_LINK=$(readlink /dev/disk/by-id/md-uuid-${MD_UUID})
MD_DEVNAME=${UUID_LINK##*/}
export $(${MDADM} --detail --export /dev/${MD_DEVNAME})
if [ -z "${MD_METADATA}" ] ; then
exit 1
fi
${MDADM} --manage /dev/${MD_DEVNAME} --re-add ${DEVNAME} --verbose