Created
June 10, 2022 16:26
-
-
Save chris13524/761a981a3bde88eecd9950c4b95ca60d to your computer and use it in GitHub Desktop.
zpool status bad sectors
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
zpool status | while IFS=$'\n' read line; do | |
if [[ "$line" == *"ata-"* ]]; then | |
id=$(echo "$line" | grep -oP '(ata-[^\s]+)') | |
count=$(sudo smartctl -a /dev/disk/by-id/$id | grep Reallocated_Sector_Ct | grep -oP '(\d+)$') | |
echo "$line - bad sectors: $count" | |
else | |
echo "$line" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment