Una pregunta de un lector en las redes sociales me impulsó a investigar cómo es posible verificar el estado de salud de un disco rígido en GNU/Linux. Siempre pienso que el día en que me alcance la muerte seguiré siendo un usuario novato de GNU/Linux. Todos los días hay conocimientos nuevos por adquirir, y cada vez que aprendo algo nuevo me doy cuenta que ignoro 10 cosas más que no conocía. Así que cada día en GNU/Linux siento que soy más y más ignorante :S
Cómo muchos sabrán, los discos rígidos (desde los primeros ATA) poseen la tecnología S.M.A.R.T. (Self Monitoring Analysis and Reporting Technology) capaz de autodetectar fallos de disco a nivel físico. La detección temprana de daños en la superficie del disco, permite poder realizar una copia de seguridad y reemplazarlo, antes de que se produzca una pérdida de datos irrecuperable.
En GNU/Linux es posible monitorear los datos S.M.A.R.T. de un disco ATA/IDE/SATA/SCSI utilizando la herramienta smartctl
. Por supuesto, además de ser soportada por el disco duro, esta tecnología tiene que ser compatible con la BIOS del equipo y debe estar activada.
Para ver rápidamente la ayuda ejecutar:
smartctl -h
Para ver el manual completo, ejecutar:
man smartctl
Con la opción -i
es posible obtener información de un disco (modelo, número de serie, versión del firmware, etc.) y determinar si soporta S.M.A.R.T.
[root@centos6 ~]# smartctl -i /dev/sda smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-431.el6.x86_64] (local build) Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net === START OF INFORMATION SECTION === Model Family: SAMSUNG SpinPoint F3 Device Model: SAMSUNG HD502HJ Serial Number: S20BJ90ZB42316 LU WWN Device Id: 5 0024e9 203da1db5 Firmware Version: 1AJ10001 User Capacity: 500,107,862,016 bytes [500 GB] Sector Size: 512 bytes logical/physical Device is: In smartctl database [for details use: -P show] ATA Version is: 8 ATA Standard is: ATA-8-ACS revision 6 Local Time is: Thu May 8 11:44:43 2014 ART SMART support is: Available - device has SMART capability. SMART support is: Enabled
Se observa que este disco soporta S.M.A.R.T. y está habilitado. Por lo tanto es posible listar toda la información S.M.AR.T. mediante la opción -a
:
[root@centos6 ~]# smartctl -a /dev/sda smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-431.el6.x86_64] (local build) Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net === START OF INFORMATION SECTION === Model Family: SAMSUNG SpinPoint F3 Device Model: SAMSUNG HD502HJ Serial Number: S20BJ90ZB42316 LU WWN Device Id: 5 0024e9 203da1db5 Firmware Version: 1AJ10001 User Capacity: 500,107,862,016 bytes [500 GB] Sector Size: 512 bytes logical/physical Device is: In smartctl database [for details use: -P show] ATA Version is: 8 ATA Standard is: ATA-8-ACS revision 6 Local Time is: Thu May 8 11:42:56 2014 ART 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: ( 4680) seconds. Offline data collection capabilities: (0x5b) SMART execute Offline immediate. Auto Offline data collection on/off support. Suspend Offline collection upon new command. Offline surface scan supported. Self-test supported. No 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: ( 78) minutes. SCT capabilities: (0x003f) SCT Status supported. SCT Error Recovery Control supported. SCT Feature Control supported. SCT Data Table supported. 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 100 100 051 Pre-fail Always - 0 2 Throughput_Performance 0x0026 252 252 000 Old_age Always - 0 3 Spin_Up_Time 0x0023 083 082 025 Pre-fail Always - 5341 4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 146 5 Reallocated_Sector_Ct 0x0033 252 252 010 Pre-fail Always - 0 7 Seek_Error_Rate 0x002e 252 252 051 Old_age Always - 0 8 Seek_Time_Performance 0x0024 252 252 015 Old_age Offline - 0 9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 27588 10 Spin_Retry_Count 0x0032 252 252 051 Old_age Always - 0 11 Calibration_Retry_Count 0x0032 252 252 000 Old_age Always - 0 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 150 191 G-Sense_Error_Rate 0x0022 252 252 000 Old_age Always - 0 192 Power-Off_Retract_Count 0x0022 252 252 000 Old_age Always - 0 194 Temperature_Celsius 0x0002 064 059 000 Old_age Always - 31 (Min/Max 13/41) 195 Hardware_ECC_Recovered 0x003a 100 100 000 Old_age Always - 0 196 Reallocated_Event_Count 0x0032 252 252 000 Old_age Always - 0 197 Current_Pending_Sector 0x0032 252 252 000 Old_age Always - 0 198 Offline_Uncorrectable 0x0030 252 252 000 Old_age Offline - 0 199 UDMA_CRC_Error_Count 0x0036 200 200 000 Old_age Always - 0 200 Multi_Zone_Error_Rate 0x002a 100 100 000 Old_age Always - 1 223 Load_Retry_Count 0x0032 252 252 000 Old_age Always - 0 225 Load_Cycle_Count 0x0032 100 100 000 Old_age Always - 150 SMART Error Log Version: 1 No Errors Logged SMART Self-test log structure revision number 1 No self-tests have been logged. [To run self-tests, use: smartctl -t] SMART Selective self-test log data structure revision number 0 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.
Para ver rápidamente el estado de salud del disco reportado por S.M.A.R.T., ejecutar smartctl -H
:
[root@centos6 ~]# smartctl -H /dev/sda smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-431.el6.x86_64] (local build) Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED
Los discos con soporte S.M.A.R.T. tienen la capacidad de realizar una serie de auto tests (self-tests).
El test "short" realiza una verificación del rendimiento eléctrico y mecánico del disco, al igual que de la performance de las lecturas. Los test eléctricos pueden incluir una verificación del buffer RAM, un test del circuito de lectura/escritura, o un test de los elementos de lectura/escritura de los cabezales. Los test mecánicos incluyen los mecanismos de seeking y servo sobre los tracks de datos. Además se escanean algunas partes de la superficie del disco (el área a escanear depende del fabricante y el test tiene un límite de tiempo). Finalmente se revisa la lista de sectores pendientes que puedan tener errores. El test toma generalmente dos minutos, por ello su nombre.
El test "long/extended" es una versión exhaustiva del test corto, escanea la superficie completa del disco sin límite de tiempo. Aproximadamente requiere un minuto por cada gigabyte en discos modernos.
El test "conveyance" (transporte, en inglés) es un test rápido para identificar daños incurridos durante el transporte del dispositivo desde el fabricante de discos al fabricante de equipos. Sólo para discos ATA.
Finalmente, en algunos discos se permite ejecutar el test "selective", que escanea sólo una parte de la superficie.
La herramienta smartctl
permite ejecutar cualquiera de estos tests.
Para listar los tests que han sido llevados a cabo en un disco, utilizar la opción -l
:
[root@centos6 ~]# smartctl -l selftest /dev/sda smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-431.el6.x86_64] (local build) Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net === START OF READ SMART DATA SECTION === SMART Self-test log structure revision number 1 No self-tests have been logged. [To run self-tests, use: smartctl -t]
La herramienta reporta que no se ha ejecutado ningún test recientemente. Para hacer un test rápido (short) ejecutar:
[root@centos6 ~]# smartctl --test=short /dev/sda smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-431.el6.x86_64] (local build) Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net === 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 2 minutes for test to complete. Test will complete after Thu May 8 11:44:38 2014 Use smartctl -X to abort test.
El test comienza y, tal como se observa, finalizará en 2 minutos. Si dentro de ese lapso de tiempo se vuelve a listar la información S.M.A.R.T., se puede observar el progreso del test:
[root@centos6 ~]# smartctl -a /dev/sda
Self-test execution status: ( 248) Self-test routine in progress... 80% of test remaining.
Note: selective self-test log revision number (0) not 1 implies that no selective self-test has ever been run SMART Selective self-test log data structure revision number 0 Note: revision number not 1 implies that no selective self-test has ever been run SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS 1 0 0 Self_test_in_progress [80% left] (0-65535) 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.
Luego de los dos minutos, es posible ver el resultado del test ejecutando nuevamente smartctl -l selftest
:
[root@centos6 ~]# smartctl -l selftest /dev/sda smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-431.el6.x86_64] (local build) Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net === 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% 27588 -
Se observa que el test finalizó sin errores, y el disco ha acumulado 27588 horas de uso, lo que equivale aproximadamente a π años.
Espero que sea de gran utilidad.