I use the following perl script to check when the next fsck will occur:
#!/usr/bin/perl -w
use strict;
my $mountcount = 0;
my $maxmount = 0;
my $dev;
my $mountpoint;
my $fstype;
my $debug = 0;
my $cmd = "mount";
open MOUNT, sprintf ( "%s |", $cmd ) or die sprintf ( "ERROR: Cannot execute %s - %s\n", $cmd, $! );
while ( <MOUNT> ) {
chomp;
( $dev, undef, $mountpoint, undef, $fstype, undef ) = split;
printf "Found device %s\n", $dev if ( $debug > 0 );
if ( $fstype =~ /^ext/i ) {
$cmd = sprintf "dumpe2fs -h %s 2>&1", $dev;
open DUMPE2FS, sprintf ( "%s |", $cmd ) or die sprintf ( "ERROR: Unable to execute %s - %s\n", $cmd, $! );
while ( <DUMPE2FS> ) {
chomp;
if ( /^Mount count:/ ) {
( undef, $mountcount ) = split /:/;
$mountcount =~ s/\s*//g;
printf "Mount count = %s\n", $mountcount if ( $debug > 0 );
}
if ( /^Maximum mount count:/ ) {
( undef, $maxmount ) = split /:/;
$maxmount =~ s/\s*//g;
printf "Maximum mount count = %s\n", $maxmount if ( $debug > 0 );
}
}
close DUMPE2FS;
printf "Filesystem %s, mounted on %s will be checked in %s mounts\n", $dev, $mountpoint, $maxmount - $mountcount;
}
}
close MOUNT;
I have it run in my ~/.bashrc so I always know when my filesystems will be checked, though I use ext4 now which doesn't suffer from extended fsck times, it's still nice to know.
Typical output is something like:
Filesystem /dev/sda1, mounted on / will be checked in 5 mounts
user@localhost ~ $