Thanks for the inspiration, slightly modified the scripts, works for my SSDs. I had to multiply the sector size 512 by a correction factor 65535, please check, if you need it. If not sure, compare with Windows Progs like CrystalDiskInfo, SSD-Z.
#!/bin/bash
# Usage e.g. : bash ssd-tbw.bash
# or: bash ssd-tbw.bash /dev/sdb
# or: for i in /dev/sd{a,b,c,d}; do bash ssd-tbw.bash $i;done
# Source : https://askubuntu.com/questions/865792/how-can-i-monitor-the-tbw-on-my-samsung-ssd
device=${1:-/dev/sda}
#device=${1:-/dev/sdb}
echo DEVICE : $device
#DEVICE
sudo /usr/sbin/smartctl -a $device | grep -i 'device'
# sector size 512, correction factor 64k = 65535, see line : bytes = ...
sudo smartctl -A $device |awk '
$0 ~ /Power_On_Hours/ { poh=$10; printf "%s / %d hours / %d days / %.2f years\n", $2, $10, $10 / 24, $10 / 24 / 365.25 }
$0 ~ /Total_LBAs_Written/ {
lbas=$10;
bytes=$10 * 512 * 65535;
mb= bytes / 1024^2;
gb= bytes / 1024^3;
tb= bytes / 1024^4;
printf "%s / %s / %d mb / %.1f gb / %.3f tb\n", $2, $10, mb, gb, tb
printf "mean writes per hour: / %.2f", mb/poh
}
$0 ~ /Airflow_Temperature_Cel/ { print $2 " / " $10}
$0 ~ /Wear/ { printf "%s / %d (%% health)\n", $2, int($4) }
' |
sed -e 's:/:@:' |
sed -e "s\$^\$$device @ \$" |
column -ts@
#Health only :
sudo /usr/sbin/smartctl -H $device
# wait for keyboard input, helpful if executed by launcher file
read -p "Press Enter to continue" </dev/tty
And a little launcher file for the desktop 'ssd-tbw.desktop', please edit USER etc. for your needs :
[Desktop Entry]
Version=1.0
Exec=/home/USER/ssd-tbw.bash
Name=Smartctl Script
GenericName=Smartctl Script
Comment=Smartctl Script
Encoding=UTF-8
Terminal=true
Type=Application
Categories=Application;
Name[de_DE]=Smartctl Check