FreeOS.com logo

FreeOS Most Popular
* Most Read stories
* Commented Stories
* Active Categories
* Non Linux Section
* User Submitters
* Top Polls
* Top Authors
* Top Reviews
* Top Rated
* Top Search Terms

Top Articles
* Writing a Linux device driver
* The Linux filesystem explained
* Samba NT Domain Controller
* Setting up Squid as your caching HTTP/FTP proxy
* Web server tutorial - Part 1

FreeOS Highlights
* Howtos (72)
* Reviews (20)
* Opinions (18)
* Interviews (8)
* News (3)

My FreeOS

Nick:
Pass:
Register

Forgot your password?

Contact Us
Contact Us

       

Project: Linux triangle Articles triangle

The Second Extended File System - An introduction

By Vans Information <content@vansinfo.com>
Posted: ( 2001-04-11 05:21:02 EST by gatha )

Most of us have been using files ever since we started using computers. And we have always wondered as to how exactly are the files stored on the hard disk. It all seems so abstract. So today, lets take a look at the newer version of file system of the Linux Operating System--the Second Extended File System--and understand its various aspects.

This file system, which draws its inspiration mainly from the Minix file system of the older days written by Andrew Tanenbaum, was the only file system that was available with a free operating system called “Minix”. It was later modified to be used with the Linux system and was called the Extended File System. The Linux file system being used now, called ext2 (Second Extended File System), is a newer version of the Extended file system that also supports the Access Control Lists (ACL).

But, before embarking on a detailed study of the ext2 file system, lets get acquainted with the terminology associated with file systems and volumes. In the later articles we will investigate the design of the ext2 filesystem.

Block: Files on disk are stored in an integral number of fixed size blocks. The size of the blocks is usually a power of 2. By default, the block size of the ext2 file system is 4K. Research, shows that 4K is the most optimal size for a disk block. If the size of a file does not come to a multiple of 4K, part of the last disk block (on an average, half a block) is wasted. In the worst of cases, almost an entire block, having just one byte of the file, is wasted.

The situation is a bit tricky here. If we select a larger block size, then there is wastage of disk space for small-sized files. On the other hand, if we use a very small block size, the number of disk blocks increase exponentially, thereby taking up more book-keeping time for the files. Therefore, selection of blocks has to be given careful thought.

When a file is loaded into memory, the disk blocks are loaded into the buffer cache in main memory. If they are modified, the blocks in the buffers are marked as `Dirty’. It means that these blocks have to be written to disk in order to maintain consistency between the blocks on disk and those in main memory.

Superblock: Superblock is a region at the beginning of every file system where information like the size of the file system, the empty and the filled blocks, their respective counts, and other such data, is stored. A request to access any file from a file system requires access to the file system’s superblock. If the superblock is damaged, then it may be difficult to retrieve data from the disk.

Inode: An inode is an entry in a table for the file system called the Inode Table. The inode contains all kinds of information about the file including its name, size, the number of links, date and time of creation, modification and access. It also contains pointers to the disk-blocks where the file is stored.


Ext2fs utilities
Now let us have a look at some of the utilities in the ext2fsprogs package that is provided with a standard Linux distribution.

* e2fsck:
This program allows us to perform a file system check on a volume that is based on the Ext2 file system. It is like Scandisk for Windows, only much more effective. Here, we can specify a filename to which it will attach all the badblocks. It is flexible enough to allow the user to specify the superblock, if any alternate one is present. Block size for the file system, in case we have compiled the filesystem driver to handle a different block size, can be specified too.

Caution: Never run e2fsck/fsck on any filesystem that is mounted. If we wish to run ‘fsck’, we should ‘unmount’ the filesystem, and then perform an ‘fsck’. Failing to do the above may cause the filesystem to be corrupted.

* tune2fs:
This allows us to tune filesystem parameters to customized settings. Here, we can set the maximum mount count between two filesystem checks, volume label, error behavior, change the reserved information and many other parameters. This utility should be used only when we are sure of what we are doing to the filesystem.

* dumpe2fs:
This program dumps the status of the ext2 file system specified as a parameter to the standard output device. It is useful for analyzing problems as well as accessing general information about the usage of the filesystem. One of the most useful utilities for an ext2-based filesystem.

* mke2fs:
This program allows us to create an ext2 filesystem on a previously unformatted volume. It provides a plethora of options ranging from block size, fragment-size, bytes-per-inode to various RAID options. In its own way, it is one of the most flexible of ext2fs utilities. ‘mke2fs’ is usually run during fresh installation, where new root and other filesystems are being constructed. It should not be run without expert knowledge of the consequences.

* badblocks:
This program searches the disk to check for blocks that have been damaged. It is usually run before installing packages on a new file system or volume. It is advisable to not run this program on a mounted filesystem.

The Second Extended Filesystem of Linux is a state-based file system. It maintains the state of all open files in memory. All files that are opened for any kind of access, have entries in data structures in memory. These data structures maintain the current status of the files loaded from disk to memory. Dirty blocks are identified by entries in these data structures and these can be explicitly written to disk using the ‘bdflush’ command.

The latest version of the Linux file system called ‘ext3’ is said to have journaling support. A Journaling Filesystem is one that keeps logs and checkpoints for all the transactions that have been done, so that if the system crashes it can start restoring file system on disk using the logs starting from the last checkpoint. We shall look into the proposed journaling file system for Linux in the following article.

The e2fsprogs package is available for anonymous ftp from ftp://tsx-11.mit.edu/ in /pub/linux/packages/ext2fs.

Other articles by Vans Information

Current Rating: [ 6.56 / 10 ] Number of Times Rated: [ 64 ]

More Articles
* Know Linux
* If I could re-write Linux
* Interview with Mozilla engineering director Chris Hofmann
* Response to SCO's Open Letter
* GNU Linux Security

Contents
Articles
  Howtos
  Interviews
  News
  Opinions
  Reviews
Comparison
Links
  Articles
  Howtos
  Interviews
  Opinions
  Reviews
  Websites
News

Linux
About Linux

Print It!
Printer Friendly Version