Why does Linux not need to be fragmented?

Source: Internet
Author: User
Why does Linux not need to be fragmented? -- Linux general technology-Linux technology and application information. for details, refer to the following section. Source: geek fan

If you are a Linux user, you may hear that the Linux file system does not need to be fragmented. You may also notice that neither the Linux release nor the disk fragment function is available. Why?

The disk fragmentation function is not available in Linux.

To understand why Linux file systems do not generate fragments like Windows file systems, you must first understand how fragments are produced, what are the differences in how the file systems of these two operating systems work.

What is disk fragmentation?

Many Windows users, and even some inexperienced users, believe that regular sorting of fragments in the file system will make their computers run faster. But they do not know why.

Simply put, a hard drive contains many sectors, each of which can store a small piece of data. For files, especially large files, they must be stored in many different sectors. Assume that your file system contains many different files, each of which is stored in a continuous sector group. Then, you increase the size of a file. The file system first tries to store the newly added part of the file in a sector next to the original sector group. However, if there are not enough continuous slices, this file must be broken down into multiple small blocks, which are visible to you. When your hard disk reads these files, its head must jump between different physical locations to read continuous sector groups, which reduces its speed.

Fragment is a precise process of moving files by bit (the smallest unit of files stored on the disk) to reduce fragments, this ensures that each file is continuously stored in the hard disk.

Of course, this is a little different for Solid State Disks. they do not need to move files or fragment. Because fragment of an SSD (solid state drive) will reduce its service life. In addition, in the latest version of Windows, you do not need to worry about fragment, because Windows will automatically help you.

How does a Windows file system work?

The FAT file system used by Microsoft in the past-the last time it was seen as the default system was in Windows 98 and ME, although the system was still used in a USB drive-it was not able to arrange files well. When you save a file in the FAT file system, it will try its best to arrange the file in the first part of the disk. When you store the next file, it will store the file directly behind the first file, and so on. So when the file grows, fragments will always be generated, because there is no space next to the file to store the added part.

Compared with the new NTFS file system, Microsoft tries to become smarter. the file system places more free space named "buffer zone" around the file. However, any Windows user will tell you that the NTFS file system will generate fragments one day.

Because of the performance of file systems, they need to fragment to maintain performance. Microsoft can only alleviate this problem in the latest Windows system by automatically running the fragment program in the background.

How does a Linux file system work?

Ext2, ext3, and ext4 file systems in Linux -- ext4 is a file system used by Ubuntu and most of the current releases -- it can be placed in a more intelligent way. The Linux file system will distribute files across the entire disk, leaving a lot of free space between files, rather than placing files one by one like Windows. When an object is edited and becomes larger, there is usually enough free space to save the object. If fragments are generated, the file system will try to move the files to reduce fragments in daily use, so no special fragment programs are required.

Because of this way of working, you may see fragments after your file system is full. If 95% (or even 80%) of the file system space is occupied, you will start to see some fragments. However, such a file system is designed to reduce fragments in common use.

If you are troubled by fragmentation on Linux, you may need a larger hard disk. If you really need to fragment a file system, the simplest and most reliable method is to copy all the files, clear the original partitions, and copy the files back. The file system intelligently places the file when you copy it back.

You can use the fsck command to check the degree of fragmentation of a Linux file system. you only need to check the number of non-consecutive I nodes (non-contiguous inodes) in the output.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.