Uso il seguente script perl per verificare quando si verificherà il prossimo fsck:
#!/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;
L'ho eseguito nel mio ~ / .bashrc, quindi so sempre quando verrà controllato il mio filesystem, anche se uso ext4 ora che non soffre di tempi fsck estesi, è comunque bello saperlo.
L'output tipico è qualcosa del tipo:
Filesystem /dev/sda1, mounted on / will be checked in 5 mounts
user@localhost ~ $