How do I defragmemt a partition on Linux?

conveyed my question in short; need urgent help.

-ilan

The filesystems in Linux don't need defragmentaion, like Windows. If your filesystem is corrupted though, you need to recover it (or at least try to); check the man pages for "fsck" - "check and repair a Linux file system"

if your filesystem becomes too slow due to fragmentation (there is fragmentation under linux!) you can simply copy your files (if possible) to an other disk or filesystem. delete the old filesystem and copy the data back. afaik there is no defrag tool for linux.....

Thanks for the replies DukeNuke2 & sysgate!
It is not that my system has gone slow...but, defragmentation on a volume is kind of customer scenario I want to test with the product I work!!

-ilan

volumemanager like veritas vm have a defrag tool. but the price is high... very high!

...hold on a second here. This very much depends on what filesystem you are using. fsck on some of the journalled filesystems may do noting short of destroying them for example I would not suggest this on ext3 or reiser filesystems.

A full fsck should not destroy a filesystem. I heard that fsck on ext3 is nasty. Reiser too? Seesh... those filesystems are broken and I would not use them until they work correctly. Veritas filesystems are journalled and extent-based. I have run a full fsck on many Veritas filesystems. There is nothing about journalled or extent-based filesystems that makes them inherently non-repairable. However, fsck does not defrag them, it only repairs damage.

The Veritas defrag tool is for the Veritas filesystem, not the Veritas volume manager. The Veritas filesystem and the Veritas Volume Manager are two different things and it is possible to use one without using the other. Using a volume manager in a clueless manner could indeed cause a form of fragmentation, but the defrag tool won't help that.

The Windows/DOS FAT filesystem family can fragment and then benefit from defraging. Linux supports FAT and a lot of us use FAT filesystems on multiboot systems to share files between Windows and Linux. I have always booted back to Windows to defrag a FAT filesystem. I don't know if Linux has a FAT defrag tool. I don't know of one offhand, but I have never really looked.

I agree completely, there is indeed nothing in the concept which prevents it, only in implementation. I also have run many fscks on vxfs with DRL logs enabled and there has never been a destroyed filesystem as a result. likewise UFS with logging enabled.

I have (deliberately) done this on ext3 and reiser(can't remember which one ) and ended up with nothing good afterwards. I certainly would recommend not using them for now for this reason.