DIVULGAÇÃO COMPLETA: Os scipt / comandos presentes nesta resposta não são meus, mas sim o trabalho de J. D. G. Leaver. Eles foram originados de post de blog em seu site .
NB:
- Isso só informará números precisos dos SSDs da Samsung
- Você precisa ter
smartctl
installed
Método 1:
Aqui está um pequeno script que lhe permitirá monitorar o TBW do seu SSD, juntamente com algumas outras informações:
#!/bin/bash
#######################################
# Variables #
#######################################
SSD_DEVICE="/dev/sda"
ON_TIME_TAG="Power_On_Hours"
WEAR_COUNT_TAG="Wear_Leveling_Count"
LBAS_WRITTEN_TAG="Total_LBAs_Written"
LBA_SIZE=512 # Value in bytes
BYTES_PER_MB=1048576
BYTES_PER_GB=1073741824
BYTES_PER_TB=1099511627776
#######################################
# Get total data written... #
#######################################
# Get SMART attributes
SMART_INFO=$(sudo /usr/sbin/smartctl -A "$SSD_DEVICE")
# Extract required attributes
ON_TIME=$(echo "$SMART_INFO" | grep "$ON_TIME_TAG" | awk '{print }')
WEAR_COUNT=$(echo "$SMART_INFO" | grep "$WEAR_COUNT_TAG" | awk '{print }' | sed 's/^0*//')
LBAS_WRITTEN=$(echo "$SMART_INFO" | grep "$LBAS_WRITTEN_TAG" | awk '{print }')
# Convert LBAs -> bytes
BYTES_WRITTEN=$(echo "$LBAS_WRITTEN * $LBA_SIZE" | bc)
MB_WRITTEN=$(echo "scale=3; $BYTES_WRITTEN / $BYTES_PER_MB" | bc)
GB_WRITTEN=$(echo "scale=3; $BYTES_WRITTEN / $BYTES_PER_GB" | bc)
TB_WRITTEN=$(echo "scale=3; $BYTES_WRITTEN / $BYTES_PER_TB" | bc)
# Output results...
echo "------------------------------"
echo " SSD Status: $SSD_DEVICE"
echo "------------------------------"
echo " On time: $(echo $ON_TIME | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta') hr"
echo "------------------------------"
echo " Data written:"
echo " MB: $(echo $MB_WRITTEN | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
echo " GB: $(echo $GB_WRITTEN | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
echo " TB: $(echo $TB_WRITTEN | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
echo "------------------------------"
echo " Mean write rate:"
echo " MB/hr: $(echo "scale=3; $MB_WRITTEN / $ON_TIME" | bc | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
echo "------------------------------"
echo " Drive health: ${WEAR_COUNT} %"
echo "------------------------------"
Aqui está a amostra da saída:
------------------------------
SSD Status: /dev/sda
------------------------------
On time: 2 hr
------------------------------
Data written:
MB: 25,098.917
GB: 24.510
TB: .023
------------------------------
Mean write rate:
MB/hr: 12,549.458
------------------------------
Drive health: 100 %
------------------------------
Esses dados são precisos, pois acabei de instalar meu novo 850 Pro.
Método 2:
Alternativamente, aqui está um one-liner para obter apenas o TBW:
echo "GB Written: $(echo "scale=3; $(sudo /usr/sbin/smartctl -A /dev/sda | grep "Total_LBAs_Written" | awk '{print }') * 512 / 1073741824" | bc | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"