Search...

Monday, November 10, 2014

Unix File System? Unix file structure? Blocks of Unix file system? Structure of regular file?

UNIX File System


Unix treats every thing as a file. All the utilities, applications and data are stored as a file. Even the devices and directories are also stored as a file. A Unix file system resembles an upside down tree. At the top their is root branching other directories called bin,lib, dev, usr, tmp, etc. Their is also a sub directories called UNIX which is nothing but a UNIX kernel it self.





bin: Contain binary executable file.

lib: Contains library function file.

dev: Contains the files related to I/O devices. I/O devices like printer, terminal,disk drives etc. 

usr: contains sub directories each one is associated with particular users. It also contain bin directory which contain additional UNIX command file.

tmp: Contain temporary files created by OS or by users.

etc: Contain binary executable files related to system administration

unix: Contains files related to kernel.

                 The disk space allocated to UNIX file system is made up of blocks. Each block having a size of 512 bytes. Some file system may have a size 1024 or 2048 bytes depending upon how the file system is implemented. It may also change from one UNIX version to another and it rarely exceeds 2048 bytes.

 All the blocks belonging to the Unix file system are logically divided into 4 parts, the first block of the file system is  called Boot Block followed by:  Super Block, Inode Block and Data Block.


 Boot Block: It represents the beginning of the file system. It contains a small program called 'Boot Strap Loader'. This program gets executed when the user boots the host machine. Only 1 boot block is require to start up the system. Like Master Boot Record (MBR) that DOS user would like to call.

Super Block: It describe the state of the file system:

how long the file is ithow many more files it can accommodatehow many more files can be createdLast time of updation etc.

In short, it gives the global information about the disk usage and availability of Data block & inode.


Inode table: As we know Unix treats everything as a file. So, the information related to file (not the content) are stored in the Inode table. For each file their is an entry in the inode table. It is just like a index of our practical note book or assignment. Each entry is of 64 bytes & contain the relevant information:

a) Owner of the fileb)Group of which the owner belongc)File typed)File sizee)File access permissionf)Date & time of last modificationg)Date & time of last accessh)Number of links of the filei)Address of the data block where the file is physically present.


Data Block: Data Block contains the original Data. The allocated block can assign to only 1 file in the file system. This block cannot be used for storing any other content of file till the previous content is deleted.


                              Structure of Regular file:                         


The Unix file system runs with 13 entries in the inode table of contents. As given in the above figure the blocks marked as "direct" contains the number of disk/data block that contains the real data. 

The block marked as "single indirect" contains a list of direct block number. To access data via indirect block the kernel should read the indirect block through that it finds the  direct block number and then access the data. 

The block marked as "double indirect" contains a list of single indirect block number and the block marked as "triple indirect" contains a list of double indirect block number.

                                                                                       




No comments:

Post a Comment