zfsonlinux / pkg-zfs

Native ZFS packaging for Debian and Ubuntu
https://launchpad.net/~zfs-native/+archive/daily
308 stars 55 forks source link

zfs-initramfs fails to run local scripts in wheezy dailies #109

Closed jgoerzen closed 10 years ago

jgoerzen commented 10 years ago

@FransUrbo , I think this will be of interest to you.

In the older zfs-initramfs, we see this, in /usr/share/initramfs-tools/scripts/zfs:

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

...

mountroot()
{
        pre_mountroot

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

etc.

Then, at some point, it changed to:

        if type run_scripts > /dev/null 2>&1 ; then
                [ "$quiet" != "y" ] && $log_begin_msg "Running /scripts/local-top"
                run_scripts /scripts/local-top
                [ "$quiet" != "y" ] && $log_end_msg
        fi

Note: run_scripts is a function, so this test is going to fail. This code was in zfs-initramfs 0.6.3-0.7~g0ad85e~wheezy. I cannot find that commit in this repo, however.

Then, it got worse:

pre_mountroot()
{
        if type run_scripts > /dev/null 2>&1 && [ -f "/scripts/local-top" ]
        then
                [ "$quiet" != "y" ] && $log_begin_msg "Running /scripts/local-top"
                run_scripts /scripts/local-top
                [ "$quiet" != "y" ] && $log_end_msg
        fi

/scripts/local-top is always a directory, and -f will always fail on it. I have no idea what this gratuitous test is intended to do, since it seems to be testing things that are always the same, but it has the effect of breaking resume from suspend, LVM, encrypted root, and just about everything else in the initramfs. It's from 0.6.3-0.12~ga77c4c~wheezy.

FransUrbo commented 10 years ago

Try this:

Extract the initrd:

mkdir /tmp/initrd
cd /tmp/initrd
zcat /boot/initrd.img-`uname -r` | cpio -i

Then create a test script like so:

#!/tmp/initrd/bin/sh

. /tmp/initrd/scripts/functions

if type run_scripts > /dev/null 2>&1 ; then
    echo run_scripts exist
else
    echo no run_scripts
fi

and run it:

debian:/tmp/initrd# /tmp/test 
run_scripts exist

The second one (the -f part) is valid though. Fixing...

FransUrbo commented 10 years ago

Considering this fixed in version 0.6.3-0.13~ga77c4c~wheezy. Please reopen if not...