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.
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.
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.
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)
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.)
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:
Softpedia also ran another test on an Ubuntu system and found that Ext4 shaved 8.7 seconds from the system’s booting time: