Figure: Physical Layout of the EXT2 File system
The Second Extended File system was devised (by Rémy Card) as an extensible and powerful file system for Linux. It is also the most successful file system so far in the Linux community and is the basis for all of the currently shipping Linux distributions.
The EXT2 file system, like a lot of the file systems, is built on the premise that the
data held in files is kept in data blocks.
These data blocks are all of the same length and, although that length can
vary between different EXT2 file systems the block size of a particular
EXT2 file system is set when it is created (using
The figure above shows the layout of the EXT2 file system as occupying a series of blocks in a block structured device. So far as each file system is concerned, block devices are just a series of blocks that can be read and written. A file system does not need to concern itself with where on the physical media a block should be put, that is the job of the device’s driver. Whenever a file system needs to read information or data from the block device containing it, it requests that its supporting device driver reads an integral number of blocks. The EXT2 file system divides the logical partition that it occupies into Block Groups.
Each group duplicates information critical to the integrity of the file system as well as holding real files and directories as blocks of information and data. This duplication is neccessary should a disaster occur and the file system need recovering. The subsections describe in more detail the contents of each Block Group.
One benefit of the ext2fs over the extfs is the size of the file systems that can be managed. Currently (after some enhancements in the VFS layer), the ext2fs can access file systems as large as 4TB. In contrast to other UNIXs, the ext2fs uses a variable length directory and can have files names that are as long as 255 characters.
When creating the file system, the ext2fs enables you to choose what size block you want. Using larger blocks will speed up the data transfer because the head disk does not need to look (seek) as much. However, if you have a lot of small files, a larger block size means you waste more space.
Also to speed up access, the ext2fs
uses a technique called a “fast
With a fast symbolic link, the path to the file is stored in the
Another advantages of the ext2fs is its reliability. The ext2fs is made of what are
called “block groups.” Each block group has a block group
There is also an entry that contains the number of directories within the group block. When creating a new directory, the system will try to put the directory into the block group with the fewest directories. This makes accessing any one directory quicker.
Because the block group contains copies of the primary control structures, it can be
repaired by these copies should the
There’s still more! The ext2fs will preallocate up to eight adjacent blocks when it allocates a block for a file. This gives the file a little room to grow. By preallocating the blocks, you have a file that is located in the same area of the disk. This speeds up all sequential accesses.
The directories entries in the ext2fs are in a singly linked list, as compared to an array with fixed entry lengths on some systems. Within the directory entry, you will find the name of the file as well as the inode number. Note that this is the only place where the name of the file appears. In addition, there’s a field that has the total length of the record in bytes (which is always a multiple of 4) that is then used to calculate the start of the next block. Therefore, there are no pointers as in other linked lists.
When a file is deleted, the