Why Linux is so embarrassing, no defragmentation

  


As a Windows system user, you will begin to envy Linux, because Linux file system does not need defragmentation. Such awkward behavior, can not help but let the system users' partners are shocked, and after the shock, found that the Linux distribution does not have the function of defragmentation. Why is this?

To understand why the Linux file system does not fragment as much as the Windows file system, you first need to understand how the fragmentation is generated, as well as the file systems of the two operating systems. How does the way of working differ?

What is disk fragmentation?

We all believe that regularly defragmenting the file system will make our computer run faster, but we don't know why? Why is it? Very simple reason.

This is because a hard drive contains many sectors, and each sector can store a small amount of data. For files, especially for larger files, they must be stored in many different sectors. Suppose you have many different files in your file system, each of which is stored in a contiguous group of sectors. Then, you increase the size of one of the files. The file system first attempts to store the newly added portion of the file in a sector immediately adjacent to the original sector group. But if there are not enough consecutive sectors in it, the file must be broken down into smaller pieces, which are visible to you. When your hard disk reads these files, its head must jump between different physical locations to read successive sectors, which slows it down.

Defragmentation is a sophisticated process of reducing fragmentation by moving files bit by bit (bits are the smallest unit of storage on disk) to ensure that each file is continuously stored on the hard disk. .

Of course, this is a bit different for SSDs. SSDs don't need to move files or defragment. Because defragmenting an SSD (Solid State Drive) will reduce its life. Moreover, in the latest version of Windows, you no longer need to worry about defragmentation, because Windows will automatically do it for you.

How Windows File System Works

The FAT file system used by Microsoft —— was last seen as the default system in Windows 98 and ME, although this system is still in USB Using —— in a drive does not work well with files. When you save a file in the FAT file system, it will arrange the file as much as possible on the head of the disk. When you store the next file, it will store the file directly after 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 part.

Microsoft's newer NTFS file system used in Windows XP and 2000 is trying to be smarter. This file system will place more free space around the file called "buffer", but any Windows user will tell you that the NTFS file system will one day be fragmented.

Because of the performance of the file system, they need to defragment to maintain performance. Microsoft can only mitigate this problem by running the defragmenter automatically in the background on the latest version of Windows.

How Linux's file system works

Linux's ext2, ext3, ext4 file system ——ext4 is the file system —— used by Ubuntu and most current distributions A smarter way to place files. The Linux file system spreads the files across the disk, leaving a lot of free space between the files, rather than placing the files one by one like Windows. When a file is edited and becomes larger, there is usually enough free space to save the file. If the fragmentation really occurs, the file system will try to move the file in daily use to reduce fragmentation, so there is no need for a dedicated defragmenter.

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

If you really have a bit of trouble with Linux, you might need a bigger hard drive. If you really need to defragment a file system, the simplest and most reliable way is to copy all the files, then empty the original partition and copy the files back. The file system will intelligently place the file as you copy it back.

In fact, you can also use the fsck command to detect the fragmentation of a Linux file system. You only need to view the non-contiguous inodes in the output. After understanding the workflow of Windows and Linux file systems, Linux is so devoid of defragmentation, we now know.

Copyright © Windows knowledge All Rights Reserved