If you are a Linux user, you may hear that Linux file systems do not require defragmentation. You may also notice that the Linux distribution does not have the ability to defragment the disk. What is this for?
To understand why Linux file systems do not fragment like Windows ' file systems, you first need to understand how fragments are generated, and how the file systems of these two operating systems work differently.
What is disk fragmentation?
Many Windows users, even some inexperienced users, believe that defragmenting the file system at regular intervals will make their computers run faster. But they don't even know why.
In short, a hard drive contains many sectors, each of which can store a small piece of data. For files, especially larger files, they have to be stored in many different sectors. Suppose you have a file system with many different files, each of which is stored in a contiguous sector group. Then, you increase the size of one of the files. The file system first tries to store the newly added portions of the file in a sector that is next to the original sector group. But if there are not enough contiguous sectors, the file has to be broken down into smaller chunks that are visible to you. When your hard drive reads these files, his head must jump between different physical locations to read contiguous sector groups, which slows it down.
Defragmentation is a sophisticated process of reducing fragmentation by moving files by bit (bit is the smallest unit stored on disk) to ensure that each file is continuously stored on the hard disk.
Of course, this is a bit different for SSDs, and SSDs don't need to move files or defragment them. Because defragmenting an SSD (solid-state drive) can reduce its lifespan. And, in the latest version of Windows, you no longer need to worry about defragmentation because Windows will do it for you automatically.
How Windows's file system works
The FAT file system formerly used by Microsoft-the last time it was seen as the default system-was in Windows 98 and ME, and although the system was also used in USB drives-it was not a good way to arrange files. When you save a file in the FAT file system, it arranges the files to the disk header as much as possible. When you store the next file, it will store the file directly behind the first file, and so on. So when the file gets bigger, there will always be fragments, because there is no space next to the file to store the added parts.
The newer NTFS file system that Microsoft uses in Windows XP and 2000 tries to become smarter. The file system places more free space around the file called "buffers", but any Windows user will tell you that the NTFS file system will someday be fragmented.
Because the file system behaves like this, they need to defragment to maintain performance. Microsoft can alleviate this problem only in the latest version of Windows system by automatically running defragmenter in the background.
How the Linux file system works
Linux's Ext2,ext3,ext4 file system,--EXT4, is the file system used by Ubuntu and most of the current distributions-to place files in a more intelligent way. Linux's file system will spread the files across the disk, leaving a lot of free space between files, rather than placing files one after the other like Windows. When a file is edited and becomes larger, there is usually enough free space to save the file. If the fragmentation really happens, the file system will try to reduce fragmentation by moving files in daily use, so there is no need for a dedicated defragmentation program.
Because of this way of working, you may see fragments after your file system is stuffed. If file system 95% (or even 80%) of space is occupied, you will begin to see some fragments. However, such a file system would have been designed to reduce fragmentation in normal use.
If you're really having trouble with fragmentation on Linux, you'll probably need a bigger hard drive. If you really need to defragment a filesystem, the simplest and most reliable way is to copy all the files and then empty the original partition and copy the files back. The file system intelligently places files in the process of copying them back.
You can use the fsck command to detect how fragmented a Linux file system is, just to see the number of noncontiguous I nodes in the output (non-contiguous inodes).
http://news.cnblogs.com/n/198682/
Why does Linux need no defragmentation?