You’ve probably heard about ‘/etc/fstab’ file, but if you don’t know how to edit this file correctly, in this tutorial you will learn all the basics.

Table of Contents


The file fstab contains information about the filesystems the system can mount. Each filesystem is described on a separate line, and each field of the line is separated by tabs or spaces.

File structure

This is an example of fstab content:

# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# /dev/sda5
UUID=1234e5-ba60-4cee-b0c4-e9bf918a4e8e	/         	ext4      	rw,relatime	0 1

# /dev/sda2
UUID=CE27-DB3F      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2

Each filesystem line is divided in 6 fields:

First field

Describes the block device or remote filesystem to be mounted. It can be a device name (like /dev/sda1) or, more recommended, an UUID or LABEL. Device names often change when other disks are mounted or unmounted. You can use PARTUUID or PARTLABEL (partition identifiers for GPT disks) as well, but UUID is the most used identifier. You can find the filesystem UUID with lsblk -f or sudo blkid.

Second field

Describes the mount point (target) for the filesystem. For swap partitions, this field should be specified as none.

Third field

Describes the type of the filesystem: ext4, btrfs, nfts, etc. For swap partitions, filesystem type is swap.

Fourth field

Describes the mount options associated with the filesystem. It is formatted as a comma-separated list of options. Some options are these ones:

  • defaults: use default options (rw,suid,dev,exec,auto,nouser,async).
  • auto: can mount the filesystem when mount -a is given or at a boot time.
  • noauto: do not mount when mount -a is given or at a boot time.
  • user: allow an ordinary user to mount. Only the user who mounts the filesystem can unmount it.
  • users: any user can mount and unmount the filesystem.
  • nouser: forbid an ordinary user to mount the filesystem.
  • group: allow an ordinary user to mount if one of that user’s groups matches the group of the device.
  • owner: only the device owner can mount.
  • rw: mount the filesystem read-write.
  • ro: mount the filesystem read-only.
  • suid: allow set-user-ID or set-group-ID bits to take effect.
  • dev: interpret character or block special devices on the filesystem.
  • nodev: do not interpret character or block special devices.
  • exec: allow execution of binaries.
  • noexec: do not allow direct execution of any binaries on the mounted filesystem.
  • async: all input/output to the filesystem should be done asynchronously.
  • sync: all I/O to the filesystem should be done synchronously.
  • relatime: update inode access times relative to modify or change time.

Fifth field

This field is used by dump to determine which filesystems need to be dumped. This usually takes a value of 0 (the default if not present).

Sixth field

This field is used by fsck to determine the order in which filesystem checks are done at boot time. Root filesystem should be specified with a value of 1. Other filesystem should have a value of 2. You can also put a value of 0 that means “don’t fsck”.