Defragmenting your hard disk is a good technique to make your Windows computer faster. When you defragment your hard disk, the various files stored on it are rearranged to occupy continuous locations. This decreases head travel and so the time taken to read and write files is significantly reduced. Defrafragmenting the hard disk also reduces the boot-up time.
In Linux, it is not necessary to defragment your hard disk at all. This is because the Linux file system is much more efficient when compared to Windows. On Windows, you will observe gradual increase in file fragmentation with regular use. When the fragmentation level increases beyond 20% you will notice significant slowdown in performance. On the other hand, fragmentation rarely exceeds 1% on Linux.
If you would like to defragment Linux partitions, you will have to use defragmentation utilities such as “Linux File-system defragmenter” (http://sourceforge.net/projects/defragfs/). This is a command line utility that defrags your Linux partitions. There are other utilities for other Linux file systems.
If you want to use Linux File-system defragmenter on your computer, download the tarball from the link I posted above and expand it. Then, type ‘make’ in the command line and install it on your system. To use it, you have to type:
# defragfs /mnt/hda1
You can also specify -f switch to force defragmentation.
Personally, I wouldn’t bother with defragmenting Linux disks. I am using my current Ubuntu computer since the last six or seven months and it is running just as fast as when I first installed the OS. There may be some performance gain if I defragment the disks but it won’t be significant enough justify messing around. If it is not broken in the first place, why bother fix it?