Smartctl: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
(Add categories: Linux, Reference)
(Fix: remove --- horizontal lines (12 removed))
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
[https://www.smartmontools.org/ smartmontools.org] supports the smartctl Command Line Tool of [https://sourceforge.net/projects/smartmontools/files/smartmontools/7.4/ Smartmontools]is primarily used to query SMART attributes of hard drives and SSDs.<ref>https://www.thomas-krenn.com/en/wiki/Smartmontools_with_MegaRAID_Controller</ref>
= Smartctl =


Recently, Alexander Shaduri released ​a graphical user interface for smartctl called as GSmartControl<ref>https://gsmartcontrol.shaduri.dev/</ref> available for [[Linux]], FreeBSD, MacOS X and Windows. 
{{Status
|status=Draft
|owner=Knowledge Agent
|last_update=2026-07-15
|review=Pending
}}
 
{{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 ==
 
{| class="wikitable"
! 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 정보를 수집합니다:
 
<syntaxhighlight lang="mermaid">
graph TD
    A[smartctl] --> B[디스크]
    A --> C[RAID 컨트롤러]
    C --> D[물리적 디스크]
    B --> E[SMART 데이터]
    C --> E
    E --> F[smartd 모니터링]
    F --> G[이메일 알림]
</syntaxhighlight>
 
 
== Workflow ==
 
{| class="wikitable"
! 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 기본 명령어 ===


== smartctl ==
{| class="wikitable"
{| class="wikitable"
! colspan="" |Option
! Option
! colspan="" |Action
! Action
|-
|-
| colspan="" rowspan="" |-h, --help
| -h, --help
| colspan="" rowspan="" |Prints out a table with a brief overview of the commands and their syntax
| 명령어 개요 및 구문 표시
|-
|-
| colspan="" rowspan="" |--scan
| --scan
| colspan="" rowspan="" |scans all devices and prints out their names, type and protocol.
| 모든 디스크 스캔 — 이름, 타입, 프로토콜 출력
|-
|-
| colspan="" rowspan="" |-d TYPE
| -d TYPE
| colspan="" rowspan="" |smartctl will guess the device type, but if you need to specify it manually you can do so with this switch. eg (ata, scsi, nvme, see man page for full list etc)
| 디바이스 타입 수동 지정 (ata, scsi, nvme )
|-
|-
| colspan="" rowspan="" |-i, --info
| -i, --info
| colspan="" rowspan="" |prints various information about the device
| 디바이스 정보 출력 (SMART 지원 여부 포함)
|-
|-
| colspan="" rowspan="" |-H, --health
| -H, --health
| colspan="" rowspan="" |Reports SMART health status. On “fail” status the drive is already dead or will die very soon.
| SMART 건강 상태 보고 — "fail"은 곧 고장 의미
|-
|-
| colspan="" rowspan="" |-a, --all
| -a, --all
| colspan="" rowspan="" |Prints all SMART info about device. I recommended piping the output to less, more, or pager.
| 모든 SMART 정보 출력 (less/more/pager 권장)
|-
|-
| colspan="" rowspan="" |-s (on, off)
| -s (on, off)
| colspan="" rowspan="" |Enable/disable SMART on device.
| 디바이스에서 SMART 활성화/비활성화
|-
|-
| colspan="" rowspan="" |-o (on, off)
| -o (on, off)
| colspan="" rowspan="" |ATA only, enable/disable SMART automatic offline test (checks disk every 4 hours for defects)
| ATA 전용 — 자동 오프라인 테스트 활성화/비활성화 (4시간마다)
|-
|-
| colspan="" rowspan="" |-x, --xall
| -x, --xall
| colspan="" rowspan="" |prints all SMART and non-SMART information about the device.
| SMART + 비-SMART 정보 모두 출력
|-
|-
| colspan="" rowspan="" |-S (on, off)
| -S (on, off)
| colspan="" rowspan="" |Enables/disables SMART autosave of device vendor attributes. Needs only be ran once and preserves this data even if disk is powered off.
| 벤더 속성 자동 저장 활성화/비활성화
|}
|}
=== smartctl 기본 사용법 ===
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
# scans all drives and type
# 모든 디스크 스캔
smartctl --scan
$ smartctl --scan


# -i gives a brief overview of the drive and status of supports SMART and is enabled
# 디바이스 정보 확인
sudo smartctl -i /dev/nvme0
$ sudo smartctl -i /dev/nvme0


# -a will print out a large amount of information and stats; piped to pager
# 모든 SMART 정보 (less로 페이지)
sudo smartctl -d ata -a -i /dev/sda | pager #or more or less
$ sudo smartctl -d ata -a /dev/sda | less


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


# check smart health with -H (Healthy status)
# 건강 상태 확인
sudo smartctl -d scsi -H /dev/sdc
$ sudo smartctl -d scsi -H /dev/sdc
</syntaxhighlight><code>--scan</code> switch to get the type of drives in the system
</syntaxhighlight>
 
=== 테스트 유형 ===


== Available Tests<ref>https://www.thomas-krenn.com/en/wiki/SMART_tests_with_smartctl</ref><ref>https://www.liquidweb.com/kb/smartctl-utility-in-smartmontools-for-linux/</ref> ==
* **Foreground Mode** — 디스크 미사용 시 권장
* **Background Mode** — **권장 모드**. 낮은 우선순위로 실행. 디스크 사용 중이면 일시 후 재개. 운영 중단 없음.


* Foreground Mode - recommended when the hard disk is not used
=== 테스트 명령어 ===
* Background Mode - '''preferred mode, test executed in low priority. If the hard drive is busy, the test is paused and then continues at a lower load speed, so there is no interruption of the operation'''


=== Basic smartctl command ===
{| class="wikitable"
{| class="wikitable"
|To disable smartctl
! 작업
|smartctl -o off device
! 명령어
|
! 비고
|-
| SMART 비활성화
| `smartctl -o off device`
| —
|-
| 건강 상태 확인
| `smartctl -H device`
|
|-
|-
|Check drive health
| Short/Long 테스트 실행
|<code>smartctl -H device</code>
| `smartctl -t short/long device`
|
| Background 모드
|-
|-
|Run long/short test
| Foreground 테스트
|<code>smartctl <short or long> device</code>
| `smartctl -t short/long -C device`
|<nowiki>sudo smartctl -t <short|long|conveyance|select> /dev/sdc</nowiki>
| -C 옵션 추가
tests in Foreground Mode a "-C" must be added to the command.
sudo smartctl -t <short|long|conveyance|select> -C /dev/sdc
|-
|-
|To abort test
| 테스트 중단
|Use smartctl -X  
| `smartctl -X`
|
|
|-
|-
|View full results
| 전체 결과 확인
|<code>smartctl -a device</code>
| `smartctl -a device`
|
|
|-
|-
|View limited results
| 제한된 결과
|<code>sudo smartctl -A device</code>
| `smartctl -A device`<br>`smartctl -l error device`
<code>smartctl -l error device</code>
|
|
|}
|}


=== smartctl test case ===
=== 테스트 유형 상세 ===
 
{| class="wikitable"
{| class="wikitable"
|+
! Test
!Test
! Description
!Test case
! 시간
!
|-
|-
| rowspan="2" |ATA/SCSI Tests
| Short Test
|Short Test
| 3개 세그먼트로 빠른 디스크 결함 식별
|rapid identification of a defective hard drive in three different segments. Therefore, a maximum run time for the short test is 2 min.
| 최대 2분
 
# '''Electrical Properties''':  The controller tests its own electronics, and since this is specific to each manufacturer, it cannot be explained exactly what is being tested. It is conceivable, for example, to test the internal RAM, the read/write circuits or the head electronics.
# '''Mechanical Properties''': The exact sequence of the servos and the positioning mechanism to be tested is also specific to each manufacturer.
# '''Read/Verify''': It will read a certain area of ​​the disk and verify certain data, the size and position of the region that is read is also specific to each manufacturer.
|-
|-
|Long Test
| Long Test
|The long test was designed as the final test in production and is the same as '''the short test''' with '''two differences'''. The first: there is '''no time restriction''' and in the Read/Verify segment the '''entire disk is checked''' and not just a section. The Long test can, for example, be used to confirm the results of the short tests.
| Short Test + 전체 디스크 읽기/검증
| 제한 없음
|-
|-
| rowspan="2" |ATA specified Tests
| Conveyance Test
|Conveyance Test
| 수송 중 손상 여부 확인
|This test can be performed to determine damage during transport of the hard disk within just a few minutes.
| 수분
|-
|-
|Select Tests
| Select Test
|During selected tests the specified range of LBAs is checked. The LBAs to be scanned are specified in the following formats:
| 지정된 LBA 범위만 검사
sudo smartctl -t select,10-20 /dev/sdc #LBA 10 to LBA 20 (incl.)
| 범위 의존
sudo smartctl -t select,10+11 /dev/sdc #LBA 10 to LBA 20 (incl.)
It is also possible to have multiple ranges, (up to 5), to scan:
sudo smartctl -t select,0-10 -t select,5-15 -t select,10-20 /dev/sdc
|}
|}


=== smartd using systemd ===
**Select Test 예시:**
smartmontool log file will be storea at /var/lib/smartmontools. smartmontool can also run  in the background and have it check drives and email when there are issues, [https://help.ubuntu.com/community/Smartmontools This Ubuntu page] shows more details.
 
<syntaxhighlight lang="bash">
# 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
</syntaxhighlight>
 
=== smartd (백그라운드 모니터링) ===
 
smartmontools 로그 파일: `/var/lib/smartmontools/`
 
smartd는 백그라운드에서 디스크를 점검하고 문제 발생 시 이메일을 발송합니다.
 
{| class="wikitable"
{| class="wikitable"
! colspan="" |Option
! Option
! colspan="" |Action
! Action
|-
|-
| colspan="" rowspan="" |-q WHEN
| -q WHEN
| colspan="" rowspan="" |Tells smartd when to quit. See full man page for full details. One useful option is onecheck, which registers attached devices and checks the status of the devices exactly once and returns this as text output.
| 종료 조건. `onecheck`: 모든 디바이스 한 번 점검 후 종료
|-
|-
| colspan="" rowspan="" |-d, --debug
| -d, --debug
| colspan="" rowspan="" |verbose status information, and does not fork into the background, in this mode, CTRL+C will not exit the readout but instead reload the smartd config, to exit this mode use CTRL+\.
| 상세 상태 정보. 포그라운드 실행. CTRL+\로 종료
|-
|-
| colspan="" rowspan="" |h
| h
| colspan="" rowspan="" |prints help and command summary
| 도움말 및 명령어 요약
|-
|-
| colspan="" rowspan="" |-i N, --interval N
| -i N, --interval N
| colspan="" rowspan="" |Sets how often smartd will check disk in seconds, default is 1800 secs or 30 minutes.
| 디스크 점검 간격 (초). 기본값 1800초 (30분)
|}
|}


smartd commandline examples<syntaxhighlight lang="bash">
**smartd 명령어 예시:**
#register and check all devices once
 
smartd -q onecheck
<syntaxhighlight lang="bash">
# 모든 디바이스 한 번 점검
$ smartd -q onecheck


# run in foreground in debug mode, checking polling every device every 15 seconds
# 디버그 모드, 15초 간격
# exit with ctrl+\
$ smartd -d -i 15
smartd -d -i 15


#running smartd on its own will run in the daemon in the background and log to syslog
# 데몬으로 실행 (syslog 로깅)
smartd
$ smartd


# with systemd service
# systemd 서비스
sudo systemctl start smartd.service
$ sudo systemctl start smartd.service
sudo systemctl stop smartd.service
$ sudo systemctl stop smartd.service
sudo systemctl restart smartd.service
$ sudo systemctl restart smartd.service
</syntaxhighlight>
</syntaxhighlight>


=== Configuring /etc/smartd.conf ===
=== /etc/smartd.conf 설정 ===
<code>smartd</code> is configurable via <code>/etc/smartd.conf</code><syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
sudo vim /etc/smartd.conf
sudo vim /etc/smartd.conf
#...
 
#DEVICESCAN -d removable -n standby -m root -M exec /usr/share/smartmontools/smartd-runner
# 기본 설정
DEVICESCAN -a -m your@mxdomain.com -M test
DEVICESCAN -a -m your@mxdomain.com -M test
#...


some more examples
# 예시: /dev/sda를 매주 일요일 2-3시에 Long 테스트
#monitors /dev/sda and preforms a long test every sunday between 2-3am
/dev/sda -d scsi -a -s L/../../7/02
/dev/sda -d scsi -a -s L/../../7/02


# Only reports SMART health failures to a email addres
# 예시: 건강 실패만 이메일 보고
/dev/sdc -H -C 0 -U 0 your@mxdomain.com
/dev/sdc -H -C 0 -U 0 your@mxdomain.com
#save
#Restart smartd service
sudo systemctl restart smartmontools.
</syntaxhighlight>
</syntaxhighlight>


=== Configuring /etc/smartd.conf with all hdd behind of controller ===
**smartd.conf 지시어:**
<syntaxhighlight lang="bash">
#list up all DID
for i in $(storcli /c0 /eall /sall show | grep "^22"|awk '{print $2}'); do echo "/dev/sda -a -d megaraid,$i <do something>; done
/dev/sda -a -d megaraid,24 <do something>
/dev/sda -a -d megaraid,25 <do something>
/dev/sda -a -d megaraid,10 <do something>
/dev/sda -a -d megaraid,11 <do something>
/dev/sda -a -d megaraid,12 <do something>
...
 
/dev/sda -a -d megaraid,21 <do something>
# <do something> example, -m root -M exec /usr/share/smartmontools/smartd-runner
</syntaxhighlight>


Following table is basic directives of the /etc/smartd.conf file and meaning<ref>https://linuxman.co/linux-server/staying-up-to-date-with-your-hard-drive-with-smartmon-tools/</ref>
{| class="wikitable"
{| class="wikitable"
! colspan="" |Option
! Option
! colspan="" |Action
! Action
|-
|-
| colspan="" rowspan="" |-a
| -a
| colspan="" rowspan="" |Equivalent to running -H -f -t -l error -l selftest -C 197 -U 198
| `-H -f -t -l error -l selftest -C 197 -U 198`와 동일
|-
|-
| colspan="" rowspan="" |-H
| -H
| colspan="" rowspan="" |Monitor SMART Health, and report failures
| SMART 건강 모니터링 및 실패 보고
|-
|-
| colspan="" rowspan="" |-f
| -f
| colspan="" rowspan="" |Monitor for failure of any 'Usage' Attributes
| 'Usage' 속성 실패 모니터링
|-
|-
| colspan="" rowspan="" |-t
| -t
| colspan="" rowspan="" |Equivalent to -p and -u
| `-p`와 `-u`와 동일
|-
|-
| colspan="" rowspan="" |-p
| -p
| colspan="" rowspan="" |Report changes in 'Prefailure' attributes
| 'Prefailure' 속성 변경 보고
|-
|-
| colspan="" rowspan="" |-u
| -u
| colspan="" rowspan="" |Report changes in 'Usage' attributes
| 'Usage' 속성 변경 보고
|-
|-
| colspan="" rowspan="" |-l TYPE
| -l TYPE
| colspan="" rowspan="" |<nowiki>Monitor SMART log. options are (error | selftest)</nowiki>
| SMART 로그 모니터링 (`error` | `selftest`)
|-
|-
| colspan="" rowspan="" |-C ID
| -C ID
| colspan="" rowspan="" |Report Current Pending Sector counts
| Current Pending Sector 보고 (ID 197)
|-
|-
| colspan="" rowspan="" |-U ID
| -U ID
| colspan="" rowspan="" |Report Offline Uncorrectable counts
| Offline Uncorrectable 보고 (ID 198)
|-
|-
| colspan="" rowspan="" |-m
| -m
| colspan="" rowspan="" |Send warning email with results of -H, -l, and -f
| `-H`, `-l`, `-f` 결과를 이메일로 발송
|-
|-
| colspan="" rowspan="" |-M Type
| -M Type
| colspan="" rowspan="" |See the man page for other options. Using -M test, Sends a test email an service start.
| 이메일 타입. `-M test`: 서비스 시작 시 테스트 이메일
|-
|-
| colspan="" rowspan="" |-d TYPE
| -d TYPE
| colspan="" rowspan="" |Specifies type of devices just like smartctl
| 디바이스 타입 지정 (smartctl과 동일)
|-
|-
| colspan="" rowspan="" |-W (D,I,C)
| -W (D,I,C)
| colspan="" rowspan="" |Monitor temperature '''D'''ifference, '''I'''nformal limit, & '''C'''ritical limit.
| 온도 모니터링: 차이(D), 정보(I), 임계값(C)
|-
|-
| colspan="" rowspan="" |-s (L/../../7/02)
| -s (L/../../7/02)
| colspan="" rowspan="" |Schedule tests using REGEXP, see man.
| REGEXP 기반 테스트 스케줄링
|}
|}


[https://linuxconfig.org/how-to-configure-smartd-and-be-notified-of-hard-disk-problems-via-email This guide] shows how to configure smartd and be notified of hard disk problems via email using msmtp
=== RAID 백 디스크 접근 ===


== Check RAID array list ==
==== MegaRAID 컨트롤러 ====
can display which disks of the RAID controller are accessible.
cat /proc/scsi/scsi


== smartctl disks behind LSI array ==
smartctl은 MegaRAID 컨트롤러를 통합 지원합니다:
smartctl provides integrated [[support]] for MegaRAID controller
 
sudo smartctl -a -d megaraid,<[[Storcli|StorCLI]] column DID value> /dev/sdX
<syntaxhighlight lang="bash">
Where <N> stands for the DID (Device ID)  on the RAID controller. These can be displayed via the [[Storcli|StorCLI]] (column DID).
# DID 확인 (Storcli로)
sudo storcli /c0 /eall /sall show
$ sudo storcli /c0 /eall /sall show
[[Test]] all N drives<ref>https://help.ubuntu.com/community/Smartmontools</ref>
 
for i in {0..N}; do sudo smartctl -t short /dev/sda -d megaraid,$i >>./OUTPUT; done
# smartctl로 디스크 확인
$ sudo smartctl -a -d megaraid,<DID> /dev/sdX
</syntaxhighlight>
 
**모든 디스크 테스트:**
 
<syntaxhighlight lang="bash">
for i in {0..N}; do sudo smartctl -t short /dev/sda -d megaraid,$i >> ./OUTPUT; done
</syntaxhighlight>
 
==== 제조사별 RAID 컨트롤러 ====


== smartctl behind by HW RAID by manufacturer<ref>https://www.ionos.com/help/server-cloud-infrastructure/server-administration-dedicated-servers/diagnose-and-replace-a-defective-hard-drive-linux-dedicated-server-with-hardware-raid/</ref> ==
{| class="wikitable"
{| class="wikitable"
!Manufacturer
! Manufacturer
!Hard disk
! Hard disk
!Command
! 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
|-
|LSI / 3Ware
|2
|smartctl -x /dev/twe0 -d 3ware,1
|-
|Adaptec
|1
|smartctl -x /dev/sg2 -d sat
|-
|Adaptec
|2
|smartctl -x /dev/sg3 -d sat
|-
|-
|Adaptec
| ARECA
|(3)
| 1
|smartctl -x /dev/sg4 -d sat
| `smartctl -x /dev/sg1 -d areca,1`
|-
|-
|Adaptec
| ARECA
|(4)
| 2
|smartctl -x /dev/sg5 -d sat
| `smartctl -x /dev/sg1 -d areca,2`
|-
|-
|Dell
| LSI / 3Ware
|1
| 1
|smartctl –x -d sat+megaraid,0 /dev/sda
| `smartctl -x /dev/twe0 -d 3ware,0`
|-
|-
|Dell
| Adaptec
|2
| 1
|smartctl –x -d sat+megaraid,1 /dev/sda
| `smartctl -x /dev/sg2 -d sat`
|-
|-
|Broadcom
| Dell
|1
| 1
|smartctl –x -d sat+megaraid,0 /dev/sda
| `smartctl -x -d sat+megaraid,0 /dev/sda`
|-
|-
|Broadcom
| Broadcom
|2
| 1
|smartctl –x -d sat+megaraid,1 /dev/sda                                           
| `smartctl -x -d sat+megaraid,0 /dev/sda`
|}
|}


== Identify a defective hard drive ==
=== 결함 디스크 식별 ===


# Check "START OF READ SMART DATA SECTION"  from smartctl.  If the value '''Failed''' or '''UNKNOWN''' is displayed instead of the value '''PASSED''', you should replace the hard drive as soon as possible
1. `=== START OF READ SMART DATA SECTION ===` 확인 — `PASSED`가 아니면 교체 필요
# Check "WHEN_FAILED", If the Attribute's current Normalized value is less than or equal to the threshold value, then the "WHEN_FAILED" column will display "'''FAILING_NOW'''". If not, but the worst recorded value is less than or equal to the threshold value, then this column will display "'''In_the_past'''". If the "WHEN_FAILED" column has no entry ('''indicated by a dash: '-'''') then this Attribute is OK now (not failing) and has also never failed in the past.<ref>https://linux.die.net/man/8/smartctl</ref>
2. `WHEN_FAILED` 확인 — `FAILING_NOW`은 현재 실패 중, `In_the_past`은 과거 실패, `-`는 정상
# Some important attributes are following
3. 주요 속성 확인:


{| class="wikitable"
{| class="wikitable"
|+
! Attribute
![[S.M.A.R.T. Attributes|Attribute name]]
! Description
!Description
! 중요도
|-
|-
|'''Reallocated_Sector_Ct'''
| Reallocated_Sector_Ct
|Specifies the number of sectors reassigned due to read errors. If a sector can no longer be read, written to or checked correctly, a replacement sector is automatically assigned to it. The faulty sector is permanently marked as unreadable. This is a clear warning sign for incipient surface problems. If this value is not equal to zero, a hard drive failure is often imminent. This value is the most important indicator for a hard drive replacement
| 재할당된 섹터 수. 0이 아니면 표면 문제 징후. **가장 중요한 교체 지표**
| ⚠️⚠️⚠️
|-
|-
|'''Current_Pending_Sector_Ct'''
| Current_Pending_Sector
|Specifies the number of unstable sectors waiting for remapping. If a sector cannot be read and written correctly, it first receives the status Current Pending Sector. The sector is not reassigned in this state, since the data in the sector are unknown. Only after several unsuccessful read or write attempts is a replacement sector assigned and the faulty sector is permanently marked as unreadable. The value Current_Pending_Sector_Ct is an important indicator for a hard drive replacement.  
| 불안정 섹터 대기 중. 0이 아니면 고장 임박. **중요 교체 지표**
If this value is not equal to zero, a hard drive failure is often imminent
| ⚠️⚠️⚠️
|-
|-
|'''Offline_Uncorrectable'''
| Offline_Uncorrectable
|Specifies the number of uncorrectable write and read sector errors.
| 교정 불가 읽기/쓰기 오류. 2자리 이상이면 즉시 교체
The last section deals with the internal hard drive log. Errors are recorded here if the server's work orders have not been processed correctly by the hard drive. If the number of errors in this section is at least two digits, you should replace the hard drive as soon as possible
| ⚠️⚠️
|}
|}
**smartctl 출력 예시:**
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
#smartctl example output
$ sudo smartctl -a /dev/sda
$ sudo smartctl -a /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-164-generic] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org


=== START OF INFORMATION SECTION ===
=== START OF INFORMATION SECTION ===
Line 341: Line 442:
Device Model:    WDC WD40EFRX-68WT0N0
Device Model:    WDC WD40EFRX-68WT0N0
Serial Number:    WD-WCC4E7JN0YCY
Serial Number:    WD-WCC4E7JN0YCY
LU WWN Device Id: 5 0014ee 262e50378
Firmware Version: 82.00A82
User Capacity:    4,000,787,030,016 bytes [4.00 TB]
User Capacity:    4,000,787,030,016 bytes [4.00 TB]
Sector Sizes:    512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Rotation Rate:    5400 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:  ACS-2 (minor revision not indicated)
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Sun Dec 10 13:01:01 2023 KST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled


=== START OF READ SMART DATA SECTION ===
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
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:                (51540) 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:        ( 515) minutes.
Conveyance self-test routine
recommended polling time:        (  5) minutes.
SCT capabilities:              (0x703d) SCT Status supported.
                                        SCT Error Recovery Control supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.


SMART Attributes Data Structure revision number: 16
SMART Attributes Data Structure revision number: 16
Line 394: Line 452:
ID# ATTRIBUTE_NAME          FLAG    VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
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
   1 Raw_Read_Error_Rate    0x002f  200  200  051    Pre-fail  Always      -      0
  3 Spin_Up_Time            0x0027  182  182  021    Pre-fail  Always      -      7875
  4 Start_Stop_Count        0x0032  100  100  000    Old_age  Always      -      22
   5 Reallocated_Sector_Ct  0x0033  200  200  140    Pre-fail  Always      -      0
   5 Reallocated_Sector_Ct  0x0033  200  200  140    Pre-fail  Always      -      0
  7 Seek_Error_Rate        0x002e  200  200  000    Old_age  Always      -      0
   9 Power_On_Hours          0x0032  069  068  000    Old_age  Always      -      22749
   9 Power_On_Hours          0x0032  069  068  000    Old_age  Always      -      22749
10 Spin_Retry_Count        0x0032  100  253  000    Old_age  Always      -      0
11 Calibration_Retry_Count 0x0032  100  253  000    Old_age  Always      -      0
12 Power_Cycle_Count      0x0032  100  100  000    Old_age  Always      -      22
192 Power-Off_Retract_Count 0x0032  200  200  000    Old_age  Always      -      11
193 Load_Cycle_Count        0x0032  180  180  000    Old_age  Always      -      60592
194 Temperature_Celsius    0x0022  117  105  000    Old_age  Always      -      35
196 Reallocated_Event_Count 0x0032  200  200  000    Old_age  Always      -      0
197 Current_Pending_Sector  0x0032  200  200  000    Old_age  Always      -      0
197 Current_Pending_Sector  0x0032  200  200  000    Old_age  Always      -      0
198 Offline_Uncorrectable  0x0030  100  253  000    Old_age  Offline      -      0
198 Offline_Uncorrectable  0x0030  100  253  000    Old_age  Offline      -      0
199 UDMA_CRC_Error_Count    0x0032  200  200  000    Old_age  Always      -      0
200 Multi_Zone_Error_Rate  0x0008  100  253  000    Old_age  Offline      -      0
</syntaxhighlight>
</syntaxhighlight>


== Check latest version ==
=== RAID 배열 확인 ===
 
<syntaxhighlight lang="bash">
# RAID 배열 목록 확인
$ cat /proc/scsi/scsi
</syntaxhighlight>
 
=== 최신 버전 확인 ===
 
* 자동 빌드: https://builds.smartmontools.org/
* 사전 컴파일 패키지: https://www.smartmontools.org/wiki/Packages
* 소스: https://sourceforge.net/projects/smartmontools/files/smartmontools/
* 컴파일 가이드: https://www.linuxfromscratch.org/blfs/view/svn/postlfs/smartmontools.html
 
 
== Configuration ==
 
<syntaxhighlight lang="bash">
# 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
</syntaxhighlight>
 
 
== Examples ==
 
=== Example 1: 디스크 건강 상태 확인 ===
 
<syntaxhighlight lang="bash">
# 모든 디스크 스캔
$ smartctl --scan
 
# 건강 상태 확인
$ sudo smartctl -H /dev/sda
 
# 전체 SMART 정보
$ sudo smartctl -a /dev/sda | less
</syntaxhighlight>
 
=== Example 2: Short 테스트 실행 ===
 
<syntaxhighlight lang="bash">
# Short 테스트 (Background)
$ sudo smartctl -t short /dev/sda
 
# 테스트 결과 확인
$ sudo smartctl -l selftest /dev/sda
 
# Long 테스트 (Background)
$ sudo smartctl -t long /dev/sda
</syntaxhighlight>
 
=== Example 3: RAID 백 디스크 모니터링 ===
 
<syntaxhighlight lang="bash">
# 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
</syntaxhighlight>
 
 
== 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는 고장 예측일 뿐 보장 아님


* smartmontools supports  automated CircleCI builds of the smartmontools package and they are available at https://builds.smartmontools.org/
* precompiled latest packages at https://www.smartmontools.org/wiki/Packages
* smartmontool source - https://sourceforge.net/projects/smartmontools/files/smartmontools/
* [https://www.linuxfromscratch.org/blfs/view/svn/postlfs/smartmontools.html this pages] guides how to compile smartmontools on your system as well


== References ==
== References ==
<references />
 
* https://www.smartmontools.org/
* https://www.thomas-krenn.com/en/wiki/Smartmontools_with_MegaRAID_Controller
* https://www.liquidweb.com/kb/smartctl-utility-in-smartmontools-for-linux/
 
 
== Related Pages ==
 
* [[Storcli]]
* [[SSD]]
* [[HBA/RAID controller]]
* [[RAID]]
* [[Storage]]
 
 
[[Category:Linux]]
[[Category:Linux]]
== Knowledge Graph ==
Related
→ [[Linux]]
→ [[Server]]
→ [[Hardware]]
→ [[Network]]


[[Category:Reference]]
[[Category:Reference]]

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