115

Why is defragmenting unnecessary in Ubuntu?

1
  • 3
    It is not unnecessary, and depending on your use, you may want to defrag every once in a while. XFS/ext4 are both simple to defrag. Just use the tools for them, they will be done in no time. EXT4 (Ubuntu default - ext4.wiki.kernel.org/index.php/…)
    – Apache
    May 12, 2014 at 15:37

5 Answers 5

66

The underlying filesystems used by Ubuntu, like ext2 and ext3, simply don't need defragmenting because they don't fragment files in the same way as NTFS. There are more details at ext3 - Wikipedia, the free encyclopedia

7
  • 4
    Ubuntu is actually using ext4 now. Aug 5, 2010 at 12:50
  • 20
    ext4 is based on ext3 is based on ext2. :)
    – Broam
    Aug 5, 2010 at 16:28
  • 52
    -1. Actually, they might very well need defragmentation, just to a much lesser degree.
    – andol
    Aug 5, 2010 at 19:06
  • 3
    If you have a SSD you do not have to defragment it either.
    – Lekensteyn
    Dec 1, 2012 at 8:52
  • 4
    @andol, having some fragmentation does not mean you need to defrag. Windows "needs" it because it creates ridiculous levels of fragmentation. A small amount doesn't make any real difference, and Linux is very good at keeping it to an absolute minimum.
    – psusi
    Nov 18, 2013 at 2:23
59

Some argue that it's actually a myth that we don't need defragmentation. It's argued that we do in fact need it, but only once the filesystem gets pretty full (i.e. less than ~10% free space). Tools are available for defragging such as e2defrag.

4
  • 17
    And those "some" are correct. It's not possible to not-fragment if there's just plain nowhere else left to write.
    – maco
    Aug 14, 2010 at 3:41
  • 2
    Well one could argue that when you have less than 10% free space defragging for more free space isn't going to be your biggest problem and that a new hard disc could be wiser decision ;-)
    – Rinzwind
    May 10, 2011 at 9:44
  • 7
    Watch out! Taken from this website:en.wikipedia.org/wiki/Ext3#Defragmentation " There is no online ext3 defragmentation tool that works on the filesystem level. An offline ext2 defragmenter, e2defrag, exists but requires that the ext3 filesystem be converted back to ext2 first. But depending on the feature bits turned on in the filesystem, e2defrag may destroy data; it does not know how to treat many of the newer ext3 features."
    – Celso
    Jan 22, 2012 at 17:34
  • 7
    @Celso, see launchpad.net/e2defrag... it now does understand ext3/4.
    – psusi
    Jul 13, 2013 at 18:28
26

Fragmentation is the product of writing files in the first available open blocks on a drive. Over time, as files get created and deleted, small sections of disk open up, which causes newly written files to be split over several such openings. This can reduce performance, although it was much more of a problem in the past with slow hardware and slow disks.

The default filesystem in Ubuntu, ext4 (and until recently, ext3) are designed to limit fragmentation of files as far as possible. When writing files, it tries to keep the blocks used sequential or close together. This renders defragmentation effectively unnecessary.

1
  • 1
    Source for this info?
    – JimLohse
    Jul 16, 2016 at 18:47
9

See this link. It gives quite a detailed explanation of how files are stored in Windows and in Linux, and why Linux filesystems usually do not need to be defragmented.

3
4

Ext4 Howto - Ext4 According to this article ext4 defragments on the fly but they are working on a defrag tool. I personally don't think it is needed except maybe for file servers that get heavy use.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .