11. Maintenance

11.1. Filesystem inspection

It is a virtuous habit to inspect your ext2 filesystem on the flash memory regularly. To do this, the tool dumpe2fs may be used in the following way: # dumpe2fs -h /dev/sda1 (you must be root and the device should not be mounted). The result should be similar to the following:


             Filesystem volume name:   <none>
             Last mounted on:          <not available>
             Filesystem UUID:          c42a6963-5e6a-4cd2-b7d7-c8f09dca6c52
             Filesystem magic number:  0xEF53
             Filesystem revision #:    1 (dynamic)
             Filesystem features:      dir_index filetype sparse_super
             Default mount options:    (none)
             Filesystem state:         clean
             Errors behavior:          Continue
             Filesystem OS type:       Linux
             Inode count:              32000
             Block count:              127856
             Reserved block count:     6392
             Free blocks:              116456
             Free inodes:              31922
             First block:              1
             Block size:               1024
             Fragment size:            1024
             Blocks per group:         8192
             Fragments per group:      8192
             Inodes per group:         2000
             Inode blocks per group:   250
             Filesystem created:       Sat Sep 20 12:43:00 2003
             Last mount time:          Tue Oct 28 14:13:03 2003
             Last write time:          Tue Oct 28 14:28:27 2003
             Mount count:              13
             Maximum mount count:      35
             Last checked:             Sat Oct 18 11:28:26 2003
             Check interval:           15552000 (6 months)
             Next check after:         Thu Apr 15 11:28:26 2004
             Reserved blocks uid:      0 (user root)
             Reserved blocks gid:      0 (group root)
             First inode:              11
             Inode size:               128
             Default directory hash:   tea
             Directory Hash Seed:      118bee0a-efa5-4771-967e-41a0badd0355
   

A few important aspects need to be pointed out.

You might get warnings about these things when you mount the device or when you try the read files from the device.

11.2. And then?

When the usage allocation has been spent, or there is evidence of file corruption, the thing to do is to run # fsck.ext2 /dev/sda1 with the device unmounted. After that, usage parameters will be freshly allocated and bad blocks will be gone.

Note

When dealing with the vfat system, the dump does not seem to exist. The command # dumpe2fs -f /dev/sda1 for filesystems other than ext2 does not work for vfat. The tool dosfsck exists (it is still Alpha), and may be risky to use on a device you have not formatted yourself.