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 fstabEvery 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:
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.
# gedit /etc/fstab
File SystemThis is the screenshot of my fstab file:
Mount PointThe 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).
TypeThe 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.
OptionsThis 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.