how much space does hard-linking save? (a script for your boss!)

Matt Bernstein mb/cyrus at dcs.qmul.ac.uk
Wed Jun 11 06:52:57 EDT 2003


I was wondering how much space Cyrus' hard-linking tricks saved us.. as an
academic department (with about 800 users) a lot of e-mail goes out to
student lists, for example. So.. while waiting for an fsck after a major
power cut I wrote this natty little perl script:

#!/usr/bin/perl -w

use strict; $|=1; print "   net G  gross G avgLinks\n";
my @x;  our($n1, $n2, $n3, $n4, $y, $gig) = (0, 0, 0, 0, 1, 1024**3);
sub splat { printf "%8.3f%8.3f%8.3f\r", $n1/$gig, $n2/$gig, $n3/$n4 }

open(M, 'find /var/spool/cyrus/mail/user -type f -name "*."|')
        or die "fork: $!";

while (<M>) {
        chomp;
        @x = stat;
        $n1 += $x[7], $n2 += $x[3] * $x[7], $n3 += $x[3], $n4++;
        $y = 100, splat unless $y--
}

splat, close M, print "\n\n"


I was quite surprised at the results:

   net G  gross G avgLinks
  15.666 130.019  47.589

..so, having thought an 80G volume for the mailstore wasn't overly 
generous, now I can up everyone's quota for the next academic year :)

Thanks! (and remember to configure your MTA to batch it all together..)




More information about the Info-cyrus mailing list