Do not import a pool that the kernel automatically imported
authorRichard Yao <ryao@cs.stonybrook.edu>
Wed, 2 May 2012 02:28:10 +0000 (22:28 -0400)
committerRichard Yao <ryao@cs.stonybrook.edu>
Wed, 2 May 2012 02:29:40 +0000 (22:29 -0400)
This works around the following upstream issue:
https://github.com/zfsonlinux/zfs/issues/714

Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu>
defaults/initrd.scripts

index a7d88e42e043455e092d6e6fa399443a1fbd6de1..c468ad4ef845c922651787193b1729d1ea7f1b86 100755 (executable)
@@ -654,7 +654,7 @@ startVolumes() {
        
        if [ "${USE_ZFS}" = '1' ]
        then
-               if [ -z "${ZFS_POOL}" ];
+               if [ -z "${ZFS_POOL}" ]
                then
                        good_msg "Importing ZFS pools"
 
@@ -667,15 +667,21 @@ startVolumes() {
                                bad_msg "Imported ZFS pools failed"
                        fi
                else
-                       good_msg "Importing ZFS pool ${ZFS_POOL}"
 
-                       /sbin/zpool import -N "${ZPOOL_FORCE}" "${ZFS_POOL}"
-
-                       if [ "$?" = '0' ]
+                       if [ "$(zpool list -H -o name ${ZFS_POOL} 2>&1)" = "$ZFS_POOL" ]
                        then
-                               good_msg "Importing ${ZFS_POOL} succeeded"
+                               good_msg "ZFS pool ${ZFS_POOL} already imported"
                        else
-                               bad_msg "Importing ${ZFS_POOL} failed"
+                               good_msg "Importing ZFS pool ${ZFS_POOL}"
+
+                               /sbin/zpool import -N "${ZPOOL_FORCE}" "${ZFS_POOL}"
+
+                               if [ "$?" = '0' ]
+                               then
+                                       good_msg "Importing ${ZFS_POOL} succeeded"
+                               else
+                                       bad_msg "Importing ${ZFS_POOL} failed"
+                               fi
                        fi
                fi
        fi