ext4 File System: Introduction and Benchmarks
Destined to become the default file system for the more popular Linux distributions, ext4 is out of experimental mode and gearing up for production environments. Here's what you need to know.
The first development snapshot of ext4 was added to the 2.6.19 kernel but was marked as experimental. The patches that marked ext4 as a stable file system were merged on Oct. 11, 2008 in the 2.6.28 kernel source (and the peasants rejoiced). The only bad spot as of the writing of this article is that you can’t use ext4 as the boot partition because grub doesn’t understand it (although that is being actively worked upon).
Recently, Fedora Core 11 has announced that ext4 will be the default file system. Also Ubuntu 9.0.4 will support ext4 but not necessarily use it as the default file system. I’m sure other distributions will enable it by default. Really, all you need is a kernel 2.6.28 or newer and a very recent version of e2fsprogs and you’re off to the races.
Creating ext4 File Systems and Benchmarking
To you get you started, let’s take a fresh SATA II drive and show how to format ext4 and then take it for a spin and compare it to ext3.
Creating an ext4 file system from scratch is very easy (as easy as ext3). I will assume that you have a kernel that is ext4 capable (2.6.28 or greater) along with the latest version of e2fsprogs (see this link for even more help). For the examples that follow, I’m using a couple of Seagate ST3500641AS 500GB disks that appear as /dev/sda and /dev/sdb in my little home box (it’s old enough that I’m embarrassed to say what it is). The box also has 1GB of memory and is running CentOS 5.2. I’m using a 220.127.116.11 kernel built by hand along with version 1.41.4 of e2fsprogs.
A simple way to start is by using,
% mke2fs -t ext4 /dev/sda1
This is a pretty easy way to create an ext4 file system but it assumes all of the defaults.
To learn a bit more about what defaults are in ext4 you can use tune2fs.
% tune2fs -l /dev/sda1 | more
Here’s a quick sample of what the output might look like:
tune2fs 1.41.4 (27-Jan-2009)
Filesystem volume name:
Last mounted on:
Filesystem UUID: 9db1edc1-69bf-4644-be16-78262d6ffb3a
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 30531584
Block count: 122096000
Reserved block count: 6104800
Free blocks: 120129098
Free inodes: 30531573
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 994
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
Flex block group size: 16
Filesystem created: Sun Mar 15 15:57:09 2009
Last mount time: Sun Mar 15 16:06:53 2009
Last write time: Sun Mar 15 16:06:53 2009
Mount count: 1
Maximum mount count: 33
Last checked: Sun Mar 15 15:57:09 2009
Check interval: 15552000 (6 months)
Next check after: Fri Sep 11 15:57:09 2009
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: 3aabc48e-6505-41f7-9c62-06b106fe975c
Journal backup: inode blocks
Next: Benchmarking ext4 vs. ext3