Do I need to defrag unix filesystems?
I know Windows file systems are very sensitive to fragmentation and Unix such as UFS, ZFS, ext3, or ext4 are not as sensitive.
But, is there any reason to defragment these filesystems at all?
If so, what tools are available for that ?
Quoting Wikipedia's page about the Ext3 Filesystem
Modern Linux filesystem(s) keep fragmentation at a minimum by keeping all blocks in a file close together, even if they can't be stored in consecutive sectors. Some filesystems, like ext3, effectively allocate the free block that is nearest to other blocks in a file. Therefore it is not necessary to worry about fragmentation in a Linux system
Actually, NTFS is not that sensitive to fragmentation. NTFS is significantly better than FAT32 -- in every way -- and is a fully modern filesystem.
I've been running Linux at home since 1996 and have never defragmented any filesystem. I have never had the need. The most I have done in this direction was pay attention to the kind of files I will be putting on a filesystem and using appropriate options when I mkfs
. For example, if a filesystem will primarily contain large files, I'll use a larger block size. If I am making a huge file system but I know it will never have more than 1,000,000 files, then I'll use the -N 1000000
option to limit the number of inodes. In general, I'll tune the filesystem at creation to its task if a particular kind of file will inhabit it.
You don't need to defrag no. But if you still want to do it, you can always use shake.
While ext2 and ext3 do not provide for it (and generally need it less as they keep files relatively together in the first place) ext4 does provide for defrag. This article talks about the e4defrag program. But ext4 is a new filesystem.
However, compared to windows linux file systems are much better at not fragmenting, so I wouldn't worry about it.