Understanding the /etc/fstab File in Linux

The /etc/fstab file is one of the important configuration file in Linux, which contains a list of filesystems to be mounted at boot time (mounted filesystems on the system).

This file will be auto created/updated during the system installation and the filesystem mounting can be controlled using this file.

This file being used at boot to validate and mount file systems on system.

It is human readable and can be edited but make sure that you have added a correct entry in that.

If you made any mistake, which make your system to stuck at boot in the next reboot.

So, be careful when you adding an entry on that. Each mounted filesystem comes with 6 fields in one line. These fields are separated by tabs or spaces.

Filesystems that are described in /etc/fstab are typically mounted when the computer is booted, unless the noauto option is used.

A list of mounted filesystems can be found by using the following commands.

  • mount
  • df -a
  • cat /etc/mtab
  • cat /proc/mounts

In Linux operating system, everything is a file and hard disks are available under /dev directory.

It contains the following 6 fields in each line.

  • Device File Name or Filesystem Label or UUID
  • Mount Point
  • File System Type
  • Options
  • Dump
  • Pass

This is the sample output of /etc/fstab file, which i taken from one of our server.

# cat /etc/fstab

# /etc/fstab
# Created by anaconda on Sat Oct 20 05:18:25 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=02b56de1-a737-48ec-945f-c6f6301541aa       /       ext3    usrjquota=quota.user,jqfmt=vfsv0        1  1
UUID=b18386ae-633c-430c-85be-76132db5dd5a /boot                   ext2   defaults        1 2
UUID=d6059278-6690-4877-8660-c70d05af30fe swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults,noexec,nosuid        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/sdb1              /home1                  ext4    defaults,usrjquota      1 2

These are the six fields, which you can see in the /etc/fstab file.

+----------+--------+------+----------+------+------+
|/dev/sdb1 | /home1 | ext4 | defaults | dump | pass |
+----------+--------+------+----------+------+------+
|     1    |    2   |  3   |    4     |   5  |   6  |

Field-1 (/dev/sdb1): Disk Partition Name
Field-2 (/home1): Mount Point Name
Field-3 (ext4): Mounted filesystem type
Field-4 (defaults): It specifies the mount options.
Field-5 (1): It indicates backup utility dump is enabled or not for the file system.
Field-6 (2): It indicates the sequence of the file system checks

Field-1: Device File Name or Filesystem Label or UUID

The first field indicates the physical location of each device, which can be a partition on the HDD or a separate device such as a CDROM or floppy disk.

In the /etc/fstab output, you may see some of the Device is mentioned by disk name or UUID. The UUID stands for Universally Unique Identifier which helps Linux system to identify a hard drives partition instead of block device file.

The advantage of using the UUID is that it is independent from the actual device number. But device names aren’t guaranteed to be the same across a reboot. So, it’s advisable to use UUID instead of device name.

tmpfs, sysfs and proc, etc, these are virtual filesystem that are created by kernel for different purpose.

Field-2: Mount Point

The second field indicates the mount point, the directory where the partition or disk will be mounted.

It should always be an absolute path and should be created before we mount the filesystem on it.

Field-3: File System Type

The third field specifies the file system type. Each partition or device should be formatted with any of the supported filesystem to use by Linux. If not, we can’t use it.

There are many supported filesystem is available in Linux, among the most commonly used filesystems are.

  • ext2: The basic Linux filesystem type.
  • ext3: An an enhanced version of ext2 with journaling capabilities.
  • ext4: Ext4 stands for fourth extended file system and overcomes ext3 limitations.
  • reiser: Another journaling filesystem.
  • vfat: It’s compatible with some Microsoft filesystems.
  • nfs: It’s network file system.
  • cifs: It’s Common Internet File System

Field-4: Mount Options

The fourth field specifies the mount options associated with the filesystem, which adds some basic security to the file system by whom and how the filesystem or device can be used.

There are numerous options are available and we can use any number of them but they are separated with commas.

Mount OptionsDescription
defaultsIt uses default options, which includes rw, suid, dev, exec, auto, nouser, and async.
autoFile system will mount automatically at boot, or when the command ‘mount -a’ is issued.
noautoThe filesystem is mounted only when you tell it to.
execAllow the execution binaries that are on that partition (default).
noexecDo not allow binaries to be executed on the filesystem.
roMount the filesystem read only.
rwMount the filesystem read-write.
syncI/O should be done synchronously.
asyncI/O should be done asynchronously.
flushSpecific option for FAT to flush data more often, thus making copy dialogs or progress bars to stays up until things are on the disk.
userPermit any user to mount the filesystem (implies noexec,nosuid,nodev unless overridden).
nouserOnly allow root to mount the filesystem (default).
suidAllow the operation of suid, and sgid bits.
nosuidBlock the operation of suid, and sgid bits.
noatimeDo not update inode access times on the filesystem. Can help performance.
nodiratimeDo not update directory inode access times on the filesystem.
relatimeUpdate inode access times relative to modify or change time.

Field-5: dump

The fifth field is used by dump to determine which filesystems need to be backed up or dumped. Most users will not have dump installed, so by default they should put 0 for the dump entry.

  • 1: If 1, dump will make a backup.
  • 0: If 0, dump will ignore the file system backup.

Field-6: Pass

fsck reads the pass number and determines in which order the file systems should be checked. Possible entries are 0, 1, and 2.

  • 0: fsck check doesn’t performed on filesystems.
  • 1: It’s a highest priority and should be assigned to root file system.
  • 2: All other file systems you want to have checked should get a 2.

How to List Mounted File Systems in Linux Using mount Command?

The mount command is used to mount the given filesystem in Linux system. A list of mounted filesystems can be found by using the mount command with no options.

# mount

proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sys on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
dev on /dev type devtmpfs (rw,nosuid,relatime,size=8115744k,nr_inodes=2028936,mode=755)
run on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
/dev/nvme0n1p1 on / type ext4 (rw,noatime)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
bpf on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=25,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=104)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)
configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev)
/var/lib/snapd/snaps/odrive-unofficial_2.snap on /var/lib/snapd/snap/odrive-unofficial/2 type squashfs (ro,nodev,relatime,x-gdu.hide)
/var/lib/snapd/snaps/core_6405.snap on /var/lib/snapd/snap/core/6405 type squashfs (ro,nodev,relatime,x-gdu.hide)
/var/lib/snapd/snaps/core_6130.snap on /var/lib/snapd/snap/core/6130 type squashfs (ro,nodev,relatime,x-gdu.hide)
tmpfs on /run/user/120 type tmpfs (rw,nosuid,nodev,relatime,size=1624856k,mode=700,uid=120,gid=120)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=1624856k,mode=700,uid=1000,gid=1000)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)

How to Print Mounted File Systems in Linux Using df Command?

The df command stands for Disk Filesystem. It shows detailed report of mounted filesystem disk space usage on the Linux system.

We can get the same above output using df command with -a option. It prints dummy filesystems in the output. These are virtual filesystems, which is used by kernel for different purpose (it’s like proc, sys, etc)

# df -a

Filesystem     1K-blocks      Used Available Use% Mounted on
proc                   0         0         0    - /proc
sys                    0         0         0    - /sys
dev              8115744         0   8115744   0% /dev
run              8124284      1672   8122612   1% /run
/dev/nvme0n1p1 227483756 159337100  56521408  74% /
securityfs             0         0         0    - /sys/kernel/security
tmpfs            8124284    679532   7444752   9% /dev/shm
devpts                 0         0         0    - /dev/pts
tmpfs            8124284         0   8124284   0% /sys/fs/cgroup
cgroup2                0         0         0    - /sys/fs/cgroup/unified
cgroup                 0         0         0    - /sys/fs/cgroup/systemd
pstore                 0         0         0    - /sys/fs/pstore
bpf                    0         0         0    - /sys/fs/bpf
cgroup                 0         0         0    - /sys/fs/cgroup/cpu,cpuacct
cgroup                 0         0         0    - /sys/fs/cgroup/devices
cgroup                 0         0         0    - /sys/fs/cgroup/blkio
cgroup                 0         0         0    - /sys/fs/cgroup/hugetlb
cgroup                 0         0         0    - /sys/fs/cgroup/freezer
cgroup                 0         0         0    - /sys/fs/cgroup/pids
cgroup                 0         0         0    - /sys/fs/cgroup/perf_event
cgroup                 0         0         0    - /sys/fs/cgroup/rdma
cgroup                 0         0         0    - /sys/fs/cgroup/cpuset
cgroup                 0         0         0    - /sys/fs/cgroup/net_cls,net_prio
cgroup                 0         0         0    - /sys/fs/cgroup/memory
systemd-1              -         -         -    - /proc/sys/fs/binfmt_misc
mqueue                 0         0         0    - /dev/mqueue
debugfs                0         0         0    - /sys/kernel/debug
hugetlbfs              0         0         0    - /dev/hugepages
binfmt_misc            0         0         0    - /proc/sys/fs/binfmt_misc
configfs               0         0         0    - /sys/kernel/config
tmpfs            8124284     38276   8086008   1% /tmp
/dev/loop1        111488    111488         0 100% /var/lib/snapd/snap/odrive-unofficial/2
/dev/loop0         93184     93184         0 100% /var/lib/snapd/snap/core/6405
/dev/loop2         91648     91648         0 100% /var/lib/snapd/snap/core/6130
tmpfs            1624856        12   1624844   1% /run/user/120
tmpfs            1624856        36   1624820   1% /run/user/1000
gvfsd-fuse             0         0         0    - /run/user/1000/gvfs
fusectl                0         0         0    - /sys/fs/fuse/connections

How to Check Mounted File Systems in Linux Using /etc/mtab File?

The /etc/mtab file contains a list of currently mounted filesystems with details.

# cat /etc/mtab

proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sys /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
dev /dev devtmpfs rw,nosuid,relatime,size=8115744k,nr_inodes=2028936,mode=755 0 0
run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0
/dev/nvme0n1p1 / ext4 rw,noatime 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0
cgroup2 /sys/fs/cgroup/unified cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,name=systemd 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
bpf /sys/fs/bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700 0 0
cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/hugetlb cgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup /sys/fs/cgroup/pids cgroup rw,nosuid,nodev,noexec,relatime,pids 0 0
cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0
cgroup /sys/fs/cgroup/rdma cgroup rw,nosuid,nodev,noexec,relatime,rdma 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=25,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=104 0 0
mqueue /dev/mqueue mqueue rw,nosuid,nodev,noexec,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,nosuid,nodev,noexec,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,relatime,pagesize=2M 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0
configfs /sys/kernel/config configfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /tmp tmpfs rw,nosuid,nodev 0 0
/dev/loop1 /var/lib/snapd/snap/odrive-unofficial/2 squashfs ro,nodev,relatime 0 0
/dev/loop0 /var/lib/snapd/snap/core/6405 squashfs ro,nodev,relatime 0 0
/dev/loop2 /var/lib/snapd/snap/core/6130 squashfs ro,nodev,relatime 0 0
tmpfs /run/user/120 tmpfs rw,nosuid,nodev,relatime,size=1624856k,mode=700,uid=120,gid=120 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=1624856k,mode=700,uid=1000,gid=1000 0 0
gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0
fusectl /sys/fs/fuse/connections fusectl rw,nosuid,nodev,noexec,relatime 0 0

How to Check Mounted File Systems in Linux Using /proc/mounts File?

The proc filesystem (procfs) is a special filesystem (Virtual filesystem) in Unix-like operating systems that presents information about processes and other system information.

It’s sometimes referred to as a process information pseudo-file system. It doesn’t contain ‘real’ files but runtime system information (e.g. system memory, devices mounted, hardware configuration, etc).

# cat /proc/mounts

proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sys /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
dev /dev devtmpfs rw,nosuid,relatime,size=8115744k,nr_inodes=2028936,mode=755 0 0
run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0
/dev/nvme0n1p1 / ext4 rw,noatime 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0
cgroup2 /sys/fs/cgroup/unified cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,name=systemd 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
bpf /sys/fs/bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700 0 0
cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/hugetlb cgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup /sys/fs/cgroup/pids cgroup rw,nosuid,nodev,noexec,relatime,pids 0 0
cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0
cgroup /sys/fs/cgroup/rdma cgroup rw,nosuid,nodev,noexec,relatime,rdma 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=25,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=104 0 0
mqueue /dev/mqueue mqueue rw,nosuid,nodev,noexec,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,nosuid,nodev,noexec,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,relatime,pagesize=2M 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0
configfs /sys/kernel/config configfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /tmp tmpfs rw,nosuid,nodev 0 0
/dev/loop1 /var/lib/snapd/snap/odrive-unofficial/2 squashfs ro,nodev,relatime 0 0
/dev/loop0 /var/lib/snapd/snap/core/6405 squashfs ro,nodev,relatime 0 0
/dev/loop2 /var/lib/snapd/snap/core/6130 squashfs ro,nodev,relatime 0 0
tmpfs /run/user/120 tmpfs rw,nosuid,nodev,relatime,size=1624856k,mode=700,uid=120,gid=120 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=1624856k,mode=700,uid=1000,gid=1000 0 0
gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0
fusectl /sys/fs/fuse/connections fusectl rw,nosuid,nodev,noexec,relatime 0 0

If /etc/mtab file is lost or corrupted by accident, it can be regenerated by running the following command.

$ sudo sh -c 'grep -v rootfs /proc/mounts > /etc/mtab' 

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

Leave a Reply

Your email address will not be published. Required fields are marked *