Exploring /etc/fstab

I have been working with linux for a long time but from time to time I come to a very simple concept that I should have already known.  I have been reading my old books and I ran across a discussion of /etc/fstab which sparked my interest into better understanding each of the fields in /etc/fstab in linux.

Column OrderFieldDescription
1LabelThe file system label identifer or mount point
2Mount Pointlocation to mount the label
3FormatFile system type for the mount identified in 2
4Mount Optionscommonly default which is rw can also be: suid, dev, exec, auto, nouser, and async etc..
5Dump ValueIf 1 the filesystem is automatically written to disk
6File system check orderFile systems that need fsck, root should be 1, other partitions should be 2 and block devices or remote directories should be 0


Label

On the surface this seems to be a simple concept.  The most basic example is /dev/hda1 or /dev/sda1  which would be device hard drive a partition 1 (/dev/hda1) or scsi drive a partition 1 (/dev/sda1) but many things can be placed inside this field to identify hard drives.  You can use a multitude of options in modern linux.  You can use drive labels, device names or UUID’s.   Label’s and UUID’s provide the advantage of not possibly changing with a reboot.

Mount Point

The location on the file system where you want to mount the partition.

Format

The filesystem on the partition.  Can be mount using fdisk if needed.

Mount Options

There are lots of mount options for different needs.

OptionDescription
sync/asyncAll I/O to this file system should be done synchronously or asynchronously
autoMounted at boot or when mount -a is used.
noautoFile system will not automatically mounted at boot time or with mount -a
dev/nodevInterpret/Do not interpret block devices on file system
exec / noexecAllow or deny execution of binaries from file system
suid/nosuidAllow or Deny the use of suid or sgid bits
ro/rwMount Read Only (ro) or Read Write (rw)
userAllow any user to mount file system
nouserAllow only root to mount the file system
defaultsDefault settings equals: rw, suid, dev, exec, auto, nouser, async
_netdevNetwork file system bring up after network is up (only used with nfs)
atimeRecord latest time when a file is accessed
noatimeDo not record latest time when a file is accessed
relatimeUpdate access time if earlier than modification time.

Dump Value

This field is used to denote if the backup program dump is used to backup the file system.  A value of 0 means it’s ignored while any number larger denotes how often in days the file system should be dumped.  This value is mostly ignored since very few people use dump now.  Root should be a 1 while other file systems should be 2 except swap which should be a 0.

Filesystem Check Order

This is the order in which file systems are checked during boot by fsck -p.   A setting of 0 is ignored while root should be 1 and everything else a 2 or higher.

© 2009, Joseph Griffiths. All rights reserved.

Leave a Reply