Los sistemas de archivos ext2, ext3 y ext4 poseen varios parámetros configurables, entre los que se destaca la verificación periódica de errores. Esto es, cada vez que el kernel Linux intenta montar un sistema de archivos, debe comprobar antes si es momento para ejecutar una verificación periódica de errores. Esta verificación puede ser cada cierto número de montajes, cada cierto período de tiempo, o ambas.
Es altamente recomendable verificar errores en sistemas de archivos de forma periódica. Discos, cables o memoria en mal estado, así como bugs en el kernel pueden llegar a corromper un sistema de archivos sin marcarlo como dirty o con errores para su verificación automática.
Para determinar el período entre verificaciones se puede utilizar la herramienta tune2fs
:
root@debian:~# tune2fs -l /dev/mapper/debian-root | grep -e "mount count" -e "interval" Maximum mount count: 20 Check interval: 15552000 (6 months)
Este sistema de archivos está configurado para ser verificado automáticamente cada 20 montajes o cada 6 meses (15552000 segundos equivalen a 180 días). Además se observa que fue montado sólo una vez desde la última verificación de errores, la cual ocurrió el día 14 de abril de 2016:
root@debian:~# tune2fs -l /dev/mapper/debian-root | grep -e "Mount count" -e "Last checked" Mount count: 1 Last checked: Thu Apr 14 13:59:23 2016
Esto significa que la próxima verificación automática de errores (e2fsck
) ocurrirá luego de ser montado 19 veces más, o la siguiente vez que intente ser montado luego del día 11 de octubre de 2016 a las 13:59:23 horas (14 de abril de 2016 + 180 días), lo primero que ocurra.
Si se desea modificar el máximo de montajes entre verificaciones, se debe utilizar el parámetro -c
:
-c max-mount-counts Adjust the number of mounts after which the filesystem will be checked by e2fsck(8). If max-mount-counts is 0 or -1, the num‐ ber of times the filesystem is mounted will be disregarded by e2fsck(8) and the kernel. Staggering the mount-counts at which filesystems are forcibly checked will avoid all filesystems being checked at one time when using journaled filesystems. You should strongly consider the consequences of disabling mount-count-dependent checking entirely. Bad disk drives, cables, memory, and kernel bugs could all corrupt a filesystem without marking the filesystem dirty or in error. If you are using journaling on your filesystem, your filesystem will never be marked dirty, so it will not normally be checked. A filesystem error detected by the kernel will still force an fsck on the next reboot, but it may already be too late to pre‐ vent data loss at that point. See also the -i option for time-dependent checking.
Los valores 0 y -1 hacen que el kernel y e2fsck
ignoren el número de veces que el filesystem ha sido montado.
Para modificar el intervalo de días entre verificaciones, utilizar -i
:
-i interval-between-checks[d|m|w] Adjust the maximal time between two filesystem checks. No suf‐ fix or d will interpret the number interval-between-checks as days, m as months, and w as weeks. A value of zero will dis‐ able the time-dependent checking. It is strongly recommended that either -c (mount-count-depen‐ dent) or -i (time-dependent) checking be enabled to force peri‐ odic full e2fsck(8) checking of the filesystem. Failure to do so may lead to filesystem corruption (due to bad disks, cables, memory, or kernel bugs) going unnoticed, ultimately resulting in data loss or corruption.
Es posible utilizar los sufijos d
, m
y w
para especificar días, meses y semanas respectivamente.
De acuerdo al manual de tune2fs
, se debe utilizar al menos uno de los intervalos (preferentemente ambos) para verificar errores automáticamente y de forma periódica.
Para más información:
man tune2fs man e2fsck