-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmr-check.sh
executable file
·218 lines (192 loc) · 9.89 KB
/
smr-check.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/bash
# Table column widths
DeviceWidth=7
ModelWidth=15
SerialWidth=20
# Gather drive information and populate arrays
midclt call disk.query | jq -S '.[] | {devname: .devname, model: .model, serial: .serial}' > tmp.json
declare -a "Device=($(<tmp.json jq -r '.devname | @sh'))"
declare -a "Model=($(<tmp.json jq -r '.model | @sh'))"
declare -a "Serial=($(<tmp.json jq -r '.serial | @sh'))"
rm tmp.json
# Detection engine
# $1 = Name of array
# $2 = Any character to trigger silent mode
function DetectSMR() {
# Initialise
name=$1[@]
SMR=("${!name}")
unset TMP
# For each drive
for ((i=0;i<${#Device[@]};i++)); do
# Is this manufacturer prefix in the model name?
if [[ "${Model[$i]:0:6}" == *"${SMR[0]}"* ]]; then
# If so, add the trimmed model name to a temporary array
TMP[$i]="${Model[$i]#*" "}"
TMP[$i]="${TMP[$i]%%-*}"
# Is this string in the trimmed model name (usually a suffix)?
if [[ "${TMP[$i]}" == *"${SMR[-1]}"* ]]; then
for ((j=1;j<$((${#SMR[@]}-1));j++)); do
# Is this number in the trimmed model name?
if [[ "${TMP[$i]}" == *"${SMR[j]}"* ]]; then
if [[ -z "$2" ]]; then
printf "$fmt" "${Device[$i]}" "${TMP[$i]}" "${Serial[$i]}"
else
f=1
fi
fi
done
fi
fi
done
}
# The SMR database is made up of a number of arrays (sorted by suffix below)
#
# References:
# 1. https://www.truenas.com/community/resources/list-of-known-smr-drives.141/
# 2. https://nascompares.com/answer/list-of-wd-cmr-and-smr-hard-drives-hdd/
# 3. https://hddscan.com/blog/2020/hdd-wd-smr.html
# 4. https://www.seagate.com/files/www-content/datasheets/pdfs/skyhawk-3-5-hdd-DS1902-15M-2103US-en_US.pdf
# 5. https://www.seagate.com/www-content/datasheets/pdfs/skyhawk-3-5-hdd-DS1902-15-2009GB-en_AS.pdf
# 6. https://www.seagate.com/www-content/datasheets/pdfs/barracuda-2-5-DS1907-3-2005GB-en_AU.pdf
# 7. https://gutendata.de/portfolio-item/how-to-shoose-hard-drive-introduction-in-magnetic-recording-technology-that-maybe-you-heard-on-pmr-cmr-and-epmr-smr-hamr-and-mamr-tdmr-and-bpmr/
# 8. https://documents.westerndigital.com/content/dam/doc-library/en_us/assets/public/western-digital/product/data-center-drives/ultrastar-dc-hc600-series/data-sheet-ultrastar-dc-hc620.pdf
# 9. https://documents.westerndigital.com/content/dam/doc-library/en_us/assets/public/western-digital/product/data-center-drives/ultrastar-dc-hc600-series/data-sheet-ultrastar-dc-hc650.pdf
# Western Digital
WD01=("WDC WD" "40" "60" "EDAZ") #3 WD Elements(3.5) 4TB 6TB
WD02=("WDC WD" "20" "30" "40" "60" "EFAX") #1 WD Red(3.5) 2TB 3TB 4TB 6TB
WD03=("WDC WD" "40" "60" "EMAZ") #3 #7 WD Elements/MyBook/Easystore(3.5) 6TB
WD04=("WDC WD" "20" "30" "40" "60" "EZAZ") #1 #7 WD Blue/Elements(3.5) 2TB 3TB 4TB 6TB
WD05=("WDC WD" "5000" "LPSX") #2 WD Black(2.5) 500GB
WD06=("WDC WD" "9000" "LPZX") #1 WD Blue(2.5) 900GB
WD07=("WDC WD" "40" "50" "NDZM") #7 WD ArmorATD/MyPassport/G-DRIVE(2.5) 4TB 5TB
WD08=("WDC WD" "40" "50" "NDZW") #7 WD MyPassport(2.5) 4TB 5TB
WD09=("WDC WD" "30" "NMRW") #7 WD Easystore(2.5) 3TB
WD10=("WDC WD" "40" "NMZM") #7 WD ArmorATD/MyPassport/G-DRIVE(2.5) 4TB
WD11=("WDC WD" "30" "40" "50" "NMZW") #7 WD P10/Elements/Easystore/PS4/Xbox(2.5) 4TB
WD12=("WDC WD" "40" "NPZZ") #3 WD Blue(2.5) 4TB
WD13=("WDC WD" "10" "20" "SDZM") #7 WD MyPassport(2.5) 1TB 2TB
WD14=("WDC WD" "10" "20" "SMZM") #7 WD ArmorATD/G-DRIVE(2.5) 1TB 2TB
WD15=("WDC WD" "10" "20" "SDZW") #7 WD MyPassport(2.5) 1TB 2TB
WD16=("WDC WD" "10" "20" "SMZW") #7 WD P10/Easystore/Elements(2.5) 2TB
WD17=("WDC WD" "10" "SPSX") #1 WD Black(2.5) 1TB
WD18=("WDC WD" "10" "SPWX") #1 WD Blue(2.5) 1TB
WD19=("WDC WD" "10" "20" "SPZX") #1 WD Blue(2.5) 1TB 2TB
# Hitachi Global Storage Technologies (now Western Digital)
HGST01=("HSH72" "1414" "1415" "AL42M0") #7 #8 Ultrastar HC620(3.5) 14TB 15TB
HGST02=("HSH72" "1414" "1415" "AL42M4") #7 #8 Ultrastar HC620(3.5) 14TB 15TB
HGST03=("HSH72" "1414" "1415" "AL52M0") #7 #8 Ultrastar HC620(3.5) 14TB 15TB
HGST04=("HSH72" "1414" "1415" "AL52M4") #7 #8 Ultrastar HC620(3.5) 14TB 15TB
HGST05=("HSH72" "1414" "1415" "ALE6M0") #7 #8 Ultrastar HC620(3.5) 14TB 15TB
HGST06=("HSH72" "1414" "1415" "ALE6M4") #7 #8 Ultrastar HC620(3.5) 14TB 15TB
HGST07=("HSH72" "1414" "1415" "ALN6M0") #7 #8 Ultrastar HC620(3.5) 14TB 15TB
HGST08=("HSH72" "1414" "1415" "ALN6M4") #7 #8 Ultrastar HC620(3.5) 14TB 15TB
HGST09=("WSH72" "2020" "ALN6L1") #7 #9 Ultrastar HC650(3.5) 20TB
HGST10=("WSH72" "2020" "ALN6L4") #7 #9 Ultrastar HC650(3.5) 20TB
HGST11=("WSH72" "2020" "ALN6L5") #7 #9 Ultrastar HC650(3.5) 20TB
HGST12=("WSH72" "2020" "AL4201") #7 #9 Ultrastar HC650(3.5) 20TB
HGST13=("WSH72" "2020" "AL4204") #7 #9 Ultrastar HC650(3.5) 20TB
HGST14=("WSH72" "2020" "AL4205") #7 #9 Ultrastar HC650(3.5) 20TB
# Seagate
ST01=("ST" "6000" "8000" "AS0002") #1 Archive(3.5) 6TB 8TB
ST02=("ST" "8000" "AS0003") #1 Exos (3.5) 8TB
ST03=("ST" "5000" "AS0011") #1 Archive(3.5) 5TB
ST04=("ST" "4000" "5000" "DM000") #1 #7 Desktop/Expansion(3.5) 4TB 5TB
ST05=("ST" "5000" "6000" "DM003") #1 #7 Barracuda/Expansion/BackupoPlus(3.5) 5TB 6TB
ST06=("ST" "4000" "8000" "DM004") #1 #7 Barracuda/Expansion/LaCie(3.5) 4TB 8TB
ST07=("ST" "2000" "DM005") #1 Barracuda(3.5) 4TB 2TB
ST08=("ST" "3000" "DM007") #1 Barracuda(3.5) 3TB
ST09=("ST" "2000" "DM008") #1 Barracuda(3.5) 2TB
ST10=("ST" "500" "DM009") #7 Barracuda(3.5) 500GB
ST11=("ST" "5000" "LM000") #1 #6 #7 Barracuda/BackupPlus/Expansion/LaCie/Portable/Xbox(2.5) 5TB
ST12=("ST" "2000" "LM007") #7 BackupPlus/Expansion/LaCie/Portable/PS/Xbox/DJI(2.5) 2TB
ST13=("ST" "2000" "LM010") #7 LaCie/BackupPlus(2.5) 2TB
ST14=("ST" "2000" "LM015") #1 #6 Barracuda/Xbox(2.5) 2TB
ST15=("ST" "3000" "4000" "LM024") #1 #6 #7 Barracuda/BackupPlus/ExpaPS4/nsion/LaCie/Portable/PS4/Xbox(2.5) 3TB 4TB
ST16=("ST" "500" "LM030") #6 Barracuda(2.5) 500GB
ST17=("ST" "500" "LM034") #6 Barracuda(2.5) 500GB
ST18=("ST" "1000" "LM035") #7 BackupPlus/Expansion/LaCie/Portable/Chromebook/Duet/Joy(2.5) 1TB
ST19=("ST" "1000" "LM038") #7 LaCie/BackupPlus(2.5) 1TB
ST20=("ST" "1000" "LM048") #1 #6 Barracuda(2.5) 1TB
ST21=("ST" "1000" "LM049") #6 Barracuda(2.5) 1TB
ST22=("ST" "2000" "LX001") #7 FireCuda(2.5) 2TB
ST23=("ST" "1000" "LX015") #7 FireCuda(2.5) 1TB
ST24=("ST" "500" "LX025") #7 FireCuda(2.5) 500GB
ST25=("ST" "8000" "VX002") #2 #4 Skyhawk(3.5) 8TB
ST26=("ST" "4000" "VX005") #2 #4 Skyhawk(3.5) 4TB
ST27=("ST" "2000" "VX007") #2 Skyhawk(3.5) 2TB
ST28=("ST" "1000" "8000" "VX008") #1,#2 Skyhawk(3.5) 1TB 8TB
ST29=("ST" "6000" "VX010") #2 Skyhawk(3.5) 6TB
ST30=("ST" "6000" "VX011") #2 #4 Skyhawk(3.5) 6TB
ST31=("ST" "2000" "VX012") #2 #4 Skyhawk(3.5) 2TB
ST32=("ST" "4000" "VX013") #2 #5 Skyhawk(3.5 UK) 4TB
ST33=("ST" "2000" "VX015") #2 #5 Skyhawk(3.5 UK) 2TB
ST34=("ST" "3000" "VX016") #2 Skyhawk(3.5) 3TB
ST35=("ST" "3000" "VX017") #2 Skyhawk(3.5) 3TB
# Toshiba
TO01=("DT02" "400" "600" "ABA") #1 #7 DT02(3.5) 4TB 6TB
TO02=("MQ04" "200" "ABD") #1 #7 MQ04(2.5) 2TB
TO03=("MQ04" "100" "ABF") #1 #7 MQ04(2.5) 1TB
TO04=("MQ04" "400" "UBB") #7 Canvio(2.5) 4TB
TO05=("MQ04" "200" "UBD") #7 Canvio(2.5) 2TB
TO06=("MQ04" "100" "UBF") #7 Canvio(2.5) 1TB
TO07=("HDWC" "360" "EK3JB") #7 Canvio(3.5) 6TB
TO08=("HDWD" "240" "260" "UZSVA") #1 #7 P300(3.5) 4TB 6TB
TO09=("HDWL" "110" "120" "EZSTA") #1 #7 L200(2.5) 1TB 2TB
TO10=("HDWL" "110" "120" "UZSVA") #1 #7 L200(2.5) 1TB 2TB
# To test this script when you have no SMR drives, configure and temporarily uncomment one of the the TEST arrays below with a valid CMR drives on your system.
# TEST=("WDC WD" "30" "EFRX")
# TEST=("ST" "6000" "VN0041")
# Now uncomment the TEST lines below (there should be two of them), and run the script. Remeber to comment oall TEST lines again when you've finished.
# Quiet detection phase. If an SMR drive is detected flag f will be set.
f=0
# Detect Western Digital SMR drives
for k in {01..19}; do
DetectSMR WD"$k" q
done
# Detect HGST SMR drives
for k in {01..14}; do
DetectSMR HGST"$k" q
done
# Detect Seagate SMR drives
for k in {01..35}; do
DetectSMR ST"$k" q
done
# Detect Toshiba SMR drives
for k in {01..10}; do
DetectSMR TO"$k" q
done
# DetectSMR TEST q
# If the flag f is still unset, no SMR drive was detected. :)
if [[ "$f" == 0 ]]; then
echo
echo -e "\e[1;32mNo known SMR drives detected. That's a good sign, but it isn't a guarantee. Double-check using other means.\e[0m"
echo
else
# otherwise, one or more SMR drives were detected so diplay all SMR drives in a table :(
echo
echo -e "\e[1;31mKnown SMR drive(s) detected.\e[0m"
echo
fmt="%${DeviceWidth}s | %${ModelWidth}s | %${SerialWidth}s |\n"
printf "$fmt" "Device" "Model" "Serial Number"
separator=$(printf "%-$((DeviceWidth+ModelWidth+SerialWidth+8))s" "-")
echo "${separator// /-}"
# Detect Western Digital SMR drives
for k in {01..19}; do
DetectSMR WD"$k"
done
# Detect HGST SMR drives
for k in {01..14}; do
DetectSMR HGST"$k"
done
# Detect Seagate SMR drives
for k in {01..35}; do
DetectSMR ST"$k"
done
# Detect Toshiba SMR drives
for k in {01..10}; do
DetectSMR TO"$k"
done
# DetectSMR TEST
echo
fi