Some of the cool things you can do with files on an ext2 filesystem:

- Create files up to 4 terabytes in size
- Create files up to 255 characters in length
- You can choose how many bytes to use per inode sizes (1024, 2048, 4096). During an installation of a distribution, Slackware is the only one I know of that will actually prompt the user and ask them. This is done using the -i option with mke2fs.

Set your file as immutable: chattr +i filename
You can't remove this file. You can't rename it. You can't modify it. It's great fun to use on friends. Only root may set or remove this attribute.

More information can be found out about special ext2fs attributes in chattr(1) and lsattr(1). Great details about ext2 can also be found doing a search on Google.


This file system was developed by Dr. Stephen Tweedie (and others) in response to the GNU/Linux operating system's need for a feature-rich file system that could handle large files and devices. During Linus Torvalds' initial design work on the Linux kernel he made it compatible with the Minix file system, as that OS was commonly used in academia, and was widely documented and tested. Unfortunately, the Minix file system was limited to drives and file sizes of 64 megabytes, which even in 1991 seemed rather absurd. The Extended File System, ext, was developed and implemented in 1992 to solve this problem, but even its 2 gigabyte file/device size proved to be a limitation for high end use. In 1993, the alpha code for the Second Extended File System, ext2, was released by Dr. Tweedie.

With ext2 it became possible to mount devices with 4 terabytes of storage, roughly enough space to store a fifth of the text content of the Library of Congress. Files contained by the system can have filenames 255 (or up to 1012 by changing a single line of code) characters long, and be up to 2 gigabytes in size. On top of this, the file system code was specifically written with modularity and extensibility in mind, and various features necessary to a commercial Unix environment were added.

After its code base and performance stabilized, early 1994-ish, ext2 became the de-facto file system used by any computer running Linux, regardless of which distribution it ran. Up through about 2001 this remained true, though with Suse switching to ReiserFS and Redhat going with ext3, it is beginning to change. Still, if I had to hazard a guess, I'd say something like 80% of Linux users are still working in ext2, so, knowing Linux users, it will be around for quite a while longer.


Crucial to understanding how ext2 (or most any other Unix-esque file system) works is the concept of the inode, the lowest common denominator of file storage description. Each inode holds the access rights, timestamps, size, and type of the file, as well as pointers to the blocks which actually hold its data. Each of the blocks can either be to direct blocks, which themselves hold data, or to indirect blocks, which hold a list of pointers to either direct blocks or more indirect blocks. Because of this recursive nature, it's possible through triply indirect blocks for the file system to hold relatively huge files.

Directories seen in user-space are themselves represented as files, and thus inodes, in the file system. Each directory contains a list of entries, which are composed of a file name and its corresponding inode number. When a request is made to the file system for a specific file, that file's name is converted to the inode number, and the inode is referenced from that point on. Notably, this design allows for the possibility of hard links, by which a single inode is referenced by two or more file names that can be located anywhere in the directory hierarchy. To delete a file or a hard link, the file system removes the file name and decrements its inode's link count. When the link count equals zero, the inode is deallocated.

Unix is designed so that devices are be accessed through special files, usually located in the /dev directory. These are implemented in ext2 as "special files", which use no file system space but provide an access point to the device file. Special files contain two numbers for the kernel's use: the major number, which identifies device type, and the minor number, which gives identical devices a consecutive ordering.

Advanced Features:

Extended file attributes, unavailable in most or all other flavors of Unix, are a user-level feature that ext2 has in spades. The 'c' attribute, for instance, works something like the Windows DoubleSpace concept, making the kernel compress and uncompress the file on each write and read. A file with the 'i' attribute cannot be deleted, renamed, or otherwise modified, and one with 'a' can only be appended to during writing; both of these flags are superuser settable only. Also, a file with the 's' attribute has its blocks randomized and zeroed upon deletion, (hopefully, you paranoiacs) making any data recovery impossible. There are more, to find them execute a man chattr command on a GNU/Linux system.

Ext2 technically allows the user to specify the block size upon creation of the file system, though most distributions don't give the the user that choice. Blocks can be 1024, 2048, or 4096 bytes in size. With larger block sizes, fewer disk accesses are needed as more indirection info and data can be read at a time, which increases the file system's performance. However, larger blocks mean more space may be wasted in the final block of a file, so there is a storage space hit associated with them. Just for reference, all the distributions I'm familiar with set the block size to 4096 by default.

Props out to anybody who covers the Linux Virtual File System, the counterpart to the information presented here. Also, much info comes from the all-important Design and Implementation of the Second Extended Filesystem paper.

Log in or register to write something here or to contact authors.