HDD/SSD の検品

弊宅で HDD / SSD を購入時に検品としてやっていることをまとめておく

購入

弊宅では調達基準として下記の Home Lab に書いてある通りである
要約するとエンタープライズグレードで HDD なら書き込み耐性 550TB/day 程度 SSD なら 600TBW/TB 程度の書き込み耐性があることをスペックシートで確認し購入とする。

検品

検品としては S.M.A.R.T で定義されている short テスト long テストを実行し PASS することを条件としている。
理由は、 QNAP と Synology のベンダー(代理店) が long テストを月1回の実施を推奨していること、 ArchWiki で記載の通り short はデバイスの物理的稼働や電気的問題の検出で long は全セクターをするようなので実施する。

テストを実行する デバイスが実行できる自己テストには3種類あります (どのテストもユーザデータに対して安全です):

  • Short: デバイスの問題を検出する可能性の高いテストを実行します。
  • Extended 或いは Long: このテストは short チェックと同じですが、時間制限が無く、完全なディスクサーフェス検査を行います。
  • Conveyance: デバイスの輸送中にダメージが発生したかどうかを調べます。

S.M.A.R.T. - ArchWiki

方法所要時間説明
クイック テスト短いBasic診断テスト。
拡張テスト長い詳細な診断テスト。
より正確な結果を得るには、少なくとも月に 1 回実行することをお勧めします。

SMART テストに関するよくある質問。 - Synology ナレッジセンター

  • 簡易テスト
    ディスクの電気的、機械的特性、ディスク表面のごく一部をテストします。
    所要時間は、約 1 分です。

    HDDメーカーにより異なりますが、一般的には週に1回または、2週間に1回など、定期的に実施いただくことを推奨します。

  • 完全テスト
    ディスクの電気的、機械的特性、ディスク表面全体をテストします。

    所要時間はストレージ環境によって変わりますが、テスト完了まではおよそ数時間かかります。 完全テストを選択し、テストをクリックしていただくと所要時間の目安が表示されます。

    HDDメーカーにより異なりますが、一般的には1ヶ月に1回
    または、数ヶ月に1回実施いただくことを推奨します。

Q&A|サポート|フォースメディア

作業

標準的には、ストレージサーバーの空きスロットに刺して smartctl を実行するのが一番早い

インストール
1
2
3
4
sudo apt-get update
sudo apt-get upgrade

sudo apt-get install -y smartmontools bash-completion

挿入したストレージの確認

挿入したストレージの MODEL, SERIAL が一致することを確認する

1
2
3
4
5
> lsblk -o NAME,HCTL,MODEL,SERIAL
NAME      HCTL       MODEL                SERIAL
sdg       4:0:0:0    INTEL SSDSC2KG480G8  PHYG101002PCXXXXXX  1
sdh       16:0:0:0   INTEL SSDSC2KG480G8  PHYG106602DGXXXXXX  2
sdi       12:0:0:0   INTEL SSDSC2KG480G8  PHYG1065009NXXXXXX  3

smartctl の確認

テスト完了後に確認するでも良いのだが、 smartctl long テストは容量によっては半日かかることも多いため予定時間を確認しておくべきである。そのため先に挿入時の状態を確認する。個人的には -a ですべて出し機材 DB に突っ込んでる。

Extended self-test routine に long テストにかかる時間が書いてある、今回の場合は 2分である

  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
> smartctl -a /dev/sdg
smartctl 7.3 2022-02-28 r5338 [x86_64-linux-6.8.12-11-pve] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Intel S4510/S4610/S4500/S4600 Series SSDs
Device Model:     INTEL SSDSC2KG480G8
Serial Number:    PHYG101002PCXXXXX
LU WWN Device Id: 5 5cd2e4 15324c4ec
Firmware Version: XCV10132
User Capacity:    480,103,981,056 bytes [480 GB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
TRIM Command:     Available, deterministic, zeroed
Device is:        In smartctl database 7.3/5319
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Wed Jul 16 22:31:56 2025 JST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x02) Offline data collection activity
                                        was completed without error.
                                        Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever 
                                        been run.
Total time to complete Offline 
data collection:                (   72) seconds.
Offline data collection
capabilities:                    (0x79) SMART execute Offline immediate.
                                        No Auto Offline data collection support.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        Conveyance Self-test supported.
                                        Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine 
recommended polling time:        (   1) minutes.
Extended self-test routine
recommended polling time:        (   2) minutes.
Conveyance self-test routine
recommended polling time:        (   2) minutes.
SCT capabilities:              (0x003d) SCT Status supported.
                                        SCT Error Recovery Control supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  5 Reallocated_Sector_Ct   0x0032   100   100   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       31446
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       69
170 Available_Reservd_Space 0x0033   100   100   010    Pre-fail  Always       -       0
171 Program_Fail_Count      0x0032   100   100   000    Old_age   Always       -       0
172 Erase_Fail_Count        0x0032   100   100   000    Old_age   Always       -       0
174 Unsafe_Shutdown_Count   0x0032   100   100   000    Old_age   Always       -       28
175 Power_Loss_Cap_Test     0x0033   100   100   010    Pre-fail  Always       -       2725 (69 65535)
183 SATA_Downshift_Count    0x0032   100   100   000    Old_age   Always       -       0
184 End-to-End_Error_Count  0x0033   100   100   090    Pre-fail  Always       -       0
187 Uncorrectable_Error_Cnt 0x0032   100   100   000    Old_age   Always       -       0
190 Drive_Temperature       0x0022   074   074   000    Old_age   Always       -       26 (Min/Max 19/26)
192 Unsafe_Shutdown_Count   0x0032   100   100   000    Old_age   Always       -       28
194 Temperature_Celsius     0x0022   100   100   000    Old_age   Always       -       26
197 Pending_Sector_Count    0x0012   100   100   000    Old_age   Always       -       0
199 CRC_Error_Count         0x003e   100   100   000    Old_age   Always       -       0
225 Host_Writes_32MiB       0x0032   100   100   000    Old_age   Always       -       423350
226 Workld_Media_Wear_Indic 0x0032   100   100   000    Old_age   Always       -       512
227 Workld_Host_Reads_Perc  0x0032   100   100   000    Old_age   Always       -       97
228 Workload_Minutes        0x0032   100   100   000    Old_age   Always       -       1886115
232 Available_Reservd_Space 0x0033   100   100   010    Pre-fail  Always       -       0
233 Media_Wearout_Indicator 0x0032   100   100   000    Old_age   Always       -       0
234 Thermal_Throttle_Status 0x0032   100   100   000    Old_age   Always       -       0/0
235 Power_Loss_Cap_Test     0x0033   100   100   010    Pre-fail  Always       -       2725 (69 65535)
241 Host_Writes_32MiB       0x0032   100   100   000    Old_age   Always       -       423350
242 Host_Reads_32MiB        0x0032   100   100   000    Old_age   Always       -       13626859
243 NAND_Writes_32MiB       0x0032   100   100   000    Old_age   Always       -       967128

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Completed without error       00%     31446         -

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

テストの実行

smartctl -t long /dev/sdg

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
> smartctl -t long /dev/sdg
smartctl 7.3 2022-02-28 r5338 [x86_64-linux-6.8.12-11-pve] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Extended self-test routine immediately in off-line mode".
Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 2 minutes for test to complete.
Test will complete after Wed Jul 16 22:31:24 2025 JST
Use smartctl -X to abort test.

テストの確認

smartctl -l selftest でテスト結果のみを出力できる

1
2
3
4
5
6
7
8
> smartctl -l selftest /dev/sdg
smartctl 7.3 2022-02-28 r5338 [x86_64-linux-6.8.12-11-pve] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Completed without error       00%     31446         -

Secure Erase

あとは慎重に確認し Secure Erase を実施しておくことで検品処理完了している

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
> lsblk -o NAME,HCTL,MODEL,SERIAL
NAME      HCTL       MODEL                SERIAL
sdg       4:0:0:0    INTEL SSDSC2KG480G8  PHYG101002PCXXXXXX  1
sdh       16:0:0:0   INTEL SSDSC2KG480G8  PHYG106602DGXXXXXX  2
sdi       12:0:0:0   INTEL SSDSC2KG480G8  PHYG1065009NXXXXXX  3

> hdparm -I /dev/sdX | grep -A8 -E 'Security:'
Security:
        Master password revision code = 65534
                supported
        not     enabled
        not     locked
        not     frozen
        not     expired: security count
                supported: enhanced erase
        2min for SECURITY ERASE UNIT. 2min for ENHANCED SECURITY ERASE UNIT.

Secure Erase を利用するには hdparm の結果が not frozen である必要があります。
今回の SSD では enhanced erase にも対応し消去時間は 2min であることが確認できました。

Important
この後の手順を実行するとデータは復元出来ません

P@ssW0rd は Secure Erase が完了すると NULL に設定されるため、作業終了まで使います

1
2
3
4
5
> hdparm --user-master u --security-set-pass P@ssW0rd /dev/sdX
security_password: "P@ssW0rd"

/dev/sdX:
 Issuing SECURITY_SET_PASS command, password="P@ssW0rd", user=user, mode=high

コマンド実行後、再度確認すると not enabled から enabled へ変更さたことが確認できる。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  > hdparm -I /dev/sdX | grep -A8 -E 'Security:'
  Security:
          Master password revision code = 65534
                  supported
+                 enabled
          not     locked
          not     frozen
          not     expired: security count
                  supported: enhanced erase
          Security level high
          2min for SECURITY ERASE UNIT. 2min for ENHANCED SECURITY ERASE UNIT.

次のコマンド完全にデータを消去する。 enhanced に対応しているため --security-erase-enhanced を利用する

1
2
3
4
5
> hdparm --user-master u --security-erase-enhanced P@ssW0rd /dev/sdX
security_password: "P@ssW0rd"

/dev/sdX:
 Issuing SECURITY_ERASE command, password="P@ssW0rd", user=user

完了すると下記のように変化し not enabled に変更されます。これで完了です。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  > hdparm -I /dev/sdX | grep -A8 -E 'Security:'
  Security:
          Master password revision code = 65534
                  supported
-         not     enabled
          not     locked
          not     frozen
          not     expired: security count
                  supported: enhanced erase
          2min for SECURITY ERASE UNIT. 2min for ENHANCED SECURITY ERASE UNIT.

参考情報

Hugo で構築されています。
テーマ StackJimmy によって設計されています。