From 98b213a11041af39b39473906b595290e2a4e2f9 Mon Sep 17 00:00:00 2001 From: Svein Ove Aas Date: Wed, 13 Jul 2016 01:18:48 +0100 Subject: [PATCH] zfs: Keep trying root import until it works Works around #11003. --- nixos/modules/tasks/filesystems/zfs.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix index 05fd160f20b7..3149c860f301 100644 --- a/nixos/modules/tasks/filesystems/zfs.nix +++ b/nixos/modules/tasks/filesystems/zfs.nix @@ -247,8 +247,19 @@ in esac done ''] ++ (map (pool: '' - echo "importing root ZFS pool \"${pool}\"..." - zpool import -d ${cfgZfs.devNodes} -N $ZFS_FORCE "${pool}" + echo -n "importing root ZFS pool \"${pool}\"..." + trial=0 + until msg="$(zpool import -d ${cfgZfs.devNodes} -N $ZFS_FORCE '${pool}' 2>&1)"; do + sleep 0.25 + echo -n . + trial=$(($trial + 1)) + if [[ $trial -eq 60 ]]; then + echo + echo "$msg" + break + fi + done + echo '') rootPools)); };