alias writes='_(){ (($#<1))||[[ "${1}" =~ ^- ]]&&echo "Usage: writes <drive eg. /dev/sdb>"&&return 1;local drive="${1}";[[ ! -e "${drive}" ]]&&echo "Device (${drive}) not found."&&return 1;smrt=$(sudo smartctl -a "${drive}");grep -iEq "unsupported"<<<"${smrt}"&&echo "Error: Not a smart tools capable SSD."&&return 1;sector_sz=$(awk "/^Sector Size:/{gsub(/[^0-9]/,\"\",\$3);print \$3}" <<< "${smrt}");lbas=$(awk "/Total_LBAs_Written/{print \$10}" <<< "${smrt}");if [[ -n "${lbas}" ]];then writes=$(echo "scale=10;(${lbas}*${sector_sz})/1099511627776"|bc);else giga=$(awk "/Lifetime_Writes_GiB/{print \$10}" <<< "${smrt}");if [[ -n "${giga}" ]];then writes=$(echo "scale=10;(${giga}*1.073741824)/1000"|bc);else tlc32=$(awk "/TLC_Writes_32MiB/{print \$10}" <<< "${smrt}");[[ -z ${tlc32} ]]&&echo "Error - Could not find write data for drive ($drive)."&&return 1;writes=$(echo "scale=10;((${tlc32}*32*1.073741824)/1000)/1000"|bc);fi;fi;printf "Total writes for drive %s: %.2f TB\n" ${drive} ${writes};};_'
Tuesday, October 15, 2019
writes - Print HD Writes
The following alias prints HD writes for a hard drive in TB.
Get the lastest on GitHub
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment