Home –  Tutorials – A complete fstab guide

A complete fstab guide

Wherever you stand on your linux learning curve, you will have to deal with fstab one day or the other. Fstab file is edited to configure filesystems. The process is really easier if you are well versed with fstab file. Continue reading to know more about fstab and how things work.

Introduction to fstab

Every operating system has a file system table, in Linux fstab happens to be that file. Earlier in linux era, one had to manually mount any drives/files at specified locations with the help of “mount” command. Right after plugging in your device, they just didn’t show up on your desktop. They were meant to be mounted manually and then further processing was done. There existed (exists) a way through which it can be done automatically, fstab was the magic wand. Fstab is used to store configurations for different file systems and it contains what to do with them, i.e., what and where to mount.
This automatic mounting can be carried out in graphical style too with the help of a tool PySDM, it is explained here.

How does fstab file look like?

Fstab file is found at:

/etc/fstab

You can see your fstab file by executing following command:

# gedit /etc/fstab

Columns in fstab file are separated from each other by a “tab”. We will go through and explain each column in the order they appear.

File System

This is the screenshot of my fstab file:

All the fstab entries are starting with UUIDs. These UUIDs are assigned to file systems while formatting, these are considered ideal for selecting file systems while mounting as they do not and cannot be changed. This setup is best for home users but for an advanced user who wishes to use RAID in future or uses a network based device, you should pass. To get the UUID of a partition so that you can make an entry in fstab, use blkid .

Mount Point

The next section in fstab denotes mount point of that particular partition. All the sections are separated by a ‘tab’. While making an entry in fstab, a mount point is to be created before rebooting (as changes take effect after restarting).

 

Type

The next section is type of file system for that partition. Linux supports a variety of file systems, few might need some packages to be able to perform read/write on them. We are looking only over a few of them:

ext3 : Most of the systems these days have ext3 linux partitions. Older systems had ext2 type filesystems but now ext3 has replaced it for its advantages. Ext3 is journaled, that is, if the power goes off and system is not properly shut down, no data will be lost, therefore, no time wasted in disc checks.
Note: Some distros are shipping with ext4 as default.

swap : Name stands for itself. “Swap” partition is of type “swap”.

ntfs and vfat : You will find your pendrives in vfat format (also known as FAT32) and windows drives in ntfs format.

auto : When you find written “auto” in this column, it doesn’t signify type but automatic detection of filesystem type.

Options

This section of fstab contains mount options for partitions. This section can seem really confusing at first but knowing few them can get you through it. Popular ones are discussed here while rest can be checked on man page of mount .

auto/noauto

With auto , the partition will automatically be mounted on a system boot. You can prevent a partition from automounting on bootup by editing option to noauto in fstab file.

exec/noexec

It lets you choose whether the partition can execute binaries or not. For example, you can give a partition noexec which contains binaries and you don’t want them to execute.

ro/rw

ro is for read-only partition while rw denotes read-write partition. To be able to write on a partition, it should have rw option in fstab file.

user/nouser

With nouser as an option, only root has privilege of mounting a partition while user allows any non-root user to mount a partition. Many users find it annoying that they can’t mount a partition as a normal user, well, now you know that solution is to update your fstab file.

sync/async

It is responsible for files being written synchronously and asynchronously. In layman words, when you issue a “copy” command on a pendrive, writing process starts as soon as command is issued but this is not the case with internal hard drives. Write operations on hard disks are not synchronised, that is, writing might start long after command was issued. This is the reason for error “wait while changes are being wriiten”. This can also cause accidental data loss. If async is set, it might appear that files are successfully written but they might not be physically written.

defaults

It sets all the default options: rw, suid, dev, exec, auto, nouser, async.

dump

This is the fifth column in fstab file. It has zeros and ones as entries, zero is for false and one is for true . It is an old school method of backing up. Backup will be performed if option is “1”. In case of “0” option dump will ignore the partition.

fsck

fsck is short form for file system check. This makes the 6th column for fstab file. You will see 0,1 or 2 written in this section. “0” denotes that the partition will be skipped from checking. “1” is for partition which will be checked at booting time. These numbers are actually the sequence in which they will be checked. Root (/root) partition is always set at 1, partitions other than root which are supposed to be checked should be set at 2.

14 thoughts on “A complete fstab guide

  1. bnr

    The “tabs” in fstab (or File System Table) are completely irrelevent; all that is needed is white space between each “cell” in the table.

  2. Jo Radakovich

    Hi,

    The article helped me, Thanx.

  3. James

    What’s that ‘2’ in the FSCK section?

    According to the guide that value is either 1 or 0 depending on if you want it to check or not that partition but in the screenshot there’s a 2 in the boot partition.

  4. ferent

    In fsck you have a number 2, but you say only can be 0 and 1. What’s the meaning of this “2”?

  5. Jim

    Is there a way of delaying a mount until after networking comes up? I have a Network File Server and get errors until the wireless comes up. Also when shutting down, the computer kills networking before unmounting the NAS which causes a long delay in halting.

    Ubuntu 10.04

  6. Alexis

    Hi Jim, you have to use the option _netdev, this will wait until the network is up

  7. For fsck bit (last column)
    0 –> Ignored when your system reboot or start or when you run
    # shutdown -Fr now
    The values 1,2…. it’s nothign but priority/order ..in which 1 — always your root partition “/” and 2 for other partitions (drivers) ..

  8. javi campos

    Muchas gracias

  9. Feyyaz Esat

    That is really helped me, Thank you, I’ve got a question :

    is that possible to define “defaults” in options section and sure override some of defaults property.

    e.g defaults, noexec ?

  10. Siddhartha RT

    This is nowhere a complete guide. You have not explained uid/gid options, the meaning of various settings available and much more. You haven’t even shown an example of mounting one directory into another on boot.

    • Tom Setrakian

      @Siddhartha RT:
      Posting your own “Advanced Linux fstab Configuration” guide would be far simpler (and less unhelpful) that complaining that a guide doesn’t cover more advanced configuration options.

      One could assume that, if this guide begins with “Introduction to fstab,” it most likely will not delve into the realm of more complex directives which could ultimately foul up a newbie’s configuration.

      That aside, there is nothing in this guide warning about the potential dangers of tinkering in your fstab – this is of some concern, if this is to be a “new user’s guide.”

Leave a Reply

Your email address will not be published. Required fields are marked *