Why the Linux operating system does not require defragmentation

Source: Internet
Author: User
Tags file system require linux

If you're a Linux user, you might have heard that you don't need to defragment your Linux filesystem. You may also notice that the Linux distribution does not have a disk defragmentation tool attached to it. Why is that? Want to know why in normal use, the Linux file system does not need to defragment, and Windows wants to. You need to understand why fragments are generated, and how Linux and Windows two file systems work separately.

Tutorial

What is a fragment

Many Windows users, even if they don't have much experience, I'm sure they will defragment them regularly to speed up their computers. Why do this, many people do not know.

Simply put, each hard drive has a lot of sectors, and each sector can contain small pieces of data. For exceptionally large files, it must be stored in many different sectors. For example, some of the different files stored in the file system, each of which will be stored in a contiguous space in the sector. Later, you update the file you originally saved and increase the size of the file. The file system will try to store the new portion of the file next to the original sector space. Unfortunately, if there is not enough contiguous space, the file must be split into fragments-this is why the fragment was generated. When your hard drive reads the file, the head must skip over the different physical locations on the hard drive to read the data for each sector-that's why it slows down.

Defragmentation is a centralized process that moves bit files to reduce fragmentation and ensures that each file is contiguous on the drive.

Of course, unlike SSD, it has no moving parts and should not be defragmented-defragmenting the SSD actually reduces its service life. Also, on the latest version of Windows, you don't have to worry about defragmenting your file system fragments-windows will automatically help you do it.

How the Windows file system works

Microsoft's old FAT file system, the last time you see the default in Windows 98 and me, is now also used on a USB flash drive, and it can't intelligently schedule files. When you save the file to the FAT file system, it saves it as close to the beginning of the disk as possible. When you save the second file, it is saved immediately after the first file, and so on. When the original file size grows and there is no free space for them to grow, they will always generate fragments.

Microsoft's new NTFS file system, used on Windows XP and 2000, seems to be a little more intelligent, allocating more "buffer" free space around the files on the hard drive. Although, any Windows user can tell you that, over time, the NTFS file system will still generate fragmentation.

By using these file systems to work, they need to defragment to ensure that their performance does not degrade. Microsoft's latest version of Windows can run defragmentation in the background to alleviate the problem.

How the Linux file system works

Linux has ext2, ext3, and Ext4 file systems, EXT4 file systems are used in Ubuntu and other current Linux distributions, and it has a smarter way of allocating files, rather than putting multiple files closer to each other on the hard disk. The Linux file system is spread across different file disks and leaves a lot of free space. When a file needs to be edited to grow, there is usually enough free space. If the fragment does occur, the file system will attempt to move the file to reduce fragmentation. In normal use, you do not need the defragmentation tool.

If your file system is full or 95% (or even 80%), you may start to see some fragments. In short, file system design, in the normal use of the process can avoid the production of debris.

If you have a fragmentation problem on your Linux, you may need a larger hard drive. If you do need to defragment the file system, the simplest and most reliable method is to copy all the files from the partition, clear all the files from the partition, and then copy the files back to the partition. This allows the file system to intelligently allocate files to disk.

You can also use the fsck command to measure fragmentation of the Linux file system-looking for output "nonadjacent nodes."

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.