fstab in ubuntu

July 11, 2013 in Web Server

How to configure fstab in Ubuntu

what is fstab?

In fstab or FileSystemTABle,you will be able to find informations regarding all your mount points in your computer.

In other words is a list of disks and partitions and also include information regarding where they are mounted in your Operating System.

It maybe sounds a bit complicat right now but i think that you will be able to understand if you see an example.

I will post here an fstab file (you can find yours under /etc/fstab)

 

# <file system> <dir>         <type> <options>       <dump> <pass>
/dev/sda1         /                   ext4      defaults             1           1
/dev/sda2        /usr              ext4      defaults              1           1

/dev/sda4        /home         ext4       defaults             0            0
/dev/sda5         swap          swap    defaults              0           0
/dev/sdc1         /data2         ext4      defaults,auto     0           2
/dev/sdb1         /data            auto     defaults,auto     0           2

Lets check this table:

on the first column:

Here you can find informations regarding the hard drives and partitions. In this computer there are 3 Hard Drives sda1, sda2, sda3 . On the first hard drive the OS is installed and the other 2 hdds are there for some additional storage. The first hard drive is divided into partitions but the other hard drives are not in this example.

On the second column:

Here you can see where in your file system are mounted your hard drives and your partitions

On the third column:

You can specify here what is the file system of your partitions. Some of the options are: ext2, ext3, ext4, nfs, reiserfs, xfs, jfs, smbfs, iso9660, vfat, ntfs, swap, and auto. the auto   is my favourite because in that mode you let the O.S. decide what kind of file system is your partition. This is very useful for CD and DVD ROMS.

On the forth Column:

Here you can specify how the system will mount your drives and partitions. You can add more than 1 option with ","

auto -- file system will mount automatically at boot.

noauto -- the filesystem is mounted only when you want to mount it (you can the mount command)

exec -- allow the execution binaries that are on that partition (default).

noexec -- do not allow binaries to be executed on the filesystem.

ro -- mount the filesystem read only.

rw -- mount the filesystem read-write.

user -- permit any user to mount the filesystem

nouser -- only allow root to mount the filesystem (default).

suid -- allow the operation of suid, and sgid bits.

nosuid -- block the operation of suid, and sgid bits.

noatime -- do not update inode access times on the filesystem. Can help performance.

nodiratime -- do not update directory inode access times on the filesystem. Can help performance.

relatime -- update inode access times relative to modify or change time. Access time is only updated if the previous access time was earlier than the current modify or change time (similar to noatime, but doesn’t break mutt or other applications that need to know if a file has been read since the last time it was modified). Can help performance.

sync -- I/O should be done synchronously.

async -- I/O should be done asynchronously.

defaults -- this is the most used and it includes the default mount settings (equivalent to rw,suid,dev,exec,auto,nouser,async). I also like this one 😉

Fifth Column

This is where you tell to dump utility if it needs to be backuped or not. if its 0 the dump will ignore this one. if it is 1 the dump will include this drive in the backup process.

Sixth Column.

this is the priority on check disk and can be 0,1,2. the root file system must have 1 and that means high priority on check. the other can be 0 no check or 2 check after file system.