Ext4 Filesystem Explained in Plain English

Published on January 23, 2009 in General by Rami Taibah


Linux Kernel 2.6.28 was released while you were partying on New Years and declared the much anticipated Ext4 filesystem as stable. The web buzzed on how fast and reliable Ext4 and the Ubutnu community celebrated to the news that the upcoming 9.04 version will include Ext4. Ext4 brings a lot of enhancements, but to a non-technical person like me it does sound confusing, with a lot of technical terms that don’t make much sense. So I thought I should read up and do my best to understand Ext4 and how it will enhance our day-to-day computing experience.

Extents

For a system to write a file on a hard disk, it needs a methodology and specific instructions to allocate space. The old Ext3 uses a block mapping scheme: A 100 Mb file will be mapped as 25600 blocks (each block 4Kb), the bigger the file the more blocks it will map, and huge mapping will lead to slower handling.

Today, with the explosion of multimedia and high-speed Internet, this method seems ineffecient. So, Ext4 introduces the concept of Extents. An extent is basically a bunch of blocks. So for our example 100 Mb file, it will basically say “write the data is in the next n blocks” instead of mapping each individual block separately. Ext4 will support up to 128 Mb extents, so for a 1000 Mb file (or 1 Gb), it will map 10 extents instead of 256,000 blocks. This will ultimately improve performance and also help in reducing fragmentation.

extents

Multiblock Allocation

Sounds confusing right? Well let me explain: In our 100 Mb example, Ext3 uses a block allocator that decides which free blocks will be used to write the data. But this allocator can only allocate one block at a time, meaning that a 100 Mb file will need to call the allocator 25600 times! Not exactly efficient right? It’s even worse when one realizes that this block allocator cannot optimize its allocation policy because it doesn’t really how many times it will be called to allocate! It doesn’t really know the size of the file its being asked allocate!

Ext4 will support multi-block allocation, which allocates many blocks in a single call, instead of a single block per call, avoiding a lot of overhead.

Backward Compatibility

If you need the advantages of Ext4, your existing Ext3 can be easily “upgraded” to Ext4 without the need to format. This means that all your data will stay intact once you upgrade (though I would highly recommend backing up)

Online Defragmentation

While the above features greatly reduce the amount of fragmentation in your hard disk, time will most certainly lead to some form of fragmentation. Ext4 will have an online tool which can defragment individual files or entire file systems.(This feature is still not implemented in Linux Kernel 2.6.28, but will be included in future releases.)

Bits and Pieces

  • Faster file system checking: Unallocated blocks are skipped –> Faster checking
  • Improved timestamps: Up to the nanosecond. Which will defer the year 2038 problem
  • Unlimited subdirectories: Ext3 had a limit of 32,000
  • Larger files: Ext4  can support volumes with sizes up to 1 exabyte and files with sizes up to 16 terabyte
  • Ext4 Put to The Test

    The popular Linux hardware blog Phoronix ran an extensive test on the Ext4 benchmarking it against other popular Linux filesystems like Ext3, XFS, JFS, and ReiserFS. The most beaming result was 4GB file writing performance. Ext4 totally blew the others filesystems out of the water:

    ext4-write-performanceSoftpedia also ran another test on an Ubuntu system and found that Ext4 shaved 8.7 seconds from the system’s booting time:

  • Ubuntu 8.10 with EXT3 filesystem boots in 31.8 seconds (on the AMD Sempron system);
  • Ubuntu 9.04 Alpha (Build 20090112.1) with EXT3 filesystem boots in 28.3 seconds (on the AMD Sempron system);
  • Ubuntu 9.04 Alpha (Build 20090112.1) with EXT4 filesystem boots in 23.1 seconds (on the AMD Sempron system).
  • Ubuntu 8.10 with EXT3 filesystem boots in 26.8 seconds (on the Intel Core 2 Duo system);
  • Ubuntu 9.04 Alpha (Build 20090112.1) with EXT3 filesystem boots in 24.5 seconds (on the Intel Core 2 Duo system);
  • Ubuntu 9.04 Alpha (Build 20090112.1) with EXT4 filesystem boots in 21.4 seconds (on the Intel Core 2 Duo system)!

About Rami Taibah

Rami Taibah the founder of The Linuxologist and a self proclaimed geek and Linux aficionado. This fall, he will be pursuing an MIMS degree at UC Berkeley, California. You can follow him on Twitter @rtaibah.

«

»

  • madjr
    well btrfs is the future with built in system rollbacks, i hope we can get that by 11.04
    Fedora already has plans to implement it
    http://www.phoronix.com/scan.php?page=article&item=fedora_13_btrfs&num=1
  • hussein
    ... Good bloke !!
  • fabrizio
    1GB=1024MB
  • Ashley
    I was wondering when theyd come up with something like this. good going! good explanation too.
  • Wow, this is great...

    I will wait for Ubuntu 9.04 :)
  • tim
    how did you get taggly to work? i keep getting a table error.
  • Anon
    I wouldn't call it an improvement if you have to defrag it. But at the same time I don't see why you would have to, from what I make of it it is pretty much just changing the block size and calculating the size of the file so it can allocate all at once, it shouldn't need to be defragmented any more than any other linux system (not at all) the reason Linux doesn't need to be defraged is mainly the way it handles r/w requests... Taken from whylinuxisbetter.net

    "Now imagine your hard disk is a huge file cabinet, with millions of drawers (thanks to Roberto Di Cosmo for this comparison). Each drawer can only contain a fixed amount of data. Therefore, files that are larger than what such a drawer can contain need to be split up. Some files are so large that they need thousands of drawers. And of course, accessing these files is much easier when the drawers they occupy are close to one another in the file cabinet.

    Now imagine you're the owner of this file cabinet, but you don't have time to take care of it, and you want to hire someone to take care of it for you. Two people come for the job, a woman and a man.

    * The man has the following strategy : he just empties the drawers when a file is removed, splits up any new file into smaller pieces the size of a drawer, and randomly stuffs each piece into the first available empty drawer. When you mention that this makes it rather difficult to find all the pieces of a particular file, the response is that a dozen boys must be hired every weekend to put the chest back in order.
    * The woman has a different technique : she keeps track, on a piece of paper, of contiguous empty drawers. When a new file arrives, she searches this list for a sufficiently long row of empty drawers, and this is where the file is placed. In this way, provided there is enough activity, the file cabinet is always tidy.

    Without a doubt, you should hire the woman (you should have known it, women are much better organized ). Well, Windows uses the first method ; Linux uses the second one. The more you use Windows, the slower it is to access files ; the more you use Linux, the faster it is. The choice is up to you!"

    So continuing the above analogy ext4 would be like having bigger drawers and a computer to keep track of the list.

    Hurray for long rambling comments
  • I love Ubuntu, its so much better than everything else. I wish we could spread it more, expose it.
  • Can't wait to try this out in the 9.04 version.
  • I have the 64bit version of Ubuntu 9.04 alpha installed on a Q6600 (2.4ghz Quad Core) w/ 4GB of RAM and a 500MB disk w/ Ext4 filesystem on it. Boots up in about 10 seconds after it POSTs. Very fast.
  • Neat specs Brian. How is the 64-bit system treating you? I really need a new PC, this blog is maintained on a 5 year old Pentium 4 HT! Its killing me LOL. Do you recommend a 64bit system?
  • 64bit is the way to go. My main system is currently 32bit Vista, but when Windows 7 is released, I will convert over to 64bit Windows. I expect starting in late 2009 and early 2010 we'll start seeing more and more native 64bit programs and games.
  • n one
    64bit is terrific. I have had no problems at all with it, and it has the ability to map some insane amount of memory. (16 exabytes?)

    If you dual-boot to windows, stick with a 32bit version of windows for a while longer. There's been problems with their move to 64bit. The driver issues seem to have been worked out, but there's still a lot of programs that totally flip out.

    (btw, I'm the first none. The second none was someone else. Hence I have put a space between the N and ONE to signify I am none one.)
  • Marius
    I run both Vista and Ubuntu 64-bit, with very few problems. None on the windows side (at least none caused by running 64-bit), and the only annoying thing on the linux side is the lack of a java browser plugin for 64-bit.
  • Ooops, I meant 500GB disk. ;)
  • Dritan
    Now that is absolutely fantastic! Ext4 reduces the need for frequent defragmentation, allowing for more available space. So the way I understand it is that when a request for a...31 mb file comes through, the OS will dispatch an allocator to 'extend'/allocate X contiguous blocks that make up 1 huge 'extent' of 31 mb of space. The rest of the untouched blocks are up for grabs for more extents. I'm already liking ext4!!
  • Great article!
  • Docbradd
    HI, I would love to know what is being measured in the graphic. I know that it isn't how long it takes to write 4GB, as Ext4 is easily the slowest of the lot, but if not, then what. I am aware that I am exposing my lack of knowledge regarding the metrics used, but...

    It is the improvements such as these that are a part of considering the shift to Ubuntu and this is a huge step. Now if I could only run Photoshop under such a system, all would be greqt and I could leave Windows for good.

    My email is included, please feel free to send me more info.

    Thanks,

    Brad
  • Symbolis
    I'm not saying it's perfect(I haven't even tried it), but might want to look at http://www.vimeo.com/2213968 on the Photoshop front.
  • Yup! As "none" said (Lol dude put a name, any name, just something that you could be referred to by other than none!) The graph is saying that on Ext4 the 4GB file was transferred 65 Mb/S. Totally trumped XFS, which is a filesystem I used because it was "fast"

    As for your Photoshop question, I have a blog coming up on Photoshop/Photo editing alternatives, so stay tuned ;)
  • none
    Mb/s. The axes are clearly labelled.
  • none
    The 8.7 second improvement on boot times was a combination of the performance improvements for Ubuntu 9.04 alpha and the EXT4 file system. EXT alone only gave 5.2 seconds improvement on the 9.04 AMD build. (3.1 seconds on the Intel build)
  • Thanks for the heads up. 5.2 seconds is still a huge improvement nonetheless :)
  • Jocke
    The first article that really made me understand what Ext4 will bring my computing experience. Now I just need that 1 exabyte hard drive...
  • anoneeee
    what the hell would you do with 1 exabyte? store a deity?
blog comments powered by Disqus