raid-array: Fix md re-add automation
Recent versions of `mdadm` stopped accepting `/dev/disk/by-id` symlinks as the MD device: > mdadm: Value "/dev/disk/by-id/md-name-backup5" cannot be set as devname. Reason: Cannot be started from '/' or '<'. To work around this, we need a script to resolve the symlink and pass the real block device name.unifi-restore
parent
dcef009353
commit
6bc0475e89
|
@ -29,14 +29,35 @@
|
||||||
tags:
|
tags:
|
||||||
- mdadm
|
- mdadm
|
||||||
- mdadm-create
|
- mdadm-create
|
||||||
|
- name: ensure md-auto-readd script is installed
|
||||||
|
copy:
|
||||||
|
content: |+
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
main() {
|
||||||
|
md_dev=$(readlink -e /dev/disk/by-id/md-name-"$2")
|
||||||
|
if [ -z "${md_dev}" ]; then
|
||||||
|
printf 'Could not find block device for MD raid %s\n' "$2" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
exec mdadm --re-add "${md_dev}" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@" 2>&1 | logger
|
||||||
|
dest: /usr/local/libexec/md-auto-readd
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: u=rwx,go=rx
|
||||||
|
tags:
|
||||||
|
- script
|
||||||
- name: ensure raid auto re-add udev rule exists
|
- name: ensure raid auto re-add udev rule exists
|
||||||
copy:
|
copy:
|
||||||
content: >+
|
content: >+
|
||||||
ENV{ID_FS_LABEL}=="{{ md_name }}",
|
ACTION=="add",
|
||||||
ENV{ID_FS_TYPE}=="linux_raid_member",
|
ENV{ID_FS_TYPE}=="linux_raid_member",
|
||||||
ENV{ID_FS_USAGE}=="raid",
|
ENV{ID_FS_USAGE}=="raid",
|
||||||
RUN+="/usr/sbin/mdadm --re-add /dev/disk/by-id/md-name-{{ md_name }} $devnode"
|
RUN+="/usr/local/libexec/md-auto-readd $devnode $env{ID_FS_LABEL}"
|
||||||
dest: /etc/udev/rules.d/80-{{ md_name }}.rules
|
dest: /etc/udev/rules.d/80-md-auto-readd.rules
|
||||||
mode: u=rw,go=r
|
mode: u=rw,go=r
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
|
|
Loading…
Reference in New Issue