Skip to content

Instantly share code, notes, and snippets.

@dklassen
Last active September 4, 2015 19:57
Show Gist options
  • Save dklassen/8a22f40dc41f320172e9 to your computer and use it in GitHub Desktop.
Save dklassen/8a22f40dc41f320172e9 to your computer and use it in GitHub Desktop.
Failed drives Script WIP

ls -l /dev/disk/by-uuid

for i in /dev/sd{a..m}; do result=$(sudo smartctl -a $i | grep Serial\ Number); echo "$i : $result"; done

awk '/UUID/ {split($1,a,"=");print a[2];}' /etc/fstab awk '/(^|#\s+)UUID/ {split($1,a,"="); print a[2]; }' /etc/fstab

/dev/disk/by-uuid/{{insert uuid here}}

for i in $(awk '/(^|#\s+)UUID/ {split($1,a,"="); print a[2]; }' /etc/fstab); do result=$(sudo smartctl -i /dev/disk/by-uuid/$i | grep Serial | cut -d' ' -f5-20); echo UUID: "$i -> Serial: $result"; done

Class A are raided so need to get some info: /opt/MegaRAID/MegaCli/MegaCli64 -pdlist -a0 | grep 'Device Id' Reading the SMART values of the drive in RAID

The use of smartmontools enables direct access to the physical drive behind the controller, eg. for the first drive. First of all, the device id needs to be determined with the megacli tool:

megacli -pdlist -a0| grep 'Device Id’

sudo smartctl -d megaraid, -a /dev/sda

http://wiki.hetzner.de/index.php/LSI_RAID_Controller/en

https://www.thomas-krenn.com/en/wiki/Smartmontools_with_MegaRAID_Controller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment