You are not logged in.

#1 2009-03-24 15:08:03

Arkane
Member
From: Switzerland
Registered: 2008-02-18
Posts: 263

[SOLVED] Initcpio and rootdelay

So here's the situation: I have setup my netbook on an LVM logical volume, part of which resides on an external SD card.

The card takes a few seconds to be detected, which means that the normal boot sequence will not see it early enough and will fail to activate the LVM volume (and, of course, won't be able to boot). Simply passing "rootdelay=..." at boot doesn't help because the delay is only waited on at the beginning of the filesystems hook, by which point the LVM hook must obviously already have run.

So I wrote a simple "delay" hook that allows inserting the rootdelay at an arbitrary point in the hooks sequence (the code is basically copied from the significant part of the filesystems hook):

# /lib/initcpio/hooks/delay
run_hook ()
{
    #If we have a rootdelay, wait for it and unset it.
    if [ -n "${rootdelay}" ]; then
        msg -n "Wating for devices to settle..."
        /bin/sleep "${rootdelay}"
        msg "done."
        export rootdelay=0
    fi
}
# /lib/initcpio/install/delay
install ()
{
    MODULES=""
    BINARIES=""
    FILES=""
    SCRIPT="delay"
}

help ()
{
cat<<HELPEOF
  This hook waits for a delay specified by the rootdelay parameter 
  to the kernel before transferring control to the next hook.
HELPEOF
}

First question is: did I miss another obvious solution ?

As for the second question: unless I'm mistaken, when the filesystems hook waits for the rootdelay, it also somehow "unsets" it so that the initscripts won't wait for it again before mounting the root fs. My custom hook doesn't do that even though its code is copied straigt from /lib/initcpio/hooks/filesystems.

Could anyone explain how the filesystems hook does this, and what I need to modify in my hook to get the same behavior?

Last edited by Arkane (2009-03-24 15:39:49)


What does not kill you will hurt a lot.

Offline

#2 2009-03-24 15:26:03

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: [SOLVED] Initcpio and rootdelay

there already is a rootdelay clause in the init script in the intial ramfs (check /lib/initcpio/init). Just specifying "rootdelay=x" should work... no need for the hook, even though i like how you did it smile


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#3 2009-03-24 15:39:10

Arkane
Member
From: Switzerland
Registered: 2008-02-18
Posts: 263

Re: [SOLVED] Initcpio and rootdelay

Like I said, the way the rootdelay is normally handled doesn't work in my case because I need to delay to be applied before the LVM hook is run.

However, reading /lib/initcpio/init showed me how to solve my problem: I also needed to modify the kinit_params variable. This version works as intended:

# /lib/initcpio/hooks/delay
run_hook ()
{
    #If we have a rootdelay, wait for it and unset it.
    if [ -n "${rootdelay}" ]; then
        msg -n "Wating for devices to settle..."
        /bin/sleep "${rootdelay}"
        msg "done."
        export rootdelay=0
        export kinit_params="$kinit_params rootdelay=0"
    fi
}

Thanks!


What does not kill you will hurt a lot.

Offline

#4 2009-03-24 18:14:13

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: [SOLVED] Initcpio and rootdelay

ah sorry. Missed that part about it needing to run before the lvm hook.
Glad I could point you in a helpful direction...


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

Board footer

Powered by FluxBB