1 |
Am 09.08.2011 21:30, schrieb Daniel Frey: |
2 |
> Greetings, |
3 |
> |
4 |
> I discovered a possible reason for mdadm always marking my raid array as |
5 |
> bad on reboot. The problem is I don't know how to check for the issue. |
6 |
> |
7 |
> When using root on a native mdadm raid, the kernel handles the array |
8 |
> state transition at shutdown, so it's not a big deal. However, it's |
9 |
> different when using external metadata - mdadm must be called before the |
10 |
> reboot. |
11 |
> |
12 |
> Apparently mdadm must be called after the root filesystem is mounted |
13 |
> read-only. Then it can mark the array as clean and not rebuild every |
14 |
> single reboot. |
15 |
> |
16 |
> Where do I check this? The /etc/init.d/mdadm script happens well before |
17 |
> root is mounted read-only. |
18 |
> |
19 |
> Apparently `mdadm --wait-clean --scan` needs to be called so the |
20 |
> external metadata is updated correctly. If you use this command with a |
21 |
> native mdadm raid it does nothing, but it's critical apparently to the |
22 |
> health of other metadata types. |
23 |
> |
24 |
> I've grepped through /etc/init.d/ and found nothing. |
25 |
> |
26 |
> Dan |
27 |
> |
28 |
|
29 |
Remounting root read-only is done by an init script called mount-ro |
30 |
which is started in runlevel shutdown. Try to add a custom init script |
31 |
to your /etc/init.d directory with the following content: |
32 |
|
33 |
#!/sbin/runscript |
34 |
depend() |
35 |
{ |
36 |
after mount-ro |
37 |
} |
38 |
start() |
39 |
{ |
40 |
ebegin 'Shutting down mdadm' |
41 |
mdadm --wait-clean --scan |
42 |
eend $? |
43 |
} |
44 |
|
45 |
Add it to the runlevel with `rc-update add <your-script> shutdown` and |
46 |
don't forget to mark it executable. |
47 |
|
48 |
Disclaimer: I've not tried this (obviously) and if the script eats your |
49 |
dog and wreaks your system, it is entirely your fault ;) |
50 |
|
51 |
Hope this helps, |
52 |
Florian Philipp |