commit:     7b805055ce3b1f211ae64905d2ee7d8898e880fd
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 20 19:29:35 2015 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Sep 20 19:29:35 2015 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=7b805055

Further ZFS boot improvements

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

 defaults/initrd.scripts | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 9c0c290..d1bb0bc 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1034,10 +1034,22 @@ startVolumes() {
                elif [ -z "${ZFS_POOL}" ]
                then
                        bad_msg "Please boot with root=ZFS=\$DATASET"
+               # startVolumes is called twice for LUKS assembly.
+               # Devices are not accessed until mount, so become a no-op.
+               # We fall through from the waitForZFS call rather than stopping
+               # sooner so that initramfs archives where the zpool.cache file
+               # has been included are protected against races.
+               elif [ -f /etc/zfs/zpool.cache ]
+               then
+                       :
                elif /sbin/zpool import -f -N -o readonly=on "${ZFS_POOL}" 2>&1 
>/dev/null
                then
                        mkdir -p /tmp/zfs
-                       mount -o ro,zfsutil -t zfs "${REAL_ROOT#*=}" /tmp/zfs
+                       /sbin/mount.zfs -o ro,zfsutil "${REAL_ROOT#*=}" 
/tmp/zfs 2>&1 >/dev/null
+                       if [ $? -ne 0 ]
+                               bad_msg "Failed to mount ${REAL_ROOT#*=}"
+                               return 1
+                       fi
 
                        # Copy important files to /etc/zfs
                        for i in zpool.cache zdev.conf

Reply via email to