Samrtctl commands for batch testing

 for dev in /dev/sd[a-d]; do sudo smartctl -t short $dev; done

for dev in $(smartctl --scan | awk '{print $1}'); do echo "--- Report for $dev ---"; sudo smartctl -A $dev; done

for dev in /dev/sd[a-d]; do
    echo "=================================================="
    echo "DEVICE: $dev"
    # Print Model and Serial
    sudo smartctl -i $dev | grep -E "Model Family|Device Model|Serial Number"
    
    echo "--- Critical Attributes ---"
    # Show Reallocated Sectors (5), Pending (197), and UDMA CRC (199)
    sudo smartctl -A $dev | grep -E "ID#|Reallocated_Sector_Ct|Current_Pending_Sector|UDMA_CRC_Error_Count"
    
    echo "--- Latest Test Result ---"
    # Show the #1 (most recent) entry from the self-test log
    sudo smartctl -l selftest $dev | grep -A 1 "Num  Test_Description" | tail -n 1
done

for dev in /dev/sd[a-d]; do
    echo "=================================================="
    echo "DEVICE: $dev"
    
    # Identify Model, Serial, and Power On Hours
    sudo smartctl -i $dev | grep -E "Model Family|Device Model|Serial Number"
    sudo smartctl -A $dev | grep "Power_On_Hours" | awk '{print "Total Lifetime: " $10 " hours"}'
    
    echo "--- Critical Health Attributes ---"
    # ID 5: Reallocated, ID 197: Pending, ID 198: Offline Uncorrectable, ID 199: CRC Errors
    sudo smartctl -A $dev | grep -E "ID#|Reallocated_Sector_Ct|Current_Pending_Sector|Offline_Uncorrectable|UDMA_CRC_Error_Count"
    
    echo "--- Latest Test Result ---"
    sudo smartctl -l selftest $dev | grep -A 1 "Num  Test_Description" | tail -n 1
done

Popular posts from this blog

Dearpygui resizable table

Fixing DNS Resolution problems with Linux Mint 19