Linux – How to force fsck on root filesystem on Voyage Linux

debian-squeezefscklinux

I have a Voyage Linux (a Debian derived system) computer (which is headless, ie no display). The root filesystem is marked as corrupted and there are actually some errors.

I would like to fix these errors, but I can't.
I tried several things (shutdown -rF now, touch /forcefsck, set FSCKFIX=yes in /etc/default/rcS, tune2fs -c 1 -C 1 /myfilesystem): no check is done.

After some searches I discovered that the /etc/init.d/checkroot.sh was set to check the /dev/root filesystem:

   fstabroot=/dev/root
   #...
   rootcheck=yes

while df told me this:

Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                     3541948   1156324   2205660  35% /
/dev/disk/by-label/ROOT_FS 3541948   1156324   2205660  35% /

tune2fs indicates this:

# tune2fs -l /dev/disk/by-label/ROOT_FS
tune2fs 1.41.12 (17-May-2010)
Filesystem volume name:   ROOT_FS
Filesystem revision #:    1 (dynamic)
Filesystem features:      ext_attr resize_inode dir_index filetype sparse_super large_file
Filesystem flags:         signed_directory_hash 
Default mount options:    (none)
Filesystem state:         not clean with errors
Errors behavior:          Continue
Filesystem OS type:       Linux
Filesystem created:       Tue Mar 13 09:49:14 2012
Last mount time:          Sat Jan  1 02:36:20 2000
Last write time:          Tue Apr 14 08:38:22 2026
Mount count:              3
Maximum mount count:      1
Last checked:             Fri Jun 15 20:55:44 2012
Check interval:           0 (<none>)
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)

My fstab looks like:

#/dev/hda1      /       ext2    defaults,noatime,rw     0       0
proc            /proc   proc    defaults                0       0
tmpfs       /tmp    tmpfs   nosuid,nodev        0   0
#tmpfs           /rw    tmpfs   defaults,size=32M       0       0

The only way I found to force fsck to run was to modify the /etc/init.d/checkroot.sh setting the following values:

   fstabroot=/dev/disk/by-label/ROOT_FS
   #...
   rootcheck=yes

and then perform 'touch /forcefsck' and reboot

I believe this is a quick and dirty fix to make my FS be repaired.

What can I do to repair this volume using a better practice ?

Best Answer

If you want a partition to be checked during boot, you have to turn on the sixth field - fsckorder bit ON in /etc/fstab. If you set that field to zero then fsck won't check the filesystem. For instance for the root(/) partition you can do this -

/dev/hda1      /       ext2    defaults,noatime,rw     0       1