Last active
          November 7, 2024 16:17 
        
      - 
      
- 
        Save killerbees19/332553fc18be2fcb089c07682079a9d7 to your computer and use it in GitHub Desktop. 
    TrueNAS CORE: Weekly selective S.M.A.R.T. test of 1/4 of all LBAs on all HDDs
  
        
  
    
      This file contains hidden or 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/sh | |
| status=0 | |
| if [ "$#" -lt 1 ] | |
| then | |
| week=$((($(date +%-d) + 6) / 7)) | |
| else | |
| week=$1 | |
| fi | |
| if [ "$week" -lt 5 ] | |
| then | |
| for disk in /dev/ada? | |
| do | |
| if [ -e "$disk" ] | |
| then | |
| lba=$(($(camcontrol identify "$disk" | grep '^LBA48' | grep -Eo '[0-9]+ sectors' | cut -d ' ' -f 1) / 4)) | |
| smartctl -t "select,$((lba * (week - 1)))-$((lba * week - 1))" "$disk" || status=1 | |
| fi | |
| done | |
| fi | |
| if [ "$status" -ne 0 ] | |
| then | |
| echo "ERROR: smartctl failed!" >&2 | |
| fi | |
| exit "$status" | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment