GNU/Linux >> Linux の 問題 >  >> Linux

LinuxでSSD/HDDの状態を確認する方法

システム管理者であり、データセンターでLinuxシステムを管理する責任がある場合。次に、SSDおよびHDDドライブの状態を定期的にチェックすることをお勧めします。故障したドライブを特定するのに役立ち、データが失われる前にドライブを交換できます。 S.M.A.R.Tは、SSDとHDDのヘルスステータスを監視するために使用されるツールです。また、ドライブでオンデマンドテストを実行することもできます。

この投稿では、LinuxでSSDとHDDの状態を確認する方法を紹介します。

前提条件
  • Linuxオペレーティングシステムを実行しているサーバーまたはデスクトップ。
  • ルートパスワードはサーバーで構成されています。

Smartctlをインストール

デフォルトでは、Smartctlはすべての主要なLinuxディストリビューションのデフォルトリポジトリに含まれています。

DebianおよびUbuntuディストリビューションの場合、次のコマンドを使用してSmartctlをインストールします。

apt-get install smartmontools -y

RHEL、CentOS、およびFedoraディストリビューションの場合、次のコマンドを使用してSmartctlをインストールします。

dnf install smartmontools

Smartctlをインストールした後、次のコマンドを使用してSmartctlサービスを開始します。

systemctl start smartd

次のコマンドを使用して、smartdのステータスを確認できます。

systemctl status smartd

次の出力が得られるはずです:

? smartmontools.service - Self Monitoring and Reporting Technology (SMART) Daemon
     Loaded: loaded (/lib/systemd/system/smartmontools.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-07-02 08:58:33 UTC; 11s ago
       Docs: man:smartd(8)
             man:smartd.conf(5)
   Main PID: 1042 (smartd)
     Status: "Next check of 0 devices will start at 09:28:33"
      Tasks: 1 (limit: 2353)
     Memory: 1.2M
     CGroup: /system.slice/smartmontools.service
             ??1042 /usr/sbin/smartd -n

Jul 02 08:58:33 ubuntu2004 smartd[1042]: Device: /dev/sda, opened
Jul 02 08:58:33 ubuntu2004 smartd[1042]: Device: /dev/sda, [QEMU     QEMU HARDDISK    2.5+], 53.6 GB
Jul 02 08:58:33 ubuntu2004 smartd[1042]: Device: /dev/sda, IE (SMART) not enabled, skip device
Jul 02 08:58:33 ubuntu2004 smartd[1042]: Try 'smartctl -s on /dev/sda' to turn on SMART features
Jul 02 08:58:33 ubuntu2004 smartd[1042]: Device: /dev/sdb, opened
Jul 02 08:58:33 ubuntu2004 smartd[1042]: Device: /dev/sdb, [AN       Volume           2.5+], S/N: sdb, 53.6 GB
Jul 02 08:58:33 ubuntu2004 smartd[1042]: Device: /dev/sdb, IE (SMART) not enabled, skip device
Jul 02 08:58:33 ubuntu2004 smartd[1042]: Try 'smartctl -s on /dev/sdb' to turn on SMART features
Jul 02 08:58:33 ubuntu2004 smartd[1042]: Monitoring 0 ATA/SATA, 0 SCSI/SAS and 0 NVMe devices
Jul 02 08:58:33 ubuntu2004 systemd[1]: Started Self Monitoring and Reporting Technology (SMART) Daemon.

SSD/HDDの正常性をテストする

Smartctlをインストールした後、ハードドライブでSMART機能をオンにする必要があります。

次のコマンドを使用して実行できます:

smartctl -s on /dev/sda

最初に行う必要があるのは、SSDまたはHDDの情報を取得することです。

次のコマンドを使用して実行できます:

smartctl -i /dev/sda

これにより、ハードドライブの詳細情報が得られます。

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-4.4.0-148-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     WDC WD5000LPVX-75V0TT0
Serial Number:    WXV1EC4KN2N7
LU WWN Device Id: 5 0014ee 65af65611
Firmware Version: 01.01A01
User Capacity:    500,107,862,016 bytes [500 GB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-2 (minor revision not indicated)
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:    Fri Jul  2 14:39:33 2021 IST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

ドライブで簡単なテストを実行する場合は、次のコマンドを実行します。

smartctl -t short -a /dev/sda

次の出力が得られるはずです:

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-4.4.0-148-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     WDC WD5000LPVX-75V0TT0
Serial Number:    WXV1EC4KN2N7
LU WWN Device Id: 5 0014ee 65af65611
Firmware Version: 01.01A01
User Capacity:    500,107,862,016 bytes [500 GB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-2 (minor revision not indicated)
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:    Fri Jul  2 14:40:23 2021 IST
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:  (0x00)	Offline data collection activity
					was never started.
					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: 		( 9360) seconds.
Offline data collection
capabilities: 			 (0x7b) SMART execute Offline immediate.
					Auto Offline data collection on/off support.

短いテストでは、電気的特性、機械的特性、および読み取り/検証をテストします。

セルフテストの結果を見つけて印刷するには、次のコマンドを実行します。

smartctl -l selftest /dev/sda

次の出力が得られるはずです:

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-4.4.0-148-generic] (local build)
Copyright (C) 2002-13, 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  Short offline       Completed without error       00%      7609         -
# 2  Short offline       Interrupted (host reset)      90%      6972         -
# 3  Short offline       Aborted by host               70%      6972         -
# 4  Short offline       Interrupted (host reset)      70%         2         -

長いテストを実行するには、次のコマンドを使用します。

smartctl -t long -a /dev/sda

次の出力が得られるはずです:

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.

=== 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 107 minutes for test to complete.
Test will complete after Fri Jul  2 16:30:41 2021

Use smartctl -X to abort test.
 

長いテストでは、短いテストに含まれるすべてのものがテストされます。

テストを停止して、次のコマンドを実行できます:

smartctl -X /dev/sda

次の出力が表示されます。

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-4.4.0-148-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Abort SMART off-line mode self-test routine".
Self-testing aborted!

ドライブの全体的な状態をテストするには、次のコマンドを実行します。

smartctl -d ata -H /dev/sda

次の出力が得られるはずです:

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-4.4.0-148-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

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

テストを実行するための推定時間を確認するには、次のコマンドを実行します。

smartctl -c /dev/sda

次の出力が得られるはずです:

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-4.4.0-148-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
General SMART Values:
Offline data collection status:  (0x00)	Offline data collection activity
					was never started.
					Auto Offline Data Collection: Disabled.
Self-test execution status:      (  25)	The self-test routine was aborted by
					the host.
Total time to complete Offline 
data collection: 		( 9360) seconds.
Offline data collection
capabilities: 			 (0x7b) SMART execute Offline immediate.
					Auto Offline data collection on/off 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: 	 (   2) minutes.
Extended self-test routine
recommended polling time: 	 ( 107) minutes.
Conveyance self-test routine
recommended polling time: 	 (   5) minutes.
SCT capabilities: 	       (0x7035)	SCT Status supported.
					SCT Feature Control supported.
					SCT Data Table supported.

エラーログのみを印刷するには、次のコマンドを実行します。

smartctl -l error /dev/sda

ヘルプ情報を取得するには、次のコマンドを実行します。

smartctl --help
結論

上記のガイドでは、S.M.A.R.Tツールをインストールして使用し、SSHドライブとHDDドライブの状態を確認する方法を学びました。これがお役に立てば幸いです。詳細については、smartctlのマニュアルページを参照してください。


Linux
  1. Linuxにデバイスドライバーをインストールする方法

  2. Redhatのバージョンを確認する方法

  3. Linuxでタイムゾーンを確認する方法

  1. LinuxでSSDまたはHDDのディスクを見つける方法は?

  2. ハードドライブの状態をチェックする方法

  3. eMMC の状態を確認する

  1. LinuxでディスクがSSDかHDDかを確認する方法

  2. Linux でデバイスをマウントするには?

  3. Linuxでパスワードを確認するには?