Update init script to allow /dev/disk/by-id import

Many people prefer to use by-id at import time instead of using
the cache file.  This can be a much better solution than the cache
file in some environments so we're adding some infrastructure to
allow it.

This functionality is disabled by default.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1929
This commit is contained in:
Turbo Fredriksson 2013-12-05 11:36:58 +00:00 committed by Brian Behlendorf
parent 90ee9ed32f
commit fc220e9ea5

View File

@ -29,6 +29,7 @@ LOCKFILE=/var/lock/zfs
ZFS="@sbindir@/zfs" ZFS="@sbindir@/zfs"
ZPOOL="@sbindir@/zpool" ZPOOL="@sbindir@/zpool"
ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache" ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache"
USE_DISK_BY_ID=0
# Source zfs configuration. # Source zfs configuration.
[ -r '/etc/default/zfs' ] && . /etc/default/zfs [ -r '/etc/default/zfs' ] && . /etc/default/zfs
@ -69,11 +70,21 @@ start()
# Import all pools described by the cache file, and then mount # Import all pools described by the cache file, and then mount
# all filesystem based on their properties. # all filesystem based on their properties.
if [ -f "$ZPOOL_CACHE" ] ; then if [ "$USE_DISK_BY_ID" -eq 1 ]; then
log_begin_msg "Importing ZFS pools"
"$ZPOOL" import -d /dev/disk/by-id -aN 2>/dev/null
ret=$?
log_end_msg $ret
[ "$ret" -eq 0 ] && POOL_IMPORTED=1
elif [ -f "$ZPOOL_CACHE" ] ; then
log_begin_msg "Importing ZFS pools" log_begin_msg "Importing ZFS pools"
"$ZPOOL" import -c "$ZPOOL_CACHE" -aN 2>/dev/null "$ZPOOL" import -c "$ZPOOL_CACHE" -aN 2>/dev/null
log_end_msg $? ret=$?
log_end_msg $ret
[ "$ret" -eq 0 ] && POOL_IMPORTED=1
fi
if [ -n "$POOL_IMPORTED" ]; then
log_begin_msg "Mounting ZFS filesystems" log_begin_msg "Mounting ZFS filesystems"
"$ZFS" mount -a "$ZFS" mount -a
log_end_msg $? log_end_msg $?