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.pswp.cn/news/255866.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/255866.shtml
英文地址,請注明出處:http://en.pswp.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 有…