Created
April 2, 2015 14:30
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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