Ext4 was released as a functionally complete and stable filesystem in Linux 2.6.28, and it's getting included in all the modern distros (in some cases as the default fs), so if you are using a modern distro, it's possible that you already have Ext4 support and you don't need to modify your system to run Ext4.
It's safe to use it in production environments, but as any piece of software, it has bugs (which are more likely to be hit in the first stable versions). Any known critical bug will be quickly fixed. If you find one, you can contact the Ext4 developers at the ext4 mailing list. They sometimes also can be found on IRC.
Any existing Ext3 filesystem can be mounted as Ext4 without requiring any on-disk format changes. However, it is possible to upgrade an Ext3 filesystem to take advantage of some Ext4 features by running a couple of commands in read-only mode (described in the next section). This means that you can improve the performance, storage limits and features of your current filesystems without reformatting and/or reinstalling your OS and software environment. If you need the advantages of Ext4 on a production system, you can upgrade the filesystem. The procedure is safe and doesn't risk your data (obviously, backup of critical data is recommended, even if you aren't updating your filesystem :). Ext4 will use the new data structures only on new data, the old structures will remain untouched and it will be possible to read/modify them when needed. This means that if you convert your filesystem to Ext4 you won't be able to go back to Ext3 again.
Bigger File System and File Sizes
Currently, Ext3 support 16 TiB of maximum file system size and 2 TiB of maximum file size for 4 KiB block size. Ext4 adds 48-bit block addressing, so it will have 1 EiB1 of maximum file system size and 16 TiB of maximum file size for 4 KiB block size. Why 48-bit and not 64-bit? There are some limitations that would need to be fixed before making Ext4 fully 64-bit capable, which have not been addressed in Ext4, and with 4 KiB block size (212 bytes) the filesystem size limit is already 260 bytes. With 64 KiB block size the limit is 264 bytes so there isn't really a pressing need to have full 64-bit block addresses. The Ext4 data structures have been designed in case this is ever required, so a future update to Ext4 may implement full 64-bit support at some point. 1 EiB will be enough (really :)) until that happens.
- An EiB or Exbibyte is 260 bytes or 1,048,576 TiB.
In order to map blocks beyond 2^32 to a file, extents must be enabled since block maps only know about 32-bit block numbers. As of e2fsprogs 1.42.9, this requirement is enforced by mke2fs.
Sub directory scalability
Right now the maximum possible number of sub directories contained in a single directory in Ext3 is 32000. Ext4 doubles that limit and allows 64000 sub directories.
Traditional, Unix-derived, file systems, like Ext3, use a indirect block mapping scheme to keep track of each block used for the blocks corresponding to the data of a file. This is inefficient for large files, especially during large file delete and truncate operations, because the mapping keeps an entry for every single block, and big files have many blocks -> huge mappings, slow to handle. Modern file systems use a different approach called "extents". An extent is basically a bunch of contiguous physical blocks. It basically says "The data is in the next n blocks". For example, a 100 MiB file can be allocated into a single extent of that size, instead of needing to create the indirect mapping for 25600 blocks (4 KiB per block). Huge files are split in several extents. Extents improve the performance and also help to reduce the fragmentation, since an extent encourages continuous layouts on the disk.
When Ext3 needs to write new data to the disk, there's a block allocator that decides which free blocks will be used to write the data. But the Ext3 block allocator only allocates one block (4KiB) at a time. That means that if the system needs to write the 100 MiB data mentioned in the previous point, it will need to call the block allocator 25600 times (and it was just 100 MiB!). Not only this is inefficient, it doesn't allow the block allocator to optimize the allocation policy because it doesn't know how many total data is being allocated, it only knows about a single block. Ext4 uses a "multiblock allocator" (mballoc) which allocates many blocks in a single call, instead of a single block per call, avoiding a lot of overhead. This improves the performance, and it's particularly useful with delayed allocation and extents. This feature doesn't affect the disk format. Also, note that the Ext4 block/inode allocator has other improvements, described in details in this paper.
Delayed allocation is a performance feature (it doesn't change the disk format) found in a few modern filesystems such as XFS, ZFS, btrfs or Reiser 4, and it consists in delaying the allocation of blocks as much as possible, contrary to what traditionally filesystems (such as Ext3, reiser3, etc) do: allocate the blocks as soon as possible. For example, if a process write()s, the filesystem code will allocate immediately the blocks where the data will be placed - even if the data is not being written right now to the disk and it's going to be kept in the cache for some time. This approach has disadvantages. For example when a process is writing continually to a file that grows, successive write()s allocate blocks for the data, but they don't know if the file will keep growing. Delayed allocation, on the other hand, does not allocate the blocks immediately when the process write()s, rather, it delays the allocation of the blocks while the file is kept in cache, until it is really going to be written to the disk. This gives the block allocator the opportunity to optimize the allocation in situations where the old system couldn't. Delayed allocation plays very nicely with the two previous features mentioned, extents and multiblock allocation, because in many workloads when the file is written finally to the disk it will be allocated in extents whose block allocation is done with the mballoc allocator. The performance is much better, and the fragmentation is much improved in some workloads.
Fsck is a very slow operation, especially the first step: checking all the inodes in the file system. In Ext4, at the end of each group's inode table will be stored a list of unused inodes (with a checksum, for safety), so fsck will not check those inodes. The result is that total fsck time improves from 2 to 20 times, depending on the number of used inodes (http://kerneltrap.org/Linux/Improving_fsck_Speeds_in_Ext4). It must be noticed that it's fsck, and not Ext4, who will build the list of unused inodes. This means that you must run fsck to get the list of unused inodes built, and only the next fsck run will be faster (you need to pass a fsck in order to convert a Ext3 filesystem to Ext4 anyway). There's also a feature that takes part in this fsck speed up - "flexible block groups" - that also speeds up file system operations.
The journal is the most used part of the disk, making the blocks that form part of it more prone to hardware failure. And recovering from a corrupted journal can lead to massive corruption. Ext4 checksums the journal data to know if the journal blocks are failing or corrupted. But journal checksumming has a bonus: it allows one to convert the two-phase commit system of Ext3's journaling to a single phase, speeding the filesystem operation up to 20% in some cases - so reliability and performance are improved at the same time. (Note: the part of the feature that improves the performance, the asynchronous logging, is turned off by default for now, and will be enabled in future releases, when its reliability improves)
"No Journaling" mode
Journaling ensures the integrity of the filesystem by keeping a log of the ongoing disk changes. However, it is known to have a small overhead. Some people with special requirements and workloads can run without a journal and its integrity advantages. In Ext4 the journaling feature can be disabled, which provides a small performance improvement.
(This feature is being developed and will be included in future releases). While delayed allocation, extents and multiblock allocation help to reduce the fragmentation, with usage filesystems can still fragment. For example: You write three files in a directory and continually on the disk. Some day you need to update the file of the middle, but the updated file has grown a bit, so there's not enough room for it. You have no option but fragment the excess of data to another place of the disk, which will cause a seek, or allocate the updated file continually in another place, far from the other two files, resulting in seeks if an application needs to read all the files on a directory (say, a file manager doing thumbnails on a directory full of images). Besides, the filesystem can only care about certain types of fragmentation, it can't know, for example, that it must keep all the boot-related files contiguous, because it doesn't know which files are boot-related. To solve this issue, Ext4 will support online defragmentation, and there's a e4defrag tool which can defragment individual files or the whole filesystem.
Larger inodes, nanosecond timestamps, fast extended attributes, inodes reservation...
- Larger inodes: Ext3 supports configurable inode sizes (via the -I mkfs parameter), but the default inode size is 128 bytes. Ext4 will default to 256 bytes. This is needed to accommodate some extra fields (like nanosecond timestamps or inode versioning), and the remaining space of the inode will be used to store extend attributes that are small enough to fit it that space. This will make the access to those attributes much faster, and improves the performance of applications that use extend attributes by a factor of 3-7 times.
- Inode reservation consists in reserving several inodes when a directory is created, expecting that they will be used in the future. This improves the performance, because when new files are created in that directory they'll be able to use the reserved inodes. File creation and deletion is hence more efficient.
- Nanoseconds timestamps means that inode fields like "modified time" will be able to use nanosecond resolution instead of the second resolution of Ext3.
This feature, available in Ext4 in the latest kernel versions, and emulated by glibc in the filesystems that don't support it, allows applications to preallocate disk space: Applications tell the filesystem to preallocate the space, and the filesystem preallocates the necessary blocks and data structures, but there's no data on it until the application really needs to write the data in the future. This is what P2P applications do in their own when they "preallocate" the necessary space for a download that will last hours or days, but implemented much more efficiently by the filesystem and with a generic API. This have several uses: first, to avoid applications (like P2P apps) doing it themselves inefficiently by filling a file with zeros. Second, to improve fragmentation, since the blocks will be allocated at one time, as contiguously as possible. Third, to ensure that applications has always the space they know they will need, which is important for RT-ish applications, since without preallocation the filesystem could get full in the middle of an important operation. The feature is available via the libc posix_fallocate() interface.
Barriers on by default
This is an option that improves the integrity of the filesystem at the cost of some performance (you can disable it with "mount -o barrier=0", recommended trying it if you're benchmarking). From this LWN article: "The filesystem code must, before writing the [journaling] commit record, be absolutely sure that all of the transaction's information has made it to the journal. Just doing the writes in the proper order is insufficient; contemporary drives maintain large internal caches and will reorder operations for better performance. So the filesystem must explicitly instruct the disk to get all of the journal data onto the media before writing the commit record; if the commit record gets written first, the journal may be corrupted. The kernel's block I/O subsystem makes this capability available through the use of barriers; in essence, a barrier forbids the writing of any blocks after the barrier until all blocks written before the barrier are committed to the media. By using barriers, filesystems can make sure that their on-disk structures remain consistent at all times."
Ext4 code implements discard/TRIM
Getting Ext4 code
For the vast majority of users today, ext4 will be included as a default part of any Linux installation, since it has been included in the mainline kernel since 2009.
For people who build their own kernel and utilities
1. Start with a 2.6.29 or later kernel. It is highly recommended that you apply the latest patchset (if available) to get the latest bug fixes. In your kernel's .config file, enable EXT4_FS (along with EXT4_FS_XATTR and EXT4_FS_POSIX_ACL if you like).
2. Compile the latest version of e2fsprogs (as of this writing 1.44.5) from kernel.org. Note that it may be desirable to install the mke2fs.conf file that comes with the e2fsprogs sources in /etc/mke2fs.conf to get the latest features enabled by default, but if you also need to boot with an older kernel it is prudent to stick with the older /etc/mke2fs.conf features and only enable new features on the mke2fs command-line as needed.
For people who are running Fedora and RHEL/CentOS
Recent Fedora is generally very up to date with respect to ext4 code in kernelspace and userspace.
For people who are running RHEL/CentOS
ext4 is included as the default filesystem in RHEL6, and is available in RHEL7 and later.
For people who are running openSuSE
- Run tune2fs -O extents,uninit_bg /dev/ROOT
- Change ext3 to ext4 in /etc/fstab
- Add "ext4" to INITRD_MODULES in /etc/sysconfig/kernel
- Run sudo mkinitrd (takes about 2 min here, dunno why)
- Run e2fsck on the ROOT fs. As this is currently mounted, you might want to change into single user mode (init 1) and remount read-only (mount -o remount,ro /) or just reboot and the bootprocess will complain a bit and run e2fsck anyway - don't know if this is The Right Thing To Do though.
For people who are running Ubuntu
Ubuntu 9.04 and later include ext4 as a manual partitioning option at installation time, including support for ext4 as the root filesystem.
For people who are running Debian
Ext4 has been available since Debian Lenny and later releases.
Creating ext4 filesystems
Creating a new ext4 filesystem is very easy once you have upgraded to e2fsprogs 1.41 or later. Simply type:
# mke2fs -t ext4 /dev/DEV
# mkfs.ext4 /dev/DEV
Once the filesystem is created, it can be mounted as follows:
# mount -t ext4 /dev/DEV /wherever
If you have a sufficiently new system, the "-t ext4" should not be needed.
NOTE: Although very large fileystems are on ext4's feature list, current e2fsprogs currently still limits the filesystem size to 2^32 blocks (16TiB for a 4KiB block filesystem). Allowing filesystems larger than 16T is one of the very next high-priority features to complete for ext4.
Booting from an ext4 filesystem
Ext4 support has been added in the 1.97 version of GRUB2
There's also a Google Summer of Code project (from opensuse) which seem to have developed ext4 support for grub legacy (0.97). Both projects—GRUB2 and the GSoC projects—seem (sadly) to be different efforts.
The grub package in Ubuntu 9.04 and later includes a patch to support booting from ext4 filesystems (see bug 314350).
Syslinux 4.00 and higher (currently in beta) supports ext4 in extlinux. See .
Converting an ext3 filesystem to ext4
This section is now a separate page.
Portions of this article have been taken from the Ext4 article from the Kernel Newbies website. The Kernel Newbies article was written by diegocalleja and was released under Creative Commons Attribution-2.5-Generic license.