Saya menggunakan skrip perl berikut untuk memeriksa kapan fsck berikutnya akan terjadi:
#!/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;
Saya telah menjalankannya di ~ / .bashrc saya jadi saya selalu tahu kapan filesystem saya akan diperiksa, meskipun saya menggunakan ext4 sekarang yang tidak mengalami perpanjangan waktu fsck, masih bagus untuk diketahui.
Output khas adalah sesuatu seperti:
Filesystem /dev/sda1, mounted on / will be checked in 5 mounts
user@localhost ~ $