Tuesday, October 11, 2011

Unix/Linux File System: Overview

A conceptual understanding of file system can help a system administrator in adverse situations whereas can help a developer to debug certain implementations which are not working properly. Any how it can be applied in whatever one wants it to.

What is a File?
File is a collection of data items stored on a storage device, the storage device can be a hard-disk, a Compact Disk etc. Infact whatever that is going to be stored in a computer is in the form of a file. So, it is the last object in a file system tree.

Unix/Linux Supports various types of file systems.
1. EXT2: This is a UNIX file system. It has the concepts of blocks, inodes and directories.
2. EXT3: This is also a UNIX file system. The successor of EXT2 type. It provides Journing capabilites in addition to what EXT2 provides. Journaling helps in fast file system recovery.
3. ISOFS: The file system type used in compact disk.
4. TMPFS: The file system type used by temporary files.
5. SysFS: It is a RAM based file system. Mostly used in kenel related activites.
6. PROCFS: The proc file system acts as an interface to internal data structures in the kernel.
7. NFS: Network File System allows many users to share files at a common place by using cleint sever methodology.

What is a file system?
A file system is nothing but collection of two things:
1. User data
2. Meta data-stores file system structural information such as inodes, directories, permissions etc. I am going to talk about this in the next part of this article.

Above information is the basis of what i am going to talk about, INODES.

inodes
-An inode is a data structure in UNIX operating systems that contains important information pertaining to files within a file system. Almost 1% of the total disk space is allocated to inode tables.

The inode structure is relatively straight forward. This is the information an inode contains:
1. Inode number
2. Mode information which determines the file type and how the file's owner, its group, and others can access the file.
3. Number of links to the file
4. UID of the owner
5. Group ID (GID) of the owner
6. Size of the file
7. Actual number of blocks that the file uses
8. Time last modified
9. Time last accessed
10. Time last changed

so we can say that a inode contains all the infomation of a file except the file name and the actual data.
This was about file. What about the directory. A directory also have an inode number and that pointing to all the inodes that are present in that directory.It is typically not possible to map from an open file to the filename that was used to open it. The operating system immediately converts the filename to an inode number then discards the filename.

The data part is associated with something called an 'inode'. The inode carries the map of where the data is, the file permissions, etc. for the data.



                               .---------------> ! data ! ! data ! etc
                              /                  +---------! !------+
        ! permbits, etc ! data addresses !
       +-------------inode-------------+


The filename part carries a name and an associated inode number.

                         .--------------> ! permbits, etc ! addresses !
                        /                   +-------------inode-------------+
        ! filename ! inode # !
       +----------------------+

No comments:

Post a Comment