Linux Commands

How to Write or Edit /etc/fstab

In Linux, there are multiple system configuration files that regulate system behavior. The fstab file is such a configuration file that stores all the information about various partitions and storage devices on the computer. At the time of boot, the fstab file describes how each partition and device will mount.

Let’s dive deep into the “/etc/fstab” file.

The fstab file

As described earlier, it’s a configuration file holding information about partitions, devices, and mount configurations. It’s located at the following location.

$ ls -lh /etc/fstab

It’s a plain text file, so we can use any text editor of our choice to work with it. However, it requires root permission to write changes to it.


First, have a look at the fstab file in your system. Note that each system will have different entries because of the partition and hardware differences. However, all fstab files will share the same fundamental structure.

$ cat /etc/fstab

Each line of the file is dedicated to a unique device/partition. It’s divided into six columns. Here’s a brief description of each of the columns.

  • Column 1: Device name.
  • Column 2: Default mount point.
  • Column 3: Filesystem type.
  • Column 4: Mount options.
  • Column 5: Dump options.
  • Column 6: Filesystem check options.

Device name

It’s the label of the particular device/partition. Each device and partition gets its unique device name. The device name is essential for mounting devices, partitions, and filesystems.

We can use the lsblk command to get a report on all the block devices. It practically reports all the gadgets and partitions with their device names.

$ lsblk -a

Default mount point

In Linux, a device, partition, or filesystem must be mounted on a location before the system can use it. Mounting makes the filesystem accessible through the computer’s filesystem. The mount point is the directory access to the device, partition, or filesystem.

We can get a list of all the mounted partitions on the system.

$ mount

In the context of the fstab file, the mount point described for the specific device name will be used as the default mount point. When the computer boots, the system will mount all the devices to the mount points described in this file.

Filesystem type

A filesystem can be described as an index of the database with all the physical location of data on the storage. There are numerous filesystems used widely. Linux supports several filesystems by default. Here’s a shortlist of the popular filesystems.

  • ext4
  • xfs
  • btrfs
  • vfat
  • ntfs
  • tmpfs
  • nfs
  • squashfs
  • sysfs

Another option is “auto,” which lets the system auto-detect the filesystem type of the device or partition. Use this option if you’re not confident about the specific filesystem.

Mount options

The mount options determine the mounting behavior of the device/partition. It’s considered the most confusing part of the fstab file.

Here’s a shortlist of some of the common mount options you’ll come across when working with the fstab file.

  • auto and noauto: This option determines if the system will mount the filesystem during boot. By default, the value is “auto,” meaning it’ll be mounted during boot. However, in specific scenarios, the “noauto” option may be applicable.
  • user and nouser: It describes which user can mount the filesystem. If the value is “user,” then normal users can mount the filesystem. If the value is “nouser,” then only the root can mount it. By default, the value is “user.” For specific and critical filesystems, “nouser” can be helpful.
  • exec and noexec: It describes whether binaries can be executed from the filesystem. The value “exec” allows binary execution, whereas “noexec” does not. The default value is “exec” for all partitions.
  • sync and async: It determines how the input and output to the device/partition will be performed. If the value is “sync,” then input and output are done synchronously. If the value is “async,” then it’s done asynchronously. It affects how data is read and written.
  • ro: It describes that the partition is to be treated as read-only. Data on the filesystem can’t be changed.
  • rw: It describes that the partition is available for reading and writing data.


It describes whether the filesystem is to be backed up. If the value is 0, then the dump will ignore the filesystem. In most cases, it’s assigned 0. For backup, it’s more convenient to use various third-party tools.

Fsck options

The fsck tool checks the filesystem. The value assigned in this column determines in which order fsck will check the listed filesystems.

Editing fstab file

Before editing the fstab file, it’s always recommended to have a backup.

Before making any changes to the fstab file, it’s recommended to make a backup first. It contains critical configuration details, so wrong entries may cause unwanted results.

$ sudo cp -v /etc/fstab /etc/fstab.backup

To edit the fstab file, launch your text editor of choice with sudo.

$ sudo nano /etc/fstab

To write a comment, use “#” at the start.

$ # This is a comment

Note that some entries may use the device UUID instead of a device name. To get the UUID of a device, use blkid.

$ blkid <device_label>

After all the changes are made, save the file and close the editor. These changes won’t be effective unless the system restarts.

Final thoughts

The fstab file is a simple yet powerful solution to many situations. It can also automate mounting remote filesystems. It just requires understanding the code structure and supported options to take the full benefit of it.

For more in-depth info, check the man page.

$ man fstab

Happy computing!

About the author

Sidratul Muntaha

Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.