Smartctl: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
(Added Knowledge Graph section)
(Fix: remove --- horizontal lines (12 removed))
 
Line 20: Line 20:
* 언제 사용하는가? — 서버 디스크 모니터링, RAID 디스크 진단
* 언제 사용하는가? — 서버 디스크 모니터링, RAID 디스크 진단


---


== Purpose ==
== Purpose ==
Line 30: Line 29:
* Non-goals: 디스크 물리적 교체, 데이터 복구
* Non-goals: 디스크 물리적 교체, 데이터 복구


---


== Key Concepts ==
== Key Concepts ==
Line 68: Line 66:
|}
|}


---


== Architecture ==
== Architecture ==
Line 85: Line 82:
</syntaxhighlight>
</syntaxhighlight>


---


== Workflow ==
== Workflow ==
Line 119: Line 115:
|}
|}


---


== Detailed Explanation ==
== Detailed Explanation ==
Line 477: Line 472:
* 컴파일 가이드: https://www.linuxfromscratch.org/blfs/view/svn/postlfs/smartmontools.html
* 컴파일 가이드: https://www.linuxfromscratch.org/blfs/view/svn/postlfs/smartmontools.html


---


== Configuration ==
== Configuration ==
Line 500: Line 494:
</syntaxhighlight>
</syntaxhighlight>


---


== Examples ==
== Examples ==
Line 541: Line 534:
</syntaxhighlight>
</syntaxhighlight>


---


== Best Practices ==
== Best Practices ==
Line 553: Line 545:
* smartmontools 최신 버전 유지
* smartmontools 최신 버전 유지


---


== Limitations ==
== Limitations ==
Line 562: Line 553:
* SMART는 고장 예측일 뿐 보장 아님
* SMART는 고장 예측일 뿐 보장 아님


---


== References ==
== References ==
Line 570: Line 560:
* https://www.liquidweb.com/kb/smartctl-utility-in-smartmontools-for-linux/
* https://www.liquidweb.com/kb/smartctl-utility-in-smartmontools-for-linux/


---


== Related Pages ==
== Related Pages ==
Line 580: Line 569:
* [[Storage]]
* [[Storage]]


---


[[Category:Linux]]
[[Category:Linux]]

Latest revision as of 11:30, 17 July 2026

Smartctl

Template:Status

Template:TOC

Overview

smartctl은 smartmontools 패키지의 명령줄 도구로, 하드 디스크와 SSD의 SMART(S.M.A.R.T.) 속성을 쿼리하고 모니터링합니다. GSmartControl이라는 GUI 도구도 제공됩니다.

Summary

  • 무엇인가? — 디스크 SMART 모니터링 CLI 도구
  • 왜 필요한가? — 디스크 건강 상태 확인, 고장 예측, 정기 테스트
  • 언제 사용하는가? — 서버 디스크 모니터링, RAID 디스크 진단


Purpose

이 문서가 존재하는 이유

  • Goal: smartctl 명령어, 테스트 유형, smartd 설정, SMART 속성 해석 제공
  • Scope: smartctl 기본 명령어, 테스트 실행, smartd 구성, RAID 백 디스크 접근
  • Non-goals: 디스크 물리적 교체, 데이터 복구


Key Concepts

Concept Description Related
SMART Self-Monitoring, Analysis and Reporting Technology Smartctl
smartctl 디스크 SMART 쿼리 도구 Smartctl
smartd 백그라운드 디스크 모니터링 데몬 Smartctl
Reallocated_Sector_Ct 재할당 섹터 수 — 고장 징후 Smartctl
Current_Pending_Sector 대기 중인 불안정 섹터 수 Smartctl
Offline_Uncorrectable 교정 불가 읽기/쓰기 오류 수 Smartctl
megaraid MegaRAID 컨트롤러 디스크 접근 Storcli


Architecture

smartctl은 디스크와 직접 통신하여 SMART 정보를 수집합니다:

graph TD
    A[smartctl] --> B[디스크]
    A --> C[RAID 컨트롤러]
    C --> D[물리적 디스크]
    B --> E[SMART 데이터]
    C --> E
    E --> F[smartd 모니터링]
    F --> G[이메일 알림]


Workflow

Stage Input Output
Install apt-get install smartmontools smartctl binary
Scan smartctl --scan Device list
Health Check smartctl -H /dev/sdX PASSED/FAILED
Run Test smartctl -t short/long Test in progress
View Results smartctl -a /dev/sdX SMART data
Monitor smartd service Email alerts


Detailed Explanation

smartctl 기본 명령어

Option Action
-h, --help 명령어 개요 및 구문 표시
--scan 모든 디스크 스캔 — 이름, 타입, 프로토콜 출력
-d TYPE 디바이스 타입 수동 지정 (ata, scsi, nvme 등)
-i, --info 디바이스 정보 출력 (SMART 지원 여부 포함)
-H, --health SMART 건강 상태 보고 — "fail"은 곧 고장 의미
-a, --all 모든 SMART 정보 출력 (less/more/pager 권장)
-s (on, off) 디바이스에서 SMART 활성화/비활성화
-o (on, off) ATA 전용 — 자동 오프라인 테스트 활성화/비활성화 (4시간마다)
-x, --xall SMART + 비-SMART 정보 모두 출력
-S (on, off) 벤더 속성 자동 저장 활성화/비활성화

smartctl 기본 사용법

# 모든 디스크 스캔
$ smartctl --scan

# 디바이스 정보 확인
$ sudo smartctl -i /dev/nvme0

# 모든 SMART 정보 (less로 페이지)
$ sudo smartctl -d ata -a /dev/sda | less

# SMART 및 오프라인 테스트 활성화
$ sudo smartctl -s on -o on -S on /dev/sdb

# 건강 상태 확인
$ sudo smartctl -d scsi -H /dev/sdc

테스트 유형

  • **Foreground Mode** — 디스크 미사용 시 권장
  • **Background Mode** — **권장 모드**. 낮은 우선순위로 실행. 디스크 사용 중이면 일시 후 재개. 운영 중단 없음.

테스트 명령어

작업 명령어 비고
SMART 비활성화 `smartctl -o off device`
건강 상태 확인 `smartctl -H device`
Short/Long 테스트 실행 `smartctl -t short/long device` Background 모드
Foreground 테스트 `smartctl -t short/long -C device` -C 옵션 추가
테스트 중단 `smartctl -X`
전체 결과 확인 `smartctl -a device`
제한된 결과 `smartctl -A device`
`smartctl -l error device`

테스트 유형 상세

Test Description 시간
Short Test 3개 세그먼트로 빠른 디스크 결함 식별 최대 2분
Long Test Short Test + 전체 디스크 읽기/검증 제한 없음
Conveyance Test 수송 중 손상 여부 확인 수분
Select Test 지정된 LBA 범위만 검사 범위 의존
    • Select Test 예시:**
# LBA 10-20 검사
$ sudo smartctl -t select,10-20 /dev/sdc

# LBA 10+11 검사
$ sudo smartctl -t select,10+11 /dev/sdc

# 여러 범위 (최대 5개)
$ sudo smartctl -t select,0-10 -t select,5-15 -t select,10-20 /dev/sdc

smartd (백그라운드 모니터링)

smartmontools 로그 파일: `/var/lib/smartmontools/`

smartd는 백그라운드에서 디스크를 점검하고 문제 발생 시 이메일을 발송합니다.

Option Action
-q WHEN 종료 조건. `onecheck`: 모든 디바이스 한 번 점검 후 종료
-d, --debug 상세 상태 정보. 포그라운드 실행. CTRL+\로 종료
h 도움말 및 명령어 요약
-i N, --interval N 디스크 점검 간격 (초). 기본값 1800초 (30분)
    • smartd 명령어 예시:**
# 모든 디바이스 한 번 점검
$ smartd -q onecheck

# 디버그 모드, 15초 간격
$ smartd -d -i 15

# 데몬으로 실행 (syslog 로깅)
$ smartd

# systemd 서비스
$ sudo systemctl start smartd.service
$ sudo systemctl stop smartd.service
$ sudo systemctl restart smartd.service

/etc/smartd.conf 설정

sudo vim /etc/smartd.conf

# 기본 설정
DEVICESCAN -a -m your@mxdomain.com -M test

# 예시: /dev/sda를 매주 일요일 2-3시에 Long 테스트
/dev/sda -d scsi -a -s L/../../7/02

# 예시: 건강 실패만 이메일 보고
/dev/sdc -H -C 0 -U 0 your@mxdomain.com
    • smartd.conf 지시어:**
Option Action
-a `-H -f -t -l error -l selftest -C 197 -U 198`와 동일
-H SMART 건강 모니터링 및 실패 보고
-f 'Usage' 속성 실패 모니터링
-t `-p`와 `-u`와 동일
-p 'Prefailure' 속성 변경 보고
-u 'Usage' 속성 변경 보고
-l TYPE `selftest`)
-C ID Current Pending Sector 보고 (ID 197)
-U ID Offline Uncorrectable 보고 (ID 198)
-m `-H`, `-l`, `-f` 결과를 이메일로 발송
-M Type 이메일 타입. `-M test`: 서비스 시작 시 테스트 이메일
-d TYPE 디바이스 타입 지정 (smartctl과 동일)
-W (D,I,C) 온도 모니터링: 차이(D), 정보(I), 임계값(C)
-s (L/../../7/02) REGEXP 기반 테스트 스케줄링

RAID 백 디스크 접근

MegaRAID 컨트롤러

smartctl은 MegaRAID 컨트롤러를 통합 지원합니다:

# DID 확인 (Storcli로)
$ sudo storcli /c0 /eall /sall show

# smartctl로 디스크 확인
$ sudo smartctl -a -d megaraid,<DID> /dev/sdX
    • 모든 디스크 테스트:**
for i in {0..N}; do sudo smartctl -t short /dev/sda -d megaraid,$i >> ./OUTPUT; done

제조사별 RAID 컨트롤러

Manufacturer Hard disk Command
ARECA 1 `smartctl -x /dev/sg1 -d areca,1`
ARECA 2 `smartctl -x /dev/sg1 -d areca,2`
LSI / 3Ware 1 `smartctl -x /dev/twe0 -d 3ware,0`
Adaptec 1 `smartctl -x /dev/sg2 -d sat`
Dell 1 `smartctl -x -d sat+megaraid,0 /dev/sda`
Broadcom 1 `smartctl -x -d sat+megaraid,0 /dev/sda`

결함 디스크 식별

1. `=== START OF READ SMART DATA SECTION ===` 확인 — `PASSED`가 아니면 교체 필요 2. `WHEN_FAILED` 확인 — `FAILING_NOW`은 현재 실패 중, `In_the_past`은 과거 실패, `-`는 정상 3. 주요 속성 확인:

Attribute Description 중요도
Reallocated_Sector_Ct 재할당된 섹터 수. 0이 아니면 표면 문제 징후. **가장 중요한 교체 지표** ⚠️⚠️⚠️
Current_Pending_Sector 불안정 섹터 대기 중. 0이 아니면 고장 임박. **중요 교체 지표** ⚠️⚠️⚠️
Offline_Uncorrectable 교정 불가 읽기/쓰기 오류. 2자리 이상이면 즉시 교체 ⚠️⚠️
    • smartctl 출력 예시:**
$ sudo smartctl -a /dev/sda

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Red
Device Model:     WDC WD40EFRX-68WT0N0
Serial Number:    WD-WCC4E7JN0YCY
User Capacity:    4,000,787,030,016 bytes [4.00 TB]
Rotation Rate:    5400 rpm

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

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     0x002f   200   200   051    Pre-fail  Always       -       0
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
  9 Power_On_Hours          0x0032   069   068   000    Old_age   Always       -       22749
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   253   000    Old_age   Offline      -       0

RAID 배열 확인

# RAID 배열 목록 확인
$ cat /proc/scsi/scsi

최신 버전 확인


Configuration

# smartmontools 설치
$ sudo apt-get install smartmontools

# SMART 활성화
$ sudo smartctl -s on -o on -S on /dev/sda

# /etc/smartd.conf 설정
$ sudo vim /etc/smartd.conf
# DEVICESCAN -a -m admin@example.com -M test

# smartd 서비스 시작
$ sudo systemctl enable smartd
$ sudo systemctl start smartd

# RAID 백 디스크 테스트
$ sudo smartctl -a -d megaraid,0 /dev/sda


Examples

Example 1: 디스크 건강 상태 확인

# 모든 디스크 스캔
$ smartctl --scan

# 건강 상태 확인
$ sudo smartctl -H /dev/sda

# 전체 SMART 정보
$ sudo smartctl -a /dev/sda | less

Example 2: Short 테스트 실행

# Short 테스트 (Background)
$ sudo smartctl -t short /dev/sda

# 테스트 결과 확인
$ sudo smartctl -l selftest /dev/sda

# Long 테스트 (Background)
$ sudo smartctl -t long /dev/sda

Example 3: RAID 백 디스크 모니터링

# Storcli로 DID 확인
$ sudo storcli /c0 /eall /sall show

# smartd.conf에 RAID 디스크 추가
/dev/sda -d megaraid,0 -a -m admin@example.com
/dev/sdb -d megaraid,1 -a -m admin@example.com


Best Practices

  • 정기적 Short 테스트 (주간) + Long 테스트 (월간)
  • smartd 백그라운드 모니터링 필수
  • /etc/smartd.conf에 이메일 알림 설정
  • Reallocated_Sector_Ct 및 Current_Pending_Sector 정기 확인
  • RAID 백 디스크는 megaraid,<DID> 옵션 사용
  • 테스트는 Background Mode로 실행 (운영 중단 없음)
  • smartmontools 최신 버전 유지


Limitations

  • SMART는 모든 디스크에서 지원되지 않음 (NVMe는 다른 명령어)
  • RAID 백 디스크는 컨트롤러별 옵션 필요
  • smartd는 로컬 로그/이메일만 지원 (원격 모니터링 아님)
  • SMART는 고장 예측일 뿐 보장 아님


References


Related Pages

Knowledge Graph

Related

LinuxServerHardwareNetwork