[Pkg-cryptsetup-devel] Proposed patch to cryptroot script

David Härdeman david at hardeman.nu
Wed Nov 28 09:42:33 UTC 2007


On Fri, November 23, 2007 16:32, Swâmi Petaramesh wrote:
> Jonas wrote:
>> As David pointed out, the 'rootdelay' parameter to initramfs already
>> does what your patch proposes. It waits for the root device to be
>> available.
>
> No it does not !
>
> Because in the current setup rootdelay is used only AFTER the encrypted
> device has been activated : It waits from the final root device to
> become available, but it does *NOT* wait for the encryption
> "host device" to be available before trying to activate it.

What do you base that assertion on?

The Debian udev package contains udev-0.114/extra/initramfs.premount with
these lines:

  udevtrigger
  udevsettle || true

  # If the rootdelay parameter has been set, we wait a bit for devices
  # like usb/firewire disks to settle.
  if [ "$ROOTDELAY" ]; then
    if [ -x /sbin/usplash_write ]; then
      /sbin/usplash_write "TIMEOUT $(($ROOTDELAY + 5))"
    fi
    sleep $ROOTDELAY
    if [ -x /sbin/usplash_write ]; then
      /sbin/usplash_write "TIMEOUT 15"
    fi
  fi

That file is installed as
/usr/share/initramfs-tools/scripts/init-premount/udev.

Now, turning to initramfs-tools, the main script is "init" which contains
these lines (starting at 153):

  run_scripts /scripts/init-top

  maybe_break modules
  log_begin_msg "Loading essential drivers..."
  load_modules
  log_end_msg

  maybe_break premount
  [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-premount"
  run_scripts /scripts/init-premount
  [ "$quiet" != "y" ] && log_end_msg

  maybe_break mount
  log_begin_msg "Mounting root file system..."
  . /scripts/${BOOT}
  parse_numeric ${ROOT}
  mountroot
  log_end_msg

and also (before that snippet), these lines:

  export ROOTDELAY=
  ...
  for x in $(cat /proc/cmdline); do
    case $x in
      ...
      rootdelay=*)
        ROOTDELAY="${x#rootdelay=}"
        case ${ROOTDELAY} in
          *[![:digit:].]*)
            ROOTDELAY=
            ;;
        esac
      ;;
  ...

So in essence....during boot initramfs-tools runs init-top, init-premount
and then mountroot (which runs local-top and local-premount).

Cryptsetups initramfs script is installed in local-top, meaning that the
udev script runs before the initramfs script.

As seen above, the udev script has support for the rootdelay parameter.

Have you tried it? Does it not work? If so, could you please try to debug
the boot process and see if you can find out why udev is not triggering
the rootdelay sleep?

-- 
David Härdeman




More information about the Pkg-cryptsetup-devel mailing list