KNOW-HOW

The new Ext4 filesystem FIT FOR THE FUTURE

The newest child in the Ext filesystem family provides better performance and supports bigger filesystems. Are you ready for Ext4? Julien

BY MARCEL HILZINGER T r omeur , F o t olia

inux came of age with the intro- strategy lets users around the world con- Another major change with Ext4 is the duction of the filesystem, tinue to use the stable while the de- use of extents. An is a contiguous Land Ext3 was the first journaling velopers integrate and test a new round area of additional disk space saved with filesystem to make it into the kernel. of enhancements. Ext4, the next genera- a file. The purpose of an extent is to en- Through the years, the Ext (Extended) tion of the Extended filesystem, is now sure that later changes will be stored in filesystem family has held an important available for users. We took a look at the same location as the original file. Ex- place in , and Ext remains a popular Ext4 to see how it compares with other tents reduce fragmentation and improve choice for users around the world. But popular filesystem options. write speeds. Several other popular file- the venerable Ext code base is showing systems, such as , NTFS, and the signs of age. Several months ago, devel- What Changes? HPS filesystem, already sup- opers began to discuss the problem of Ext4 moves to better 64-bit support, port extents. adding new features to Ext3 while main- which leads to several other enhance- Backward compatibility was also a taining the stability and compatibility of ments. One important benefit unveiled goal for the Ext4 developers: You can the code [1]. Meanwhile, several initia- with Ext4 is an increase in the maximum an Ext4 partition as Ext3, and tives offered enhancements to the filesys- filesystem size. Ext3’s maximum filesys- you can mount an Ext3 partition as Ext4 tem that were too fundamental to inte- tem size of 8TB (with a default block (with the ext4dev filesystem type). Un- grate easily but too important to ignore. size of 4KB) was once considered huge, fortunately, to achieve this Ext3/ Ext4 The solution proposed by the develop- but contemporary hardware cries out for compatibility, you have to turn off Ext4’s ers was to the code and start work more. Ext4 now supports filesystems of extent feature, which is one of the major on a new filesystem called Ext4. This up to 1024 petabytes (PB). performance benefits of Ext4.

40 ISSUE 79 JUNE 2007 WWW.LINUX - MAGAZINE.COM Ext4 KNOW-HOW

If you are interested in testing Ext4, you only want to add Ext4, need a current kernel and the usual de- just keep pressing Enter veloper tools: make, GCC, and glibc- to accept the defaults. devel. In our lab, we used kernel 2.6.20. Note that the system will Working as root, unpack the sources in not use Ext4 by default. the /usr/src and create a link of To change this, you need /usr/src/linux that points to the sources: to open the .config file and look for the follow- cp linux-2.6.20.tar.bz2 /usr/src ing entry: cd /usr/src tar xvfj linux-2.6.20.tar.bz2 # CONFIG_EXT4DEV_FS U ln -s linux-2.6.20 linux is not set

To let the kernel know which kernel ele- Remove the pound sign ments you want to compile as modules, at the start of the line you need to create a .config file in /usr/ and change the entry to src/linux. To do so, you can issue either CONFIG_EXT4DEV_ Figure 1: To make sure the kernel understands Ext4, you need the make menuconfig or make xconfig FS=m (Figure 1). To to enable the corresponding option in your .config file. command. Because the manual system experiment with Ext4 on with its multitude of options is not easy, your root partition, you will need to make modules_install you might prefer to use the current ker- build the filesystem into the kernel make install nel as the basis for the new configura- rather than using a module. In this case, tion and just add the differences for the change the entry to CONFIG_EXT4DEV_ Most distributions will set up the initial new kernel version. To do so, copy the FS=y, launch make oldconfig again, and ramdisk (initrd) at this point and also /boot/config-kernelversion file to /usr/ then answer a few questions about Ext4 modify the bootloader. When you reboot src/linux and save the file as .config. The (Figure 2). your machine, you should be able to se- following command should do the trick Most current distributions use access lect the new kernel from the Grub menu. for most distributions: control lists (ACLs) and extended attri- Installing the new kernel will not affect butes to support more granular control your existing installation. cp /boot/config$(uname -r) U over user privileges. If the mount com- /usr/src/linux/.config mand output shows you entries for acl Working with Ext4 or user_xattr at the command line, you To create an Ext4 partition, you need a Again working as root, enter the make will need to enable these features on recent version of -Tools [2]. oldconfig command in the /usr/src/linux Ext4 too. So when you are prompted to Users of SUSE Linux will find the current directory to create a new kernel from the enable EXT4DEV_FS_XATTR and SUSE kernel version 2.6.20 and match- existing configuration file. For each EXT4DEV_FS_POSIX_ACL, don’t forget ing E2fsprogrs at suse. com [3] or open- change, the system will prompt you for to say y. SUSE. org [4]. When you install this ker- whether you want the change and how You need security labels (EXT4DEV_ nel, make sure you don’t enter the rpm you want to implement it. Depending on FS_SECURITY) to support SElinux. Make -Uvh command, but use rpm -ivh instead your kernel version, you might need to sure you avoid enabling debugging sup- to keep the openSUSE 10.2 kernel. answer a number of questions. If you port for JBD2 because this will slow the To install Ext2-Tools, just follow the filesystem down. make enables debug- usual steps: ./configure, make, and (as Roadwork Ahead! ging support for JBD (JBD_SUPPORT) by root) make install. If an error occurs at default. the make step, you will probably need Athough Ext4 has officially been part of Linux since kernel 2.6.19, work on the After making your de- new filesystem is far from complete. cisions, type make old- Takashi Sato, for example, is currently config to write the new working on an online re-sizer that .config file, which now checks Ext4 for fragmentation on the fly has Ext4 support en- and corrects any issues it finds. The abled. Then run make to finished Ext4 product will also include start building the kernel. an undelete function. Some of these Depending on how fast new features, however, mean changing the filesystem format, and this could your machine is, this cause issues with existing Ext4 parti- can take a couple of tions. Given the current pace of develop- hours. After completing ment, you might want to think twice the kernel build, enter before moving to Ext3’s successor, the following commands although our tests did not identify any to install the module Figure 2: The second time you run make oldconfig, you only stability problems. and the kernel: need to answer questions on Ext4.

WWW.LINUX - MAGAZINE.COM ISSUE 79 JUNE 2007 41 KNOW-HOW Ext4

�������������������� �������������������

���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���������� ���� ���� ���� ������� ���� ���� ������� ����

���� ������� ������� ���� ���� ��� ��� ��� ��� ��� ��� ��� ��� ����������� ���������� ����� ����

Figure 3: Ext4 writes a 1GB file slightly faster than ReiserFS in a Figure 5: Without extents, Ext4 writes far more slowly and drops blockwise write operation, and Ext4 is far faster than Ext3. down to the level of Ext3.

to install the texinfo package on your commit=seconds option might be of The performance effect of the extents machine. After installing the package, interest. The interval you specify here feature is clearly demonstrated by the just run make again. determines how often Ext4 will write results of the “Random Create” test. It To create a new partition in Ext4 for- data to disk. The default value is every makes sense that Ext4 loses out to Ext3 mat, enter mke2fs -j , re- five seconds. Higher values improve here because it needs extra time to re- placing partition with the required de- performance and can also save power. serve storage space for the extents. This vice file name. You could also use the But note that this compromises the extra work is not required on deleting GUI to create a new Ext3 partition. After safety of any data that have not yet been files, and this is where Ext4 overtakes doing so, mount the partition by enter- saved. This said, our benchmarks failed Ext3 and ReiserFS, which comes in last ing mount -t ext4dev to reveal any significant difference when in the Bonnie++ stress tests. . The kernel will auto- we set this option to commit=60. Finally, we wanted to know how fast matically load the ext4dev module. For our first tests with the developer Ext4 is without extents. Figure 5 shows If you intend to use Ext4’s extents fea- version of Ext4, we put the filesystem the results of the Slow.c benchmarks ture, you need to add -o extents to the through its paces with the Bonnie++ with a 1GB test file. The results show mount command. Note that a partition [5] and Slow.c [6] benchmarks. Our that Ext4’s exceptional write perfor- mounted with extents cannot be choice of distribution was openSUSE mance is mainly due to extents. mounted as Ext3 later. Be sure not to 10.2 with a home-grown kernel 2.6.20 mount existing Ext3 partitions with -o and ext4dev as a module. For our tests, Conclusions extents. If this happens, unmount the we used the -o extents mount option for Ext4 is a fast and future-oriented journ- partition without making any changes to Ext4, unless specified otherwise, and we aling filesystem that is still at an early files; otherwise, you will only be able to used defaults for all other filesystems. stage of development. Although the lack mount the partition as Ext4 in the future. Ext4 achieves far faster write speeds of full downward compatibility to Ext3 The developers are aiming to migrate than its predecessors and actually over- might cause occasional confusion, this is support for extents to the mke2fs and takes its direct competitor ReiserFS (Figure no reason not to deploy Ext4 for produc- tune2fs tools in the future, which will 3) on blockwise write operations for the tion use. You might, however, prefer to remove the need for the mount option. first time. This said, ReiserFS still reads stick with Ext3 as long as the Ext4 devel- Besides these options, Ext4 supports slightly faster than Ext4. Ext4 is not much opers refer to the kernel module as familiar mount parameters for journaling faster than Ext3 when it comes to sequen- ext4dev. ■ filesystems. If you have a laptop, the -o tial creating and deleting of files (Figure 4). INFO ���������������������������������� [1] Ext4 proposal: ����� http:// lkml. org/ lkml/ 2006/ 6/ 28/ 454 ���� ����� ����� ����� ����� [2] E2fsprogs: ����� ���� ftp:// ftp. kernel. org/ pub/ linux/ kernel/ ����� ����� ����� people/ tytso/ e2fsprogs-interim/ ����� ����� �������� ����� ����� [3] SUSE kernel: ftp:// ftp. suse. com/ pub/ ����� ����� projects/ kernel/ kotd/ i386/ HEAD ����� �����

������������ ���� ���� [4] SUSE E2fsprogs: http:// download. ���� . org/ distribution/ ���� SL-OSS-factory/ inst-source/ suse/ i586/ ���� � [5] Bonnie++: ����������������� ����������������� ������������� ������������� http:// www. coker. com. au/ bonnie++/ [6] Slow.c: Figure 4: A special Bonnie++ stress test evaluates how many files the filesystem can create or http:// www. jburgess. uklinux. net/ slow. c delete in a second. Ext4 scores top marks.

42 ISSUE 79 JUNE 2007 WWW.LINUX - MAGAZINE.COM