Skip to content

Instantly share code, notes, and snippets.

@likewhoa
Created August 13, 2013 00:34
Show Gist options
  • Save likewhoa/6216768 to your computer and use it in GitHub Desktop.
Save likewhoa/6216768 to your computer and use it in GitHub Desktop.
A BASH script to show the Sector Size count of drives using smartctl.
chksectorcount() {
local -a drives=(/dev/sd*)
# Iterate through array to remove partitions i.e /dev/sda1 and so on
((n_elements=${#drives[@]}, max_index=n_elements - 1))
for ((i = 0; i <= max_index; i++)); do
if [[ $(echo ${drives[i]} | grep -v '[0-9]') ]]; then
smartctl -a ${drives[i]} | grep "Sector Sizes:"|sed "s:^:${drives[i]} :"
else
unset 'drives[i]'
continue
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment