Monday, July 8, 2013

FSTAB - One of the most important file

FSTAB is 9th out of the 10 most critical and important configuration files which is stored in /etc directory, where all the configuration files are stored.
FSTAB stands for "File System TABle" and this file contains
information of hard disk partitions and removeable devices in the system.
It contains infor-mation of where the partitions and removeable devices are mounted and which device drivers are used for mounting them, which filesystem they are using and what permissions are assigned to them.
The file FSTAB contains descriptive information about the various file systems. fstab is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file. Each filesystem is described on a separate line; fields on each line are separated by tabs or spaces. Lines starting with '#' are comments. The order of records in fstab is important because fsck, mount, and umount sequentially iterate through fstab doing their thing.

Example of a FSTAB file content :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LABEL=/     /              ext3       defaults       1   1
LABEL=/boot /boot          ext3       defaults       1   2
none        /dev/pts       devpts gid=5,mode=620     0   0
LABEL=/home /home          ext3       defaults       1   2
none        /proc          proc       defaults       0   0
none        /dev/shm       tmpfs      defaults       0   0
LABEL=/tmp  /tmp           ext3       defaults       1   2
LABEL=/u01  /u01           ext3       defaults       1   2
LABEL=/usr  /usr           ext3       defaults       1   2
LABEL=/var  /var           ext3       defaults       1   2
/dev/hda6   swap           swap       defaults       0   0
/dev/cdrom  /mnt/cdrom     udf,iso9660 noauto,ro     0   0
/dev/fd0    /mnt/floppy    auto   noauto,owner,kudzu 0   0
/dev/sda1   /mnt/usb_hdd   vfat        noauto        0   0
\________/ \___________/ \_________/ \____________/ \_/ \_/
    |            |            |            |         |   |
   1st          2nd          3rd          4th       5th 6th

There are total six columns in the fstab file separated by spaces  or tabs. Each column holds different information about the device. For adding any new device add a fresh row. Each row stands for a partition or removeable device in the system.

1st Column :
~~~~~~~~~~
The first column contains the partitions's label, eg. "LABEL=/boot" or driver's path, eg. "/dev/cdrom". Device driver's path tells the system to mount the device with the mentioned device driver.

2nd Column :
~~~~~~~~~~
The second field (fs_file) describes the mount point for the
filesystem.For swap partitions, this field should be specified as `none'.
If the name of the mount point contains spaces these can be escaped as `\040'.
The second column shows the mount point specified for a device in the fstab file. The mount points actually is the directory where that particular device (mentioned in the first column) will be mounted and through which we can view and modify the content of that partition. You can change the default mount point listed in the column, if you are not satisfied with the one your system has given you.

3rd Column :
~~~~~~~~~~
The third column in the file specifies the file system type of the device or partition. Many diffrent file systems are supported by Linux and most common ones are,

1) autofs
2) devpts
3) ext2
4) ext3
5) iso9660
6) nfs
7) ntfs
8) proc
9) swap
10) tmpfs
11) udf
12) ufs
13) vfat
14) xfs

If you are not sure of the file system type of the device then set the value to "auto" and the system will itself determine the file system type and will mount the device with that file system.

4th Column :
~~~~~~~~~~
The fourth column is for permissions to be given to the partition at the time of booting. There are many options which constitutes the forth column.

They are as follows : -

1) ro - Read Only
2) rw - Read Write
3) auto - Mount on startup
4) noauto- Do not mount on startup
5) user - Any user can mount, but only unmount device mounted by him
6) nouser- Only root can mount & unmount the device
7) users - Every user can mount and also unmount the device mounted by others
8) owner - Same as user (above no. 5)
9) dev - User can use device driver to mount the device
10) nodev - User cannot use device driver to mount the device
11) exec - Users can execute binaries on the partition
12) noexec- Users cannot execute binaries on the partition
13) async - Asynchronous, whenever a file is saved it will be first saved in the RAM and after 30 seconds all the queued files will be written on the hard disk
14) sync - Synchronous, whenever a file is saved it will be directly written to the hard disk
15) suid - Allow set-user-identifier for the device where users are allowed to run binaries even though they do not have execute
permissions. These binaries are temporarily made available to
them to perform certain tasks
16) nosuid- Do not allow set-user-identifier
17) defaults- auto, rw, dev, async, suid, exec & nouser

5th Column :
~~~~~~~~~~
The 5th column is for backup option. This column contains either 0 or 1. Where "0" stands for "NO" and "1" stands for "YES". The system checks it at the time of booting, if it's "0", dump will ignore that filesystem but if its "1" then it will enable backup option.
Backup is supported on only ext3 file system, hence only for ext3 file system it should be enabled and for rest of the file systems it should be disabled.

6th Column :
~~~~~~~~~~
The 6th column is for "fsck" option. fsck stands for file system
check. This column defines the order in which the system should scan the partitions on start up. The / partition is assigned top priority i.e. 1 and the rest of the partitions are assigned second priority i.e. 2. If value is set to 0 means no scanning will be done at the time of startup.
If same number is given to different partitions then the partitions are scanned together with equal priority. This minimizes error because if a
link is present on one partition with higher priority and the source file in another partition with a priority lower than the link, it will give an error.

No comments:

Post a Comment