[Pkg-cryptsetup-devel] Bug#488271: Bug#488271: Bug#488271: cryptsetup: use a loop to wait for the root device

Reinhard Tartler siretart at tauware.de
Tue Jul 1 18:28:52 UTC 2008


David Härdeman <david at hardeman.nu> writes:

>>> initramfs-tools already has a rootdelay parameter which is executed
>>> before the cryptsetup initramfs script. What is the advantage of
>>> duplicating that functionality?
>>
>>the rootdelay parameter makes the initramfs loop until the root device
>>appears. It does not help the cryptsetup hook in any way.
>
> Well, unless my memory serves me wrong, it does....with a rootdelay=5,
> initramfs-tools will sleep 5 secs extra before cryptsetup gets a chance
> of executing which might be enough for the USB device to show up.

Looking at the code:

mountroot ()
{
        [ "$quiet" != "y" ] && log_begin_msg "Running
        /scripts/local-top"
        run_scripts /scripts/local-top
        [ "$quiet" != "y" ] && log_end_msg

        # If the root device hasn't shown up yet, give it a little while
        # to deal with removable devices
        if [ ! -e "${ROOT}" ] || ! /lib/udev/vol_id "${ROOT}" >/dev/null
        # 2>&1; then
                log_begin_msg "Waiting for root file system..."

                # Default delay is 180s
                if [ -z "${ROOTDELAY}" ]; then
                        slumber=180
                else
                        slumber=${ROOTDELAY}
                fi
                if [ -x /sbin/usplash_write ]; then
                        /sbin/usplash_write "TIMEOUT ${slumber}" || true
                fi

                slumber=$(( ${slumber} * 10 ))
                while [ ! -e "${ROOT}" ] || ! /lib/udev/vol_id "${ROOT}"
                >/dev/null 2>&1; do
                        /bin/sleep 0.1
                        slumber=$(( ${slumber} - 1 ))
                        [ ${slumber} -gt 0 ] || break
                done

                if [ ${slumber} -gt 0 ]; then
                        log_end_msg 0
                else
                        log_end_msg 1 || true
                fi
                if [ -x /sbin/usplash_write ]; then
                        /sbin/usplash_write "TIMEOUT 15" || true
                fi
        fi
[...]

I fear your memory indeed does serve you wrong :(


>>If the control flow reaches the point the patch adds the loop and the
>>device holding the crypted volume it will silently fail and pass
>>control to the initramfs, which itself fails after 5 minutes (by
>>default). This usually happens with slow devices like usb sticks,
>>according to bug reports in launchpad.
>>
>>I agree that it would be nice if we could re-use the functionality from
>>initramfs-tools. However it is not written in a reusable way.
>>
>> Do you see a better way solving the problem? 
>
> Yes, teach initramfs-tools to take a path as an argument to rootdelay
> and make it wait until that path appears.

If you can make the initramfs-tools maintainer refactor the code I cited
above as a function and usable for cryptsetup, I'd agree with you.

-- 
Gruesse/greetings,
Reinhard Tartler, KeyID 945348A4





More information about the Pkg-cryptsetup-devel mailing list