Skip to content

Commit

Permalink
zfs need ZPOOL_IMPORT_PATH for know where search devices #47
Browse files Browse the repository at this point in the history
  • Loading branch information
szorfein committed Oct 4, 2017
1 parent d534e9a commit 14ec233
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions hooks/zfs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ dozfs() {
$CHECK_ENV && debug -d check_bin zfs spool
debug -d test -n "$1" -a -n "$2" -a -n "$3"
local _env="$1" _grp="$2" _vol="$3" _KEY _opt="$4"
local _dirs="" _dir=""
ZPOOL_IMPORT_PATH=""

local _sign _type _vdev
[ -n "$zfs" ] && CUT "_vdev" "$zfs" "," "$_grp" "${_opt:+-s}"
Expand All @@ -41,8 +43,20 @@ dozfs() {
for _dev in $(echo "$_vdev" | sed 's/:/ /g'); do
debug -d dmopen "$_dev"
done
if [ -z "$ZPOOL_IMPORT_PATH" ] ; then
_dirs="$(for _dir in $(echo /dev/disk/by-*) ; do
echo "$_dir" | grep -q /by-vdev && continue
[ ! -d "$_dir" ] && continue
echo -n "$_dir:"
done | sed 's,:$,,g')"
[ -d "/dev/disk/by-vdev" ] && ZPOOL_IMPORT_PATH="/dev/disk/by-vdev"
ZPOOL_IMPORT_PATH="$ZPOOL_IMPORT_PATH$_dirs:/dev"
[ -n "$ZPOOL_IMPORT_PATH" ] && export ZPOOL_IMPORT_PATH
fi
debug -d zpool import -f $_opt -R $newroot "$_pool"
unset ZPOOL_IMPORT_PATH
fi

if [ "$_grp" = 1 ]; then
zfs mount | grep -q "$_vol" || debug -d zfs mount -vO -a
else
Expand Down

0 comments on commit 14ec233

Please sign in to comment.