본문 바로가기
OS/Linux

[Linux] smartctl 명령어

by Yoon_estar 2025. 1. 26.
728x90

smartctl 이란?

smartctl 은 Linux 시스템에서 디스크 드라이브 상태를 모니터링하고 관리하는 데 사용되는 명령어입니다. 

smartctl 은 SMART(Self-Monitoryng, Analysis and Reporting Technology) 데이터를 활용하여 디스크 상태를 진단하는 도구입니다. 이를 통해 하드 드라이브와 SSD의 성능 및 건강 상태를 분석할 수 있으며, 디스크 오류를 사전에 감지하여 데이터 손실을 예방하는 데 유용합니다. 

smartctl 설치

Red Hat

# yum install smartmontools

 

Debian

# apt install smartmontools

 

설치 확인

# smartctl --version
smartctl 7.4 2023-08-01 r5530 [x86_64-linux-6.8.0-49-generic] (local build)
Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org

smartctl comes with ABSOLUTELY NO WARRANTY. This is free
software, and you are welcome to redistribute it under
the terms of the GNU General Public License; either
version 2, or (at your option) any later version.
See https://www.gnu.org for further details.

smartmontools release 7.4 dated 2023-08-01 at 10:59:45 UTC
smartmontools SVN rev 5530 dated 2023-08-01 at 11:00:21
smartmontools build host: x86_64-pc-linux-gnu
smartmontools build with: C++11, GCC 13.2.0
smartmontools configure arguments: [hidden in reproducible builds]
reproducible build SOURCE_DATE_EPOCH: 1712593173 (2024-04-09 01:19:33)

 

samrtctl 주요 옵션

1. 디스크 상태 확인

  • 디스크 /dev/sdX의 모든 S.M.A.R.T 정보를 출력합니다.
  • 주요 정보: 제조사, 모델, 펌웨어 버전, S.M.A.R.T 지원 여부, 에러 로그 등.
# smartctl -a /dev/sda
smartctl 7.4 2023-08-01 r5530 [x86_64-linux-6.8.0-49-generic] (local build)
Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor:               VMware
Product:              Virtual disk
Revision:             2.0
Compliance:           SPC-4
User Capacity:        274,877,906,944 bytes [274 GB]
Logical block size:   512 bytes
LU is fully provisioned
Device type:          disk
Local Time is:        Mon Jan 20 12:15:03 2025 KST
SMART support is:     Unavailable - device lacks SMART capability.

=== START OF READ SMART DATA SECTION ===
Current Drive Temperature:     0 C
Drive Trip Temperature:        0 C

Error Counter logging not supported

Device does not support Self Test logging

 

2. SMART 지원 여부 확인

# smartctl -i /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-4.18.0-553.el8_10.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Toshiba 3.5" DT01ACA... Desktop HDD
Device Model:     TOSHIBA DT01ACA300
Serial Number:    43FBD1BGS
LU WWN Device Id: 5 000039 ff4c52d4b
Firmware Version: MX6OABB0
User Capacity:    3,000,592,982,016 bytes [3.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    7200 rpm
Form Factor:      3.5 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA8-ACS T13/1699-D revision 4
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Mon Jan 20 12:16:26 2025 KST
SMART support is: Available - device has SMART capability.
SMART support is: Disabled

 

3. SMART 활성화

# smartctl -s on /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-4.18.0-553.el8_10.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.

 

4. 디스크 건강 상태 확인

# smartctl -H /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-4.18.0-553.el8_10.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

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

 

5. 디스크 테스트 수행

  • 짧은 테스트
# smartctl -t short /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-4.18.0-553.el8_10.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Short self-test routine immediately in off-line mode".
Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 1 minutes for test to complete.
Test will complete after Mon Jan 20 12:20:18 2025 KST
Use smartctl -X to abort test.

 

  • 긴 테스트
# smartctl -t long /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-4.18.0-553.el8_10.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Can't start self-test without aborting current test (90% remaining),
add '-t force' option to override, or run 'smartctl -X' to abort test.

 

6. 테스트 결과 확인

# smartctl -l selftest /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-4.18.0-553.el8_10.x86_64] (local build)
Copyright (C) 2002-19, 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%     65508

 

7. 에러 로그 확인

# smartctl -l error /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-4.18.0-553.el8_10.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART Error Log Version: 1
ATA Error Count: 1454 (device log contains only the most recent five errors)
        CR = Command Register [HEX]
        FR = Features Register [HEX]
        SC = Sector Count Register [HEX]
        SN = Sector Number Register [HEX]
        CL = Cylinder Low Register [HEX]
        CH = Cylinder High Register [HEX]
        DH = Device/Head Register [HEX]
        DC = Device Command Register [HEX]
        ER = Error register [HEX]
        ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.

Error 1454 occurred at disk power-on lifetime: 5600 hours (233 days + 8 hours)
  When the command that caused the error occurred, the device was active or idle.

8. 특정 속성 확인

# smartctl -A /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-4.18.0-553.el8_10.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   086   086   016    Pre-fail  Always       -       117
  2 Throughput_Performance  0x0005   140   140   054    Pre-fail  Offline      -       69
  3 Spin_Up_Time            0x0007   164   164   024    Pre-fail  Always       -       360 (Average 338)
  4 Start_Stop_Count        0x0012   097   097   000    Old_age   Always       -       12116
  5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       32
  7 Seek_Error_Rate         0x000b   100   100   067    Pre-fail  Always       -       0
  8 Seek_Time_Performance   0x0005   124   124   020    Pre-fail  Offline      -       33
  9 Power_On_Hours          0x0012   088   088   000    Old_age   Always       -       84100
 10 Spin_Retry_Count        0x0013   100   100   060    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       351
192 Power-Off_Retract_Count 0x0032   090   090   000    Old_age   Always       -       12760
193 Load_Cycle_Count        0x0012   090   090   000    Old_age   Always       -       12760
194 Temperature_Celsius     0x0002   150   150   000    Old_age   Always       -       40 (Min/Max 15/71)
196 Reallocated_Event_Count 0x0032   097   097   000    Old_age   Always       -       213
197 Current_Pending_Sector  0x0022   093   093   000    Old_age   Always       -       312
198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0

 

  • 주요 속성
ID 속성 설명
5 Reallocated Sectors 재할당된 섹터 수
9 Power-On-Hours 디스크 가동 시간
10 Spin Retry Count 스핀 재시도 횟수
194 Temperature Celsius 디스크 온도
197 Current Pending Sector 교체 대기 섹터 수

 

실무 활용

디스크 온도 확인

# smartctl -A /dev/sda | grep Temperature
194 Temperature_Celsius     0x0002   150   150   000    Old_age   Always       -       40 (Min/Max 15/71)

 

디스크 에러 확인

# smartctl -l error /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-4.18.0-553.el8_10.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART Error Log Version: 1
ATA Error Count: 1454 (device log contains only the most recent five errors)
        CR = Command Register [HEX]
        FR = Features Register [HEX]
        SC = Sector Count Register [HEX]
        SN = Sector Number Register [HEX]
        CL = Cylinder Low Register [HEX]
        CH = Cylinder High Register [HEX]
        DH = Device/Head Register [HEX]
        DC = Device Command Register [HEX]
        ER = Error register [HEX]
        ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.

Error 1454 occurred at disk power-on lifetime: 5600 hours (233 days + 8 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 51 00 37 1f 42 04  Error: UNC at LBA = 0x04421f37 = 71442231

 

주기적인 테스트 자동화

  • cron 또는 systemd를 사용해 주기적으로 디스크 상태를 점검할 수 있습니다.
# crontab -e
0 2 * * * smartctl -a /dev/sdX > /var/log/smartctl_$(date +\%Y\%m\%d).log