* [gentoo-user] Run command after root mounted ro?
@ 2011-08-09 19:30 Daniel Frey
2011-08-09 19:50 ` Florian Philipp
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Frey @ 2011-08-09 19:30 UTC (permalink / raw
To: gentoo-user
Greetings,
I discovered a possible reason for mdadm always marking my raid array as
bad on reboot. The problem is I don't know how to check for the issue.
When using root on a native mdadm raid, the kernel handles the array
state transition at shutdown, so it's not a big deal. However, it's
different when using external metadata - mdadm must be called before the
reboot.
Apparently mdadm must be called after the root filesystem is mounted
read-only. Then it can mark the array as clean and not rebuild every
single reboot.
Where do I check this? The /etc/init.d/mdadm script happens well before
root is mounted read-only.
Apparently `mdadm --wait-clean --scan` needs to be called so the
external metadata is updated correctly. If you use this command with a
native mdadm raid it does nothing, but it's critical apparently to the
health of other metadata types.
I've grepped through /etc/init.d/ and found nothing.
Dan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] Run command after root mounted ro?
2011-08-09 19:30 [gentoo-user] Run command after root mounted ro? Daniel Frey
@ 2011-08-09 19:50 ` Florian Philipp
2011-08-10 1:04 ` Daniel Frey
0 siblings, 1 reply; 4+ messages in thread
From: Florian Philipp @ 2011-08-09 19:50 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1673 bytes --]
Am 09.08.2011 21:30, schrieb Daniel Frey:
> Greetings,
>
> I discovered a possible reason for mdadm always marking my raid array as
> bad on reboot. The problem is I don't know how to check for the issue.
>
> When using root on a native mdadm raid, the kernel handles the array
> state transition at shutdown, so it's not a big deal. However, it's
> different when using external metadata - mdadm must be called before the
> reboot.
>
> Apparently mdadm must be called after the root filesystem is mounted
> read-only. Then it can mark the array as clean and not rebuild every
> single reboot.
>
> Where do I check this? The /etc/init.d/mdadm script happens well before
> root is mounted read-only.
>
> Apparently `mdadm --wait-clean --scan` needs to be called so the
> external metadata is updated correctly. If you use this command with a
> native mdadm raid it does nothing, but it's critical apparently to the
> health of other metadata types.
>
> I've grepped through /etc/init.d/ and found nothing.
>
> Dan
>
Remounting root read-only is done by an init script called mount-ro
which is started in runlevel shutdown. Try to add a custom init script
to your /etc/init.d directory with the following content:
#!/sbin/runscript
depend()
{
after mount-ro
}
start()
{
ebegin 'Shutting down mdadm'
mdadm --wait-clean --scan
eend $?
}
Add it to the runlevel with `rc-update add <your-script> shutdown` and
don't forget to mark it executable.
Disclaimer: I've not tried this (obviously) and if the script eats your
dog and wreaks your system, it is entirely your fault ;)
Hope this helps,
Florian Philipp
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Re: [gentoo-user] Run command after root mounted ro?
2011-08-09 19:50 ` Florian Philipp
@ 2011-08-10 1:04 ` Daniel Frey
2011-08-10 15:00 ` Florian Philipp
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Frey @ 2011-08-10 1:04 UTC (permalink / raw
To: gentoo-user
On 01/-10/37 11:59, Florian Philipp wrote:
> Remounting root read-only is done by an init script called mount-ro
> which is started in runlevel shutdown. Try to add a custom init script
> to your /etc/init.d directory with the following content:
>
> #!/sbin/runscript
> depend()
> {
> after mount-ro
> }
> start()
> {
> ebegin 'Shutting down mdadm'
> mdadm --wait-clean --scan
> eend $?
> }
>
> Add it to the runlevel with `rc-update add <your-script> shutdown` and
> don't forget to mark it executable.
>
> Disclaimer: I've not tried this (obviously) and if the script eats your
> dog and wreaks your system, it is entirely your fault ;)
Thanks, I tried this out, and while it does run after mounting ro, it
just hangs. I've noticed that it's supposed to be monitoring
/proc/mdstat but it was (presumably) unmounted long ago.
I guess I have to do some more experimenting.
Dan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] Run command after root mounted ro?
2011-08-10 1:04 ` Daniel Frey
@ 2011-08-10 15:00 ` Florian Philipp
0 siblings, 0 replies; 4+ messages in thread
From: Florian Philipp @ 2011-08-10 15:00 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1228 bytes --]
Am 10.08.2011 03:04, schrieb Daniel Frey:
> On 01/-10/37 11:59, Florian Philipp wrote:
>> Remounting root read-only is done by an init script called mount-ro
>> which is started in runlevel shutdown. Try to add a custom init script
>> to your /etc/init.d directory with the following content:
>>
>> #!/sbin/runscript
>> depend()
>> {
>> after mount-ro
>> }
>> start()
>> {
>> ebegin 'Shutting down mdadm'
>> mdadm --wait-clean --scan
>> eend $?
>> }
>>
>> Add it to the runlevel with `rc-update add <your-script> shutdown` and
>> don't forget to mark it executable.
>>
>> Disclaimer: I've not tried this (obviously) and if the script eats your
>> dog and wreaks your system, it is entirely your fault ;)
>
>
> Thanks, I tried this out, and while it does run after mounting ro, it
> just hangs. I've noticed that it's supposed to be monitoring
> /proc/mdstat but it was (presumably) unmounted long ago.
>
> I guess I have to do some more experimenting.
>
> Dan
>
>
>
Try remounting proc in your new init script. You have to advice mount to
not try adding it to /etc/mtab since that would obviously fail.
mount --no-mtab -t proc proc /proc
Hope this helps,
Florian Philipp
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-10 15:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-09 19:30 [gentoo-user] Run command after root mounted ro? Daniel Frey
2011-08-09 19:50 ` Florian Philipp
2011-08-10 1:04 ` Daniel Frey
2011-08-10 15:00 ` Florian Philipp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox