Vía Menéame me entero de la existencia de las smartmontools. Se trata de una herramienta capaz de monitorizar los discos y proporcionarnos un detallado informe sobre su estado, así como el tiempo aproximado de vida (en horas) del dispositivo.
Los paquetes están en los repositorios tanto en Debian como en Ubuntu por tanto para instalarlo podemos dejar que apt-get haga el trabajo:
apt-get install smartmontools
Si no tenemos S.M.A.R.T. activado al lanzar el comando para generar el informe nos mostrará un error:
$ smartctl -t short /dev/hdb smartctl version 5.36 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ SMART Disabled. Use option -s with argument 'on' to enable it.
Por tanto seguiremos las instrucciones y usaremos el parámetro "-s on" para activar S.M.A.R.T. en el disco:
$ smartctl -s on -t short /dev/hdb smartctl version 5.36 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF ENABLE/DISABLE COMMANDS SECTION === SMART Enabled. === 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 mod e" successful. Testing has begun. Please wait 2 minutes for test to complete. Test will complete after Sat Oct 20 19:17:18 2007 Use smartctl -X to abort test.
Esperaremos un par de minutos, y ya podemos ver el resultado del informe:
$ smartctl -l selftest -i /dev/hdb smartctl version 5.36 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF INFORMATION SECTION === Model Family: Seagate U10 family Device Model: ST310212A Serial Number: 7EG11PBP Firmware Version: 3.02 User Capacity: 10,242,892,800 bytes Device is: In smartctl database [for details use: -P show] ATA Version is: 5 ATA Standard is: Exact ATA specification draft version not indicated Local Time is: Sat Oct 20 19:27:35 2007 CEST SMART support is: Available - device has SMART capability. SMART support is: Enabled === 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% 7074 -
Por tanto segun S.M.A.R.T a nuestro disco le quedan lleva funcionando ya 7074 horas (gracias a Israel por la aclaración), o lo que es lo mismo menos de un año (294 días y 18 horas). Ya os contaré, puede que el año que viene por estas fechas en breve tenga que cambiar de disco
El servidor smartd, que también viene incluido en el paquete, no se activa por defecto por tanto si queremos inciarlo debemos editar el fichero /etc/default/smartmontools y decirle que discos vamos a monitorizar (en nuestro caso /dev/hdb) y que se arranque por defecto:
# Defaults for smartmontools initscript (/etc/init.d/smartmontools) # This is a POSIX shell fragment # List of devices you want to explicitly enable S.M.A.R.T. for # Not needed (and not recommended) if the device is monitored by smartd enable_smart="/dev/hdb" # uncomment to start smartd on system startup start_smartd=yes # uncomment to pass additional options to smartd on startup #smartd_opts="--interval=1800"
Ya podemos iniciar el sevidor smartmontools:
$ /etc/init.d/smartmontools start Enabling S.M.A.R.T..../dev/hdb...done. Starting S.M.A.R.T. daemon: smartd.
Las herramientas nos permiten hacer múltiples verificaciones, como información general del disco:
$ smartctl -i /dev/hdb smartctl version 5.36 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF INFORMATION SECTION === Model Family: Seagate U10 family Device Model: ST310212A Serial Number: 7EG11PBP Firmware Version: 3.02 User Capacity: 10,242,892,800 bytes Device is: In smartctl database [for details use: -P show] ATA Version is: 5 ATA Standard is: Exact ATA specification draft version not indicated Local Time is: Sat Oct 20 20:14:49 2007 CEST SMART support is: Available - device has SMART capability. SMART support is: Enabled
El estado de salud:
$ smartctl -Hc /dev/hdb smartctl version 5.36 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED General SMART Values: Offline data collection status: (0x82) Offline data collection activity was completed without error. Auto Offline Data Collection: Enabled. 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: (2400) seconds. Offline data collection capabilities: (0x1d) SMART execute Offline immediate. No Auto Offline data collection support. Abort Offline collection upon new command. Offline surface scan supported. Self-test supported. No Conveyance Self-test supported. No 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. No General Purpose Logging support. Short self-test routine recommended polling time: ( 2) minutes. Extended self-test routine recommended polling time: ( 14) minutes.
Atributos específicos SMART del disco:
$ smartctl -A /dev/hdb smartctl version 5.36 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === 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 0x0008 084 060 000 Old_age Offline - 3948270 3 Spin_Up_Time 0x0006 098 098 000 Old_age Always - 0 4 Start_Stop_Count 0x0013 099 099 020 Pre-fail Always - 1776 5 Reallocated_Sector_Ct 0x0013 100 100 036 Pre-fail Always - 22 7 Seek_Error_Rate 0x0009 065 058 030 Pre-fail Offline - 7 9 Power_On_Hours 0x0012 092 092 000 Old_age Always - 7075 10 Spin_Retry_Count 0x0013 100 100 090 Pre-fail Always - 0 12 Power_Cycle_Count 0x0013 099 099 000 Pre-fail Always - 1764 197 Current_Pending_Sector 0x0030 100 100 000 Old_age Offline - 0 198 Offline_Uncorrectable 0x0030 100 100 000 Old_age Offline - 0 199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always - 7
Ver un log de errores, como veréis nuestro pobrecito disco está hecho polvo
:
smartctl -l error /dev/hdb smartctl version 5.36 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF READ SMART DATA SECTION === SMART Error Log Version: 1 ATA Error Count: 58 (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 58 occurred at disk power-on lifetime: 7046 hours (293 days + 14 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 -- -- -- -- -- -- -- 84 51 00 11 43 31 f1 Error: ABRT at LBA = 0x01314311 = 20005649 Commands leading to the command that caused the error were: CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name -- -- -- -- -- -- -- -- ---------------- -------------------- 20 00 08 80 42 31 f1 00 00:01:57.426 READ SECTOR(S) e1 00 08 81 42 31 f1 00 00:01:57.230 IDLE IMMEDIATE c8 00 08 80 42 31 f1 00 00:01:27.176 READ DMA c8 00 08 00 00 00 f0 00 00:00:57.061 READ DMA f8 00 01 00 00 00 f0 00 00:00:57.047 READ NATIVE MAX ADDRESS Error 57 occurred at disk power-on lifetime: 6999 hours (291 days + 15 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 -- -- -- -- -- -- -- 84 51 00 d1 42 31 f1 Error: ABRT at LBA = 0x013142d1 = 20005585 Commands leading to the command that caused the error were: CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name -- -- -- -- -- -- -- -- ---------------- -------------------- 20 00 02 10 43 31 f1 00 00:04:24.061 READ SECTOR(S) e1 00 02 11 43 31 f1 00 00:04:23.852 IDLE IMMEDIATE 20 00 08 80 42 31 f1 00 00:03:53.738 READ SECTOR(S) e1 00 08 81 42 31 f1 02 00:03:53.541 IDLE IMMEDIATE c8 00 08 80 42 31 f1 00 00:03:23.484 READ DMA Error 56 occurred at disk power-on lifetime: 6984 hours (291 days + 0 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 -- -- -- -- -- -- -- 84 51 00 d1 42 31 f1 Error: ABRT at LBA = 0x013142d1 = 20005585 Commands leading to the command that caused the error were: CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name -- -- -- -- -- -- -- -- ---------------- -------------------- 20 00 02 10 43 31 f1 00 00:01:57.207 READ SECTOR(S) e1 00 02 11 43 31 f1 00 00:01:57.007 IDLE IMMEDIATE 20 00 08 80 42 31 f1 00 00:01:26.912 READ SECTOR(S) e1 00 08 81 42 31 f1 00 00:01:26.707 IDLE IMMEDIATE c8 00 08 80 42 31 f1 00 00:00:56.648 READ DMA Error 55 occurred at disk power-on lifetime: 6984 hours (291 days + 0 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 -- -- -- -- -- -- -- 84 51 00 d1 42 31 f1 Error: ABRT at LBA = 0x013142d1 = 20005585 Commands leading to the command that caused the error were: CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name -- -- -- -- -- -- -- -- ---------------- -------------------- 20 00 02 10 43 31 f1 00 00:01:52.648 READ SECTOR(S) 20 00 08 80 42 31 f1 00 00:01:22.323 READ SECTOR(S) e1 00 08 81 42 31 f1 00 00:01:22.126 IDLE IMMEDIATE c8 00 08 80 42 31 f1 00 00:00:52.074 READ DMA c8 00 08 00 00 00 f0 00 00:00:21.959 READ DMA Error 54 occurred at disk power-on lifetime: 6984 hours (291 days + 0 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 -- -- -- -- -- -- -- 84 51 00 11 43 31 f1 Error: ABRT at LBA = 0x01314311 = 20005649 Commands leading to the command that caused the error were: CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name -- -- -- -- -- -- -- -- ---------------- -------------------- 20 00 08 80 42 31 f1 00 00:01:22.323 READ SECTOR(S) e1 00 08 81 42 31 f1 00 00:01:22.126 IDLE IMMEDIATE c8 00 08 80 42 31 f1 00 00:00:52.074 READ DMA c8 00 08 00 00 00 f0 00 00:00:21.959 READ DMA f8 00 01 00 00 00 f0 00 00:00:21.945 READ NATIVE MAX ADDRESS
Si queremos realizar pruebas silenciosas, y que smartd nos envie un correo sólo cuando sea detectado algún error, deberemos modificar las siguientes líneas en el archivo de /etc/smartd.conf, donde le indicaremos el disco y la dirección de correo donde deben ser enviados dichos informes:
# A very silent check. Only report SMART health status if it fails # But send an email in this case /dev/hdc -H -m josepantoni.to****@gmail.com
Desde luego con este servidor tan viejo, vienen bien herramientas así.
Referencias:
Comentarios
7074 NO son las horas que le quedan, son las horas que ya lleva
Atención que en el informe de SMART:
Esto NO significa que el disco tenga 7074 horas de vida! Significa que el teste fue corrido cuando el disco YA TENÍA 7074 horas de uso. La palabra "Remaining" está indicando un campo a parte, es la leyenda del campo del porcentaje, que indica el porcentaje que falta para que el teste acabe de ejecutarse (en este caso 00% porque el teste ya acabó).
Las herramientas SMART no indican directamente las horas de vida que le quedan a un disco. Cuando mencionan Lifetime se refieren al tiempo que el disco ya tiene de uso, no el que le queda. Las horas de uso son usadas para medir el tiempo en que sucedió algo, porque el disco no tiene un reloj interno con fecha - apenas tiene un contador de horas de utilización.
Gracias Israel
Gracias Israel por la aclaración,
la verdad es que pensando en el tema, ahora veo como caí en la trampa. Es mucho más lógico que se cuenten las horas de uso que predecir el tiempo que le queda al disco para que falle.
Saludos.