/etc/fstab is key file for file systems in any Linux Unix system. Learn fields, formats within /etc/fstab file. Understand meaning of each field and how it can be set.
/etc/fstab is one of the key file in running Linux or unix system. File system mounting can be controlled using this file. This is one of the file being used at boot to validate and mount file systems on machine. This file is human readable and can be edited with text editor like vi.
This file contains 6 parameters per row. Each row represents one file system details. They are as below :
- Mount point
- File system type
Lets see one by one –
This is disk or logical volume which is source to be mounted on the mount point specified in second field. See below example of fstab from Linux system.
# cat /etc/fstab
# Created by anaconda on Thu Dec 5 15:47:52 2013
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
/dev/mapper/vg_00-lv_root / ext4 defaults 1 1
UUID=f2918ad9-f5ce-485d-81ae-e874f57f6f57 /boot ext4 defaults 1 2
/dev/mapper/vg_00-lv_home /home ext4 defaults 1 2
/dev/mapper/vg_00-lv_tmp /tmp ext4 defaults 1 2
/dev/mapper/vg_00-lv_usr /usr ext4 defaults 1 2
/dev/mapper/vg_00-lv_var /var ext4 defaults 1 2
/dev/mapper/vg_00-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/sdb /app ext3 defaults 1 2
10.10.2.3:/my_share /tmp/nfs_share nfs defaults 0 0
In above example you can see volume is specified by UUID or logical volume name or disk name or IP:/directory.
/boot entry is specified by UUID. UUID is universal unique ID assigned to each disk when its formatted in system. Disk can be identified by UUID or disk name in kernel. Since its unique number, its ideal to use UUID in fstab for important file systems!
/var, /tmp etc entries are defined using volume as a logical volume name. They are logical volumes part of volume group vg00. See LVM legends to get familiarize with naming conventions.
/dev/shm is defined by tmpfs volume. Its a temporary file system volume created and identified by kernel on root disk. devpts, sysfs are paart of such system defined file systems.
Second Last entry, you can see disk sdb is also defined as a volume for /app entry.
Lastly NFS share is mounted on /tmp/nfs_share directory. There IP address of nfs server and its exported share volume name combination is defined as a volume.
This is the first argument to be supplied in mount command while mounting any filesystem.
Normally HPUX uses LVM as a partition manager hence only logical volumes are found as a volume entry in fstab. See below example of fstab from HPUX system.
$ cat /etc/fstab
# System /etc/fstab file. Static information about the file systems
# See fstab(4) and sam(1M) for further details on configuring devices.
/dev/vg00/lvol3 / vxfs delaylog 0 1
/dev/vg00/lvol1 /stand vxfs tranflush 0 1
/dev/vg00/lvol4 /home vxfs delaylog 0 2
/dev/vg00/lvol5 /opt vxfs delaylog 0 2
/dev/vg00/lvol6 /tmp vxfs delaylog 0 2
/dev/vg00/lvol7 /usr vxfs delaylog 0 2
/dev/vg00/lvol8 /var vxfs delaylog 0 2
/dev/vg00/lvol10 /var/adm/sw vxfs delaylog 0 2
/dev/vg00/lvol11 /admin vxfs delaylog 0 2
10.10.2.3:/my_share /tmp/nfs_share nfs defaults 0 0
2. Mount point:
Its second field in an entry of fstab. This is name of the directory on which volume should be mounted. It should always be an absolute path (i.e. starts with / and has all directory hierarchy till last expected directory) in this field.
Directories like /var, /boot /tmp, /stand, /usr, /home, /proc, /sys are (and should be) reserved for system mount points. In HPUX even logical volume numbers of root vg are reserved for system mount points like lvol1 should always be /stand. 2 for swap, 3 for root etc.
This is the second argument ot be supplied to mount command when mounting any file system.
3. File system type:
This is FS type to be considered while mounting the give volume on specified mount point. Different file system types has different functions and advantages to offer. You need to specify same FS type which was used at time of formatting respective volume. ext3, ext4 (Linux FS), vxfs (veritas FS), nfs (Network FS), swap (SWAP FS) are few of types.
This can be supplied to mount command with -F option.
Those are file system options which will enhance usage experience of mount point. They also impact on performance of file system and impact in recovery in case of failures. Value ‘defaults’ in above example instructs mount command to use parameters defined inbuilt. They can be seen in man page :
Use default options: rw, suid, dev, exec, auto, nouser, async, and relatime.
All available options can be summarized as below :
These options can be supplied to mount command using -o .
This is old fashioned backup option in case of server goes down. If this is set to 1 then FS dump will happen when system goes down due to some issue. Setting this 0 will nullify this option.
This tells kernel about file system check priority or sequence. fsck is facility which checks file system for its consistency. During boot if fsck is invoked then it look for this filed. If set to 0, fsck will be skipped for that mount point. If set to 1 then that mount points will be first in sequence to be fscked.