Linux File System

Just imagine an office environment before the arrival of computers.  All the data connected with the office will be available in paper and kept in a file. In a big organization there will be thousands of file. It will be hard to keep track of all these files unless all the files are kept safely and well organized. This not only helps to track a file easily but also improves work efficiency of the place. 

Now lets co-relate the scenario with a computer. Instead of paper files, in a Computer System
the data or the information required for a program  is stored in objects called Computer files or simply files. These files are stored in hard drives and should be made available to the programs when ever required. But who or rather what keeps track on these files? The answer is File System. All operating System whether it is Linux, Unix or Windows make use of a file system to organize files in a computer system. Since this is a Linux blog I am concentrating on Linux Filesystem.

In Linux, Filesystem can mean two things
  1. Hierarchy of directories used to organize files on a computer system
  2. Type of filesystem used by the storage media to organize files on an entire disk or a partition
Lets see the first meaning, i.e the File System Hierarchy. In Linux the directory structure starts or begins with / (forward slash) or the root directory. All the other directories are sub-directories of the root directory and all the files are organized within the root directory and its sub-directories, even if they are stored on different physical or virtual devices. Given below is a sample directory structure of a Linux system.








The directory structure and the contents in Unix/*nix operating system are defined by a standard called Filsystem Hierarchy Standard (FHS). The above image represents how directories are arranged in a Unix/*nix operating system. Lets see what are the importance of each directories and what these directories hold.
Directory Description
/ The Root Directory. Primary or first level of entire filesystem hierarchy
/bin Contains binary commands available all users (eg: ls, cp)
/boot Contains boot loader files required for system boot. (eg : initrd)
/dev Contains device files. (eg: /dev/sda, /dev/lp0)
/etc Contains host specific system-wide configuration files
/home Contains Home Directory of users except root user. A user's home directory contains all the user specific settings and saved files
/lib Contains all the library files required by the binary files
/lost+found Path where results of file recovery is available
/media Path for mounting removable medias like CD-ROM
/mnt Path for temporarily mounted filesystem
/opt Path for optional software installation.Somewhat similar to C:\Program Files\ in windows
/proc Contains run time system information. This is a virtual filesystem
/root Home directory of root user.
/run Contains information regarding the running system
/sbin Contains system binaries used for system maintenance and/or administrative tasks (eg: fdisk)
/srv Contains site specific data served by the system
/sys Contains plug and play (PnP) configuration files
/sysroot the root directory where headers and libraries are located during cross platform compilation
/tmp Contains files which are required temporarily.
/usr Contains all the user binaries, their documentation, libraries, header files
/var Contains variable files. i.e files whose contents are expected to change like log files, mail and printer spool

For a more detailed understanding of Filesystem Hierarchy Standard go to http://www.pathname.com/fhs/pub/fhs-2.3.pdf

The second meaning refers to the type of filesystem used. Disk File System, Network File System, Shared DIsk File System, Database File System etc are some of the classifications of file system types.

 Linux supports many different filesystems. We can configure multiple filesystems in a single linux machine. For example in a windows machine we can create two different partitions and format one partition in FAT32 and the other partition with NTFS. Similarly in Linux we can create two file systems in ext3 and xfs format and mount them under different directories. Filesystems are created at the time of OS installation. We can also make filesystems from inside the OS using mkfs command. Following are the most commonly used Linux Filesystems. Linux supports different filesystems. The most commonly used ones are
  • ext2 - Second Extended File System. Simple and old with less features.Data contained in files are saved in blocks.
  • ext3 - Third Extended File System. ext3 is ext2 + journaling. Jorunaling improves reliability and eliminates the need to check the file system after an unclean shutdown. 
  • reiserfs - Like ext3, reiserfs is a journaled filesystem. It is faster and efficient for both small and large files
  • xfs - high performing, data consistent journaling filesystem with maximum file size support upto 8 exbibytes.
 ext4, btrfs, jfs and many more filesystems are available also for Linux. Latest Linux distros can support NTFS, which is proprietary filesystem devoloped by Microsoft.

Comments

Popular posts from this blog

Understanding awk command with examples

Understanding sed command with example -Part 1

How to install a Software in Linux