Operating System - Linux
1753401 Members
7454 Online
108792 Solutions
New Discussion юеВ

Is there a command to defrag fs?

 
K.C. Chan
Trusted Contributor

Is there a command to defrag fs?

Is there a command to defrag filesystem, in particular ext2 and ext3 filesystem. My root fs is 1.2% non-contiguous. Thanks.
Reputation of a thousand years can be determined by the conduct of an hour
2 REPLIES 2
D. Jackson_1
Honored Contributor

Re: Is there a command to defrag fs?

Eric Ladner
Trusted Contributor

Re: Is there a command to defrag fs?

FYI: From the Linux Partition HOWTO

"Noncontiguous placement of blocks in a file is bad for performance, since files are often accessed in a sequential manner. It forces the operating system to split a disk access and the disk to move the head. This is called "external fragmentation" or simply "fragmentation" and is a common problem with MS-DOS file systems. In conjunction with the abysmal buffer cache used by MS-DOS, the effects of file fragmentation on performance are very noticeable. DOS users are accustomed to defragging their disks every few weeks and some have even developed some ritualistic beliefs regarding defragmentation.

None of these habits should be carried over to Linux and ext2. Linux native file systems do not need defragmentation under normal use and this includes any condition with at least 5% of free space on a disk. There is a defragmentation tool for ext2 called defrag, but users are cautioned against casual use. A power outage during such an operation can trash your file system. Since you need to back up your data anyway, simply writing back from your copy will do the job."