Product SiteDocumentation Site

Chapter 7.  The Ext4 File System

7.1. Creating an Ext4 File System
7.2. Converting an Ext3 File System to Ext4
7.3. Mounting an Ext4 File System
7.4. Resizing an Ext4 File System
7.5. Other Ext4 File System Utilities
The ext4 file system is a scalable extension of the ext3 file system, which was the default file system in previous versions of Fedora. Ext4 is the default file system of Fedora 14, and can support files and file systems of up to 16 terabytes in size. It also supports an unlimited number of sub-directories (the ext3 file system only supports up to 32,000). Further, ext4 is backward compatible with ext3 and ext2, allowing these older versions to be mounted with the ext4 driver.
Main Features
Ext4 uses extents (as opposed to the traditional block mapping scheme used by ext2 and ext3), which improves performance when using large files and reduces metadata overhead for large files. In addition, ext4 also labels unallocated block groups and inode table sections accordingly, which allows them to be skipped during a file system check. This makes for quicker file system checks, which becomes more beneficial as the file system grows in size.
Allocation Features
The ext4 file system features the following allocation schemes:
  • Persistent pre-allocation
  • Delayed allocation
  • Multi-block allocation
  • Stripe-aware allocation
Because of delayed allocation and other performance optimizations, ext4's behavior of writing files to disk is different from ext3. In ext4, a program's writes to the file system are not guaranteed to be on-disk unless the program issues an fsync() call afterwards.
By default, ext3 automatically forces newly created files to disk almost immediately even without fsync(). This behavior hid bugs in programs that did not use fsync() to to ensure that written data was on-disk. The ext4 file system, on the other hand, often waits several seconds to write out changes to disk, allowing it to combine and reorder writes for better disk performance than ext3


If a system crashes while ext4 is waiting to write out changes to disk, the write will fail (i.e. newly created files will not be on-disk). To prevent this, add an fsync() call to any programs that depend on writes being on-disk.
Other Ext4 Features
The Ext4 file system also supports the following:
  • Extended attributes (xattr), which allows the system to associate several additional name/value pairs per file.
  • Quota journalling, which avoids the need for lengthy quota consistency checks after a crash.
  • "No journalling" mode, which allows users to disable journalling for a slight improvement albeit at the cost of file system integrity
  • Subsecond timestamps

7.1. Creating an Ext4 File System

To create an ext4 file system, use the mkfs.ext4 command. In general, the default options are optimal for most usage scenarios, as in:
mkfs.ext4 /dev/device
Below is a sample output of this command, which displays the resulting file system geometry and features:
mke2fs 1.41.9 (22-Aug-2009)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1954064 inodes, 7813614 blocks
390680 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
239 block groups
32768 blocks per group, 32768 fragments per group
8176 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
For striped block devices (e.g. RAID5 arrays), the stripe geometry can be specified at the time of file system creation. Using proper stripe geometry greatly enhances performance of an ext4 file system.
When creating file systems on lvm or md volumes, mkfs.ext4 chooses an optimal geometry. This may also be true on some hardware RAIDs which export geometry information to the operating system.
To specify stripe geometry, use the -E option of mkfs.ext4 (i.e. extended file system options) with the following sub-options:
Specifies the RAID chunk size.
Specifies the number of data disks in a RAID device, or the number of stripe units in the stripe.
For both sub-options, value must be specified in file system block units. For example, to create a file system with a 64k stride (i.e. 16 x 4096) on a 4k-block file system, use the following commmand:
mkfs.ext4 -E stride=16,stripe-width=64 /dev/device
For more information about creating file systems, refer to man mkfs.ext4.