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:
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.
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 .
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).
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.
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 .
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.
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 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.
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.
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.
It sets all the default options: rw, suid, dev, exec, auto, nouser, async.
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 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.