zfsonlinux / pkg-zfs

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

initramfs doesn't activate LVM volume groups before looking for zpools #102

Closed jgoerzen closed 8 years ago

jgoerzen commented 10 years ago

The situation here is an rpool atop an LVM volume group. The zfs-initramfs scripts do not properly activate LVM volume groups before probing for zpools.

The activate_vg() and udev_settle() functions in /usr/share/initramfs-tools/scripts/local-top/cryptroot are instructive. Over at http://wiki.complete.org/ConvertingToZFS#If_rpool_is_on_LVM:_initramfs_bug_workaround I have posted a workaround script people can add to local-top that will get a ZFS root pool atop LVM working. It begins with #!/bin/bash, but github seems to be mucking with that line.

PREREQ="mdadm mdrun multipath"

prereqs()
{
        echo "$PREREQ"
}

case $1 in
# get pre-requisites
prereqs)
        prereqs
        exit 0
        ;;
esac

# source for log_*_msg() functions, see LP: #272301
. /scripts/functions

#
# Helper functions
#
message()
{
        if [ -x /bin/plymouth ] && plymouth --ping; then
                plymouth message --text="$@"
        else
                echo "$@" >&2
        fi
        return 0
}

udev_settle()
{
        # Wait for udev to be ready, see https://launchpad.net/bugs/85640
        if [ -x /sbin/udevadm ]; then
                /sbin/udevadm settle --timeout=30
        elif [ -x /sbin/udevsettle ]; then
                /sbin/udevsettle --timeout=30
        fi
        return 0
}

activate_vg()
{
        # Sanity checks
        if [ ! -x /sbin/lvm ]; then
                message "jgoerzenactivatevg: lvm is not available"
                return 1
        fi

        # Detect and activate available volume groups
        /sbin/lvm vgscan
        /sbin/lvm vgchange -a y --sysinit
        return $?
}

udev_settle
activate_vg

exit 0