-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtbw.sh
More file actions
38 lines (35 loc) · 1.39 KB
/
tbw.sh
File metadata and controls
38 lines (35 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# smart parameters references https://www.backblaze.com/blog/making-sense-of-ssd-smart-stats/
for drive in /dev/sd[a-z]; do
model=$(sudo smartctl -a $drive | awk -F: '/Model Family/ {print $2}' | xargs)
case "$model" in
*Intel*)
onewrite=32768
sudo smartctl --attributes $drive | awk -v devname=$drive -v onewrite=$onewrite '
$1 == "241" {
B=$10 * onewrite;
printf("%s: Attribute %d, Intel: %.2f TiB \n", devname, $1, B/1024^4, onewrite)
}'
;;
#Any other vendor. Tested on Crucial and Samsung
*)
pss=$(
sudo smartctl -a $drive | awk '
/Sector Sizes|Sector Size/ {
if ($0 ~ /logical\/physical/) {
split($0, a, /[ ,/]/);
for (i in a) if (a[i] == "physical") {print a[i-3]; break}
} else if ($0 ~ /physical/) {
split($0, a, /[ ,/]/);
for (i in a) if (a[i] == "physical") {print a[i-2]; break}
}
}'
)
sudo smartctl --attributes $drive | awk -v devname=$drive -v pss=$pss '
$1 == "241" || $1 == "246" {
B=$10 * pss;
printf("%s: Attribute %d: %.2f TiB (Physical Sector Size: %d bytes)\n", devname, $1, B/1024^4, pss)
}'
;;
esac
done