.:My Black Corner:.

Monday, September 08, 2008

Defragmenting Disk di Linux?

Hanya sekedar dokumentasi pribadi. Sebenarnya ini artikel udah lama sih.. Yah buat dokumentasi ga ada salahnya di posting disini. Intinya berikut ini adalah script untuk melakukan defragmenting disk di sistem Linux.

Buat satu script dengan nama terserah.pl.
root# nano terserah.pl

#!/usr/bin/perl -w
######
A W A L
######

# isi filenya sebagai berikut:

#this script search for frag on a fs
use strict;

#number of files
my $files = 0;
#number of fragment
my $fragments = 0;
#number of fragmented files
my $fragfiles = 0;

#search fs for all file
open (FILES, "find " . $ARGV[0] . " -xdev -type f -print0 |");

$/ = "\0";

while (defined (my $file = )) {
open (FRAG, "-|", "filefrag", $file);
my $res = ;
if ($res =~ m/.*:\s+(\d+) extents? found/) {
my $fragment = $1;
$fragments += $fragment;
if ($fragment > 1) {
$fragfiles++;
}
$files++;
} else {
print ("$res : not understand for $file.\n");
}
close (FRAG);
}
close (FILES);

print ( $fragfiles / $files * 100 . "% non contiguous files, " . $fragments / $files . " average fragments.\n");

######
A K H I R
######


Cara menjalankannya:
root# terserah.pl /home
5.4590570719603% non contiguous files, 1.2258064516129 average fragments.

Selamat mencoba, semoga bermanfaat.
http://forums.gentoo.org/viewtopic-p-3111409-highlight-.html#3111409

posted by .:CyberColombuzz:. at 3:03 PM

1 Comments:

Dats, itu untuk file sytem apa, any ?

Thursday, October 01, 2009 8:24:00 PM  

Post a Comment

<< Home