Ext4

From Gentoo Linux Wiki

Jump to: navigation, search
Ext4 is the next generation of the Ext filesystem series. It supports much larger disks as well as nanosecond timestamps and extents. For more information see http://kernelnewbies.org/Ext4

Contents

[hide]

[edit] Prerequisites

The linux kernel code for mounting ext4 was marked stable (name changed from ext4dev to ext4) in version 2.6.28. You will need a recent version of e2fsprogs; at least version 1.41. You may choose to use either the stable or the testing version, but the testing version may have updates that fix problems related to ext4, since it is rather new.
emerge -au e2fsprogs

[edit] Installation

Once you have installed the prerequisites, you may continue by emerging the >=2.6.29 kernel.
emerge -au gentoo-sources

[edit] Configuring the kernel

Only one kernel option must be enabled to use ext4:
Linux Kernel Configuration: Ext4 options
File systems  --->
     <*> The Extended 4 (ext4) filesystem
     [ ]   Enable ext4dev compatibility
     [ ]   Ext4 extended attributes
     [ ]     Ext4 POSIX Access Control Lists
     [ ]     Ext4 Security Labels
If you have used the development version of ext4 (ext4dev) make sure you enable that option. If you have only newly-created filesystems (created with the 2.6.28 or later version of ext4), then you don't need the ext4dev option.
Extended attributes and POSIX ACLs only need to be enabled if you intend to make use of them, which is entirely optional.
If you plan to mount an ext4 filesystem with the huge_file feature set, which is enabled by default by mkfs.ext4, you need this option, too.
Linux Kernel Configuration: Ext4 options
Enable the block layer --->
     --- Enable the block layer
     [*]   Support for Large single files
Fix me: This option doesn't seem available for 64bit systems. It seems this option this is as result of the line "depends on !64BIT" in the file block/Kconfig under the section, "config LBD". Can anyone verify this?

To get rid of the "huge_file" default (which is only useful if you intend to have individual files larger than 2 Terabytes), edit the file "/etc/mke2fs.conf" before creating your ext4 filesystems. Once a filesystem is created with huge_file enabled, you will need the feature enabled in the kernel in order to access it. The "huge_file" feature set uses a wider inode index, resulting in unnecessarily large inodes and superblocks. Although the difference is minor, and there have been no reports of performance degradation, logic dictates the potential is there for an incremental performance penalty. Also, huge_file is a relatively new feature that will be under active development during the transition to btrfs. (So I for one have opted out, given that I don't have any 2TB+ files.)
Although it is enabled by default, you can get rid of it by changing "huge_file" to "large_file" in the "ext4" block of /etc/mke2fs.conf (the section that begins with "ext4 = {"). If you have ext4dev support enabled in the kernel, you would want to make the change in the ext4dev block as well.
If all your ext4 filesystems are created without the huge_file feature set enabled, then you don't need it in your kernel. Alternatively, you may want to switch the default from "huge_file" to "large_file" (as above), but leave support enabled in the kernel (this gives you the option to enable it in the command line later, if you suddenly get an irrepressable urge to create a 2+ TB file, or in case a friend drops by with a 2+ TB file on a USB drive or something).

[edit] Creating a new Ext4 filesystem

If you have a partition that you just want to make a new filesystem on, you can simply run:
mkfs.ext4 /dev/ device
where device is the name of the block device where you want to put the partition.

[edit] Converting an ext3 filesystem to ext4

since ext4 is backwards compatible, you can mount an ext3 partition as ext4:
mount -t ext4 /dev/ device /mnt/ mountpoint
where device is the device you want to mount, and mountpoint is where you want to mount it.
The filesystem will not, however, use many of the new features of ext4. You can enable those with the following:
Warning: This will make the filesystem unable to be mounted as ext3
tune2fs -O extents,uninit_bg,dir_index /dev/ device
It is important that you then run fsck, to make sure everything is ok:
fsck -pf /dev/ device
Note: Using this method, new files will be created using the "extents" method, but old files will not be automatically converted