HTG Explains: Why Linux Doesn’t Need Defragmenting


image

If you’re a Linux user, you’ve probably heard that you don’t need to defragment your Linux file systems. You’ll also notice that Linux distributions don’t come with disk-defragmenting utilities. But why is that?

To understand why Linux file systems don’t need defragmenting in normal use – and Windows ones do – you’ll need to understand why fragmentation occurs and how Linux and Windows file systems work differently from each other.

What Fragmentation Is

Many Windows users, even inexperienced ones, believe that regularly defragmenting their file systems will speed up their computer. What many people don’t know is why this is.

In short, a hard disk drive has a number of sectors on it, each of which can contain a small piece of data. Files, particularly large ones, must be stored across a number of different sectors. Let’s say you save a number of different files to your file system. Each of these files will be stored in a contiguous cluster of sectors. Later, you update one of the files you originally saved, increasing the file’s size. The file system will attempt to store the new parts of the file right next to the original parts. Unfortunately, if there’s not enough uninterrupted room, the file must be split into multiple pieces – this all happens transparently to you. When your hard disk reads the file, its heads must skip around between different physical locations on the hard drive to read each chunk of sectors — this slows things down.

Defragmenting is an intensive process that moves the bits of files around to reduce fragmentation, ensuring each file is contiguous on the drive.

Of course, this is different for solid state drives, which don’t have moving parts and shouldn’t be defragmented – defragmenting an SSD will actually reduce its life. And, on the latest versions of Windows, you don’t really need to worry about defragmenting your file systems – Windows does this automatically for you. For more information on best practices for defragmenting, read this article:

HTG Explains: Do You Really Need to Defrag Your PC?

How Windows File Systems Work

Microsoft’s old FAT file system – last seen by default on Windows 98 and ME, although it’s still in use on USB flash drives today – doesn’t attempt to arrange files intelligently. When you save a file to a FAT file system, it saves it as close to the start of the disk as possible. When you save a second file, it saves it right after the first file – and so on. When the original files grow in size, they will always become fragmented. There’s no nearby room for them to grow into.

Microsoft’s newer NTFS file system, which made its way onto consumer PCs with Windows XP and 2000, tries to be a bit smarter. It allocates more “buffer” free space around files on the drive, although, as any Windows user can tell you, NTFS file systems still become fragmented over time.

Because of the way these file systems work, they need to be defragmented to stay at peak performance. Microsoft has alleviated this problem by running the defragmentation process in the background on the latest versions of Windows.

How Linux File Systems Work

Linux’s ext2, ext3, and ext4 file systems – ext4 being the file system used by Ubuntu and most other current Linux distributions – allocates files in a more intelligent way. Instead of placing multiple files near each other on the hard disk, Linux file systems scatter different files all over the disk, leaving a large amount of free space between them. When a file is edited and needs to grow, there’s usually plenty of free space for the file to grow into. If fragmentation does occur, the file system will attempt to move the files around to reduce fragmentation in normal use, without the need for a defragmentation utility.

Because of the way this approach works, you will start to see fragmentation if your file system fills up. If it’s 95% (or even 80%) full, you’ll start to see some fragmentation. However, the file system is designed to avoid fragmentation in normal use.

If you do have problems with fragmentation on Linux, you probably need a larger hard disk. If you actually need to defragment a file system, the simplest way is probably the most reliable: Copy all the files off the partition, erase the files from the partition, then copy the files back onto the partition. The file system will intelligently allocate the files as you copy them back onto the disk.

中文翻译版本:http://my.oschina.net/liux/blog/61636


==============================================================================
本文转自被遗忘的博客园博客,原文链接:http://www.cnblogs.com/rollenholt/articles/2545316.html,如需转载请自行联系原作者


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/255866.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Spring AOP 实战运用

Spring AOP 实战 看了上面这么多的理论知识, 不知道大家有没有觉得枯燥哈. 不过不要急, 俗话说理论是实践的基础, 对 Spring AOP 有了基本的理论认识后, 我们来看一下下面几个具体的例子吧.下面的几个例子是我在工作中所遇见的比较常用的 Spring AOP 的使用场景, 我精简了很多有…

VC Ws2_32.lib

该库对应WS2_32.DLL,提供了对以下网络相关API的支持,若使用其中的API,则应该将ws2_32.lib加入工程(否则要动态载入WS2_32.DLL)。acceptbindcloseSOCKETconnectgetpeernamegetsocknamegetsockopthtonlhtonsioctlsocketi…

大话设计模式之策略模式

第二章:商场促销——策略模式 策略模式的定义:策略模式是一种定义一系列算法的方法,从概念上来看,所有这些算法完成的都是相同的工作,知识实现不同,他可以以相同的方式调用所有的算法,减少了各类算法类与使…

【Python学习】——语言风格(变量赋值、深浅拷贝、for循环陷阱)

目录 1、赋值 2、赋值的分类——引用赋值、值赋值 1) 不可变对象引用赋值——字符串、数值、元组等 2)可变对象引用赋值——列表、集合、字典 3)可变与不可变对象的引用赋值内部分析 4)在py文件中,和作用域有关,如…

underscore.js 页面数据渲染

1.underscore.js 源码 // Underscore.js 1.8.3 // http://underscorejs.org // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors // Underscore may be freely distributed under the MIT license.(function() {// …

判断庄家是否出货

1. 大盘处于强势的时候 日平均线在横盘的时候,缓慢拉升然后急剧下跌 高位盘整的时候 2. 有利好消息发布的时候 因为庄家会利用这个对于散户来说这个买入时机来进行出货操作,可见庄家真是阴险狡诈转载于:https://www.cnblogs.com/dcz1001/p/6115893.html

【深度学习】——常见深度学习模型总结、anchor-free和anchor-based

目录 1、faster rcnn: 2、SSD: 3、YOLOv1: 小结: 拓展:anchor-based和anchor-free anchor 1、faster rcnn: FasterRcnn 算法原理讲解笔记(非常详细)https://blog.csdn.net/xjtdw/article…

PHP PDO函数库详解

PDO是一个“数据库访问抽象层”,作用是统一各种数据库的访问接口,与mysql和mysqli的函数库相比,PDO让跨数据库的使用更具有亲和力;与ADODB和MDB2相比,PDO更高效。目前而言,实现“数据库抽象层”任重而道远&…

数据交互相关分享

Python与web Python Web.py与AJAX交互转载于:https://juejin.im/post/5a40af3d6fb9a044ff31b1f5

springMVC 相对于 Structs 的优势

智者说,没有经过自己的思考和估量,就不能接受别人的东西。资料只能是一个参考,至于是否正确,还得自己去分辨 SpringMVC相对于Structs的几个优势: 1、springMVC安全性更高,structs2框架是类级别的拦截&#…

YOLOV1学习

YOLOV1学习(输入的图像固定大小为448X448X3) 参考文献 模型结构 将输入的图像归一化为大小为448x448x3的图像,然后将经过中间24层的卷积后得到了7x7x1024的特征图,然后后面连接的是两个全连接层,分别是4096和1470&am…

KUKA通信 CREAD问题

嗨。 我想通过串行端口1发送X,Y,Z,A,B,C坐标给机器人。 G1: ...... CREAD(HANDLE,SR_T,MR_T,TIMEOUT,OFFSET,"%F",X) P.XX CREAD(HANDLE,SR_T,MR_T,TIMEOUT,OFFSET,"%F",Y) P.YY ...... GOTO G1…

bzoj 1901: Zju2112 Dynamic Rankings

Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 6245 Solved: 2593[Submit][Status][Discuss]Description 给定一个含有n个数的序列a[1],a[2],a[3]……a[n],程序必须回答这样的询问:对于给定的i,j,k,在a[i],a[i1],a[i2]……a[j]中第k小的…

第 36 章 RRDTool

36.1. install $ apt-get install rrdtool原文出处:Netkiller 系列 手札 本文作者:陈景峯 转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

手机号码已经注册写到数据库中,如何利用相同手机号码再次注册?

手机号码已经注册写到数据库中,如何利用相同手机号码再次注册? 解:删除数据库中以前注册的手机号码就可以了啊,delete那条记录,转载于:https://www.cnblogs.com/panxuejun/p/6122499.html

腾讯技术研究类和数据分析第一次笔试(2021.8.22)——Python

第一题:开锁——数学期望 # 最优策略:钥匙的选择先从消耗时间最少的开始选择,然后选择第二小的依次类推 # 开锁概率1/n def openLockTime(n, m, time):time_reverse [] # (n,m)->(m,n)for i in range(m):m_time []for j in range(n):m…

教你怎样选择伺服电机控制方式

伺服电机一般都有三种控制方式:速度控制方式,转矩控制方式,位置控制方式 。 速度控制和转矩控制都是用模拟量来控制的。位置控制是通过发脉冲来控制的。具体采用什么控制方式要根据客户的要求,满足何种运动功能来选择。 …

.Net Discovery系列之四 深入理解.Net垃圾收集机制(下)

上一节给大家介绍了 .Net GC的运行机制,下面来讲下与GC相关的重要方法。 第二节.GC关键方法解析 1.Dispose()方法 Dispose可用于释放所有资源,包括托管的和非托管的,需要自己实现。 大多数的非托管资源都要求手动释放,…

真静态和伪静态的区别

首先肯定的是纯静态和伪静态都是SEO的产物,但纯静态和伪静态还是有很大区别的。 纯静态是生成真实的HTML页面保存到服务器端,用户访问时直接访问这 个HTML页面即可,从而大大的减轻了服务器压力(如dedecms就是采用的纯静态&#xf…

非常有趣的Console

console觉醒之路,打印个动画如何? 原文地址: http://www.helloweba.com/view-blog-383.html 批量去掉或替换文本中的换行符(notepad、sublime text2) 原文地址:http://m.blog.csdn.net/article/details?id43228729 有…