Skip to content

Instantly share code, notes, and snippets.

@StevenWolfe
Created April 2, 2015 14:30
Show Gist options
  • Save StevenWolfe/0688a7bff4f15711be1f to your computer and use it in GitHub Desktop.
Save StevenWolfe/0688a7bff4f15711be1f to your computer and use it in GitHub Desktop.
Bash script to return a list of online disks in a ZFS pool
#!/bin/bash
# Return a list of online disks for a storage pool
ONLINE=$(zpool status $1 | grep -Po "\S*(?=\s*ONLINE)")
DEVICES=()
while read -r line; do
if ! [ -b "/dev/disk/by-id/$line" ]; then
continue
fi
echo $line
done <<< "$ONLINE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment