From abfd35a68e629d75b8edee7af20ab3b9d5af94f7 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Tue, 5 Nov 2024 06:52:20 -0600 Subject: [PATCH] raid-array: Create udev rules to auto re-add disks This udev rule will automatically re-add disks to the RAID array when they are connected. `mdadm --udev-rules` is supposed to be able to generate such a rule based on the `POLICY` definitions in `/etc/mdadm.conf`, but I was not able to get that to work; it always printed an empty rule file, no matter what I put in `mdadm.conf`. --- raid-array.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/raid-array.yml b/raid-array.yml index c8317f4..993510e 100644 --- a/raid-array.yml +++ b/raid-array.yml @@ -29,3 +29,22 @@ tags: - mdadm - mdadm-create + - name: ensure raid auto re-add udev rule exists + copy: + content: >+ + ENV{ID_FS_LABEL}=="{{ md_name }}", + ENV{ID_FS_TYPE}=="linux_raid_member", + ENV{ID_FS_USAGE}=="raid", + RUN+="/usr/sbin/mdadm --re-add /dev/disk/by-id/md-name-{{ md_name }} $devnode" + dest: /etc/udev/rules.d/80-{{ md_name }}.rules + mode: u=rw,go=r + owner: root + group: root + notify: + - reload udev + tags: + - udev + handlers: + - name: reload udev + command: + udevadm control --reload