Linux online course

Linux /etc/fstab File: Persistent Filesystem Mounting

Learn to read, configure, and safely validate Linux /etc/fstab entries for disks, partitions, swap, USB storage, and network filesystems.

The /etc/fstab file is Linux's static filesystem table. It defines filesystems that are available to mount and describes where and how they should be mounted. Correct entries allow filesystems to become available automatically during boot or when a command such as mount /srv/data refers to an entry in the table.

This lesson covers local disks, partitions, swap, removable media, and the basic concepts needed for network filesystems. You should be familiar with the Linux directory hierarchy, disks and partitions, permissions, shell commands, and sudo. For related command-line concepts, see Linux and showing the full path of shell commands.

What /etc/fstab Does

To mount a filesystem means to make its contents accessible at a directory in the Linux directory tree. The directory is called the mount point. For example, mounting a data partition at /srv/data makes that partition's files accessible below /srv/data.

/etc/fstab tells Linux:

  • Which storage device or filesystem to use.
  • Which directory should receive the filesystem.
  • Which filesystem driver and mount options to apply.
  • Whether traditional dump backup processing should include it.
  • Whether boot-time filesystem checks should process it, and in what order.

Entries commonly describe the root filesystem, /home, /boot, additional data partitions, swap space, removable media, and optionally NFS or CIFS network filesystems.

During boot, the operating system or its service manager reads eligible entries. The mount command also consults /etc/fstab when you provide a mount point or device without all mount parameters. For example, if an entry exists for /srv/data, sudo mount /srv/data can obtain the device, type, and options from that entry.

The Six-Field Syntax

Each filesystem definition normally occupies one line. Fields are separated by whitespace, usually spaces or tabs. The fields must appear in this order:

Field numberField namePurposeTypical valuesImportant notes
1Filesystem identifierSelects the device, UUID, label, or special source.UUID=..., /dev/sda1, noneStable identifiers are usually safer than device names.
2Mount pointDirectory where the filesystem is attached./, /home, /srv/data, noneThe directory normally must already exist.
3Filesystem typeIdentifies the filesystem format and driver.ext4, xfs, vfat, swapauto can request type detection.
4Mount optionsControls access, behavior, security, and timing.defaults, ro, nofailOptions are comma-separated.
5Dump flagControls inclusion in the traditional dump backup utility.0, 1Most modern systems use 0.
6fsck passSets boot-time filesystem consistency-check order.0, 1, 2Root commonly uses 1; other local filesystems commonly use 2.

A line beginning with # is a comment and is ignored. Blank lines are also ignored. Comments are useful for documenting why an entry exists, but do not place a comment marker before an entry you intend to activate.

# Device or UUID   Mount point   Type   Options   Dump   Check
UUID=<data-uuid>   /srv/data     ext4   defaults  0      2

Field 1: Filesystem Identifier

The first field identifies the filesystem to mount. A device node is a path under /dev representing a disk or partition. Examples include /dev/sda1 for a partition on a traditional disk name and /dev/nvme0n1p1 for a partition on an NVMe device.

FormatExample formStabilityRecommended use
Device path/dev/sdb1May change when hardware is added, removed, or reordered.Useful for temporary work or when the device identity is controlled.
UUIDUUID=4f2a-...Usually stable for the filesystem until it is reformatted or its identifier is changed.Preferred for most persistent mounts.
LABELLABEL=backupStable until the filesystem label is changed; must be unique enough to avoid ambiguity.Convenient when a meaningful human-readable name is desired.
Special sourcenoneNot a block-device identifier.Used in applicable pseudo-filesystem, bind, or swap-related forms.

Kernel-assigned names such as /dev/sdb1 are not guaranteed to refer to the same physical partition after hardware changes. UUIDs and labels identify the filesystem more directly. Use lsblk -f or sudo blkid to find identifiers.

lsblk -f
sudo blkid

Field 2: Mount Point

The second field is the directory through which the mounted filesystem is accessed. Common mount points include:

  • / — the root filesystem.
  • /home — users' home directories.
  • /boot — boot files on systems that use a separate boot filesystem.
  • /mnt — a conventional location for temporary or administrative mounts.
  • /media — a conventional location for removable media.
  • A purpose-specific directory such as /srv/data or /media/backup.

The mount-point directory normally must already exist. Create it before testing:

sudo mkdir -p /srv/data

Swap is different: it is not mounted as an ordinary directory, so its mount-point field is conventionally none.

Field 3: Filesystem Type

TypeTypical useNotable option considerations
ext4Common Linux local filesystem.Often works with defaults; commonly checked with pass 2 when it is not root.
ext3Older journaling Linux filesystem.Use options supported by the installed filesystem tools.
xfsScalable Linux filesystem used for local data.Filesystem checking and repair behavior differs from ext filesystems.
btrfsLinux filesystem with features such as subvolumes and snapshots.Subvolume and distribution-specific options may be required.
vfatFAT-family removable media and compatibility partitions.Use uid, gid, and umask to map ownership and permissions.
exfatLarge removable media shared with other operating systems.Ownership and permission behavior depends on the driver and mount options.
ntfsNTFS volumes, often shared with Windows.Use the appropriate installed NTFS driver and its supported options.
swapSwap partition or swap file.Activated with swap tools rather than mounted at a normal directory.
nfsNetwork File System export.Requires network availability and appropriate client configuration.
cifsSMB or Windows-compatible network share.Usually needs a server/share source and credentials or credential-file options.

auto is an optional type setting that asks the mount system to detect the filesystem type. An explicit type is preferable when you know the format because it documents the configuration and reduces ambiguity.

Field 4: Mount Options

The fourth field contains comma-separated options. defaults represents a standard group of default behaviors. You can combine it with additional settings, such as defaults,nofail.

OptionEffectTypical use caseSecurity or boot impact
defaultsUses the standard default option set.Normal local filesystems.A starting point, not a complete security policy.
rw / roMount read-write or read-only.Writable data or protected media.ro prevents normal writes; errors can also cause a filesystem to become read-only.
exec / noexecAllows or prevents execution of programs from the filesystem.Removable or untrusted storage.noexec can reduce risk but is not a complete security boundary and may break software.
suid / nosuidAllows or ignores set-user-ID and set-group-ID permission effects.Untrusted or removable storage.nosuid limits privilege-related behavior.
dev / nodevAllows or ignores device nodes on the filesystem.Removable or untrusted storage.nodev prevents device files there from acting as devices.
userAllows a user to mount; normally implies restrictions and permits that user to unmount.User-controlled removable media.Understand the implied behavior before using it.
usersAllows users to mount and unmount.Shared removable media.Broader permission than user.
ownerAllows the device owner to mount.Some removable-device workflows.Behavior depends on the device and mount system.
noautoExcludes the entry from ordinary automatic mounting, including mount -a.Optional media mounted only on demand.Prevents an absent device from being automatically attempted.
nofailAllows boot to continue if the filesystem cannot be mounted.Optional USB disks or noncritical data.Reduces boot failure risk, but the data may be unavailable.
_netdevMarks a mount as requiring network availability.NFS, CIFS, and other network-dependent mounts.Helps boot ordering and dependency handling.
x-systemd.device-timeout=...Sets how long the system manager waits for a device to appear.Slow or occasionally delayed devices.Can reduce excessive waits, but an overly short value may reject a slow device.

FAT-family filesystems such as vfat do not store ordinary Linux user and group ownership for each file. Options can map all visible files to an account or group:

UUID=<removable-uuid> /media/share vfat rw,uid=<user-id>,gid=<group-id>,umask=022,nofail 0 0

uid selects the apparent owner, gid selects the apparent group, and umask removes permissions from the filesystem's base mode. Select values appropriate for the intended users. Mount options are filesystem-specific: do not copy options from an ext4 example into a vfat, NFS, or CIFS entry without checking whether they are supported.

Field 5: Dump Backup Flag

The fifth field is a numeric flag for the traditional dump backup utility. A value of 1 enables inclusion in dump processing; 0 excludes the filesystem. Most modern installations do not use dump, so 0 is common.

Field 6: fsck Check Order

The sixth field is the filesystem-check pass number. Boot-time tools can use it to schedule consistency checks:

ValueMeaningTypical placement
0Do not schedule an automatic fsck pass from this entry.Swap, network filesystems, and filesystems where boot checking is not applicable.
1Highest-priority check.Normally the root filesystem mounted at /.
2Check after pass 1; eligible filesystems may be checked after root.Other checkable local filesystems such as a separate data partition.

Whether this field is acted upon depends on filesystem support and the distribution's boot behavior. Not every filesystem supports traditional fsck checking in the same way.

Creating a Persistent Mount Entry

  1. Discover the partition. Inspect devices, filesystem types, labels, UUIDs, and current mount points with lsblk -f. Use sudo blkid when more detail is needed.
  2. Format only when intended. Formatting creates a new filesystem and normally destroys existing data. For example, partitioning tools and mkfs tools are separate operations from configuring fstab.
  3. Create the mount point. For a data partition, use sudo mkdir -p /srv/data.
  4. Back up the configuration. Use sudo cp /etc/fstab /etc/fstab.bak.$(date +%F).
  5. Edit with administrative privileges. sudoedit /etc/fstab opens the file through a root-capable editing workflow.
  6. Add the six fields in order. Prefer the correct UUID or label, an existing mount point, an explicit type, suitable options, and appropriate dump and fsck values.
  7. Validate before rebooting. Run sudo mount -a, then inspect the result.
sudo cp /etc/fstab /etc/fstab.bak.$(date +%F)
sudoedit /etc/fstab
sudo mount -a
findmnt /srv/data
df -Th

A typical additional local partition entry is:

UUID=<data-uuid> /srv/data ext4 defaults 0 2

This is persistent because boot-time processing can read it. By contrast, a direct command such as sudo mount /dev/sdb1 /srv/data normally affects only the current session and does not create persistent configuration.

Mounting a Newly Added Disk or Partition

The complete workflow is:

  1. Use lsblk -f to identify the new disk and partition.
  2. Partition the disk if necessary, using an appropriate partitioning tool.
  3. Create a filesystem if the partition is empty and should be formatted.
  4. Create the intended directory with mkdir -p.
  5. Retrieve the filesystem UUID and type with lsblk -f or blkid.
  6. Back up and edit /etc/fstab.
  7. Test with sudo mount -a.
  8. Confirm the target with findmnt /srv/data and inspect capacity with df -Th.

To remove a test mount, first ensure no process is using it, then run:

sudo umount /srv/data

USB and Removable Devices

Removable hardware may be absent, connected late, or assigned a different device name. It is therefore risky to make a removable drive a mandatory boot dependency. Reference it by UUID or label rather than a changing path such as /dev/sdb1.

Use nofail when the system should continue booting if the device is missing. Use noauto when the device should not be mounted automatically at all and will be mounted explicitly when needed. These options can be combined:

UUID=<usb-uuid> /media/backup ext4 nofail,noauto 0 0

For vfat or other non-POSIX filesystems, add suitable uid, gid, and umask values if ordinary users need access. Test the resulting ownership and permissions rather than assuming they match an ext4 filesystem.

Swap Entries

Swap is disk-backed memory extension, not an ordinary directory-mounted filesystem. A swap partition can be represented as:

UUID=<swap-uuid> none swap sw 0 0

The first field identifies the swap partition. The second field is none because there is no normal directory mount point. The third field is swap, and sw is the swap option. The final two fields are normally 0 0 because swap is activated rather than checked and mounted like a regular filesystem.

Activating swap and mounting a normal filesystem are different operations. A swap entry is processed by swap-management tools, while a normal filesystem is attached to a directory in the Linux tree.

Safe Validation and Boot Protection

sudo mount -a attempts to mount all eligible entries in /etc/fstab. It is the essential first test after editing. Entries with noauto are normally skipped, so test those separately when appropriate.

After a successful test:

  • Use findmnt /target/path to confirm which source and options are active.
  • Use df -Th to confirm the filesystem type and available space.
  • Check that expected files are visible at the mount point.
  • For a removable device, disconnect or test absence only after deciding whether nofail and noauto provide the intended behavior.

Troubleshooting Common Problems

Mount point does not exist

If mount -a reports that the mount point does not exist, inspect the second field for a typo and create the directory:

sudo mkdir -p /srv/data
sudo mount -a

The device path changed

If an entry uses /dev/sdb1 and fails after devices are added or reordered, locate the filesystem again with lsblk -f or sudo blkid. Replace the volatile device path with the correct UUID=... or LABEL=... reference, then run mount -a.

Boot enters emergency mode or waits for a disk

Possible causes include invalid syntax, an incorrect UUID, or an unavailable optional USB or network filesystem. Use recovery access to inspect the file and system logs. Correct the entry or comment it out temporarily. For genuinely optional storage, consider nofail and, when automatic mounting is not wanted, noauto. Validate before rebooting again.

A USB user cannot write files

Check the type and active options with findmnt. A vfat filesystem does not retain normal Linux ownership metadata, so root-mapped ownership or a restrictive umask may prevent writes. Set suitable uid, gid, and umask values, then remount or test with mount -a.

Manual mounting works but boot mounting fails

Compare the successful manual command with every fstab field. The device may not be ready during boot, or a network filesystem may lack network dependency handling. For NFS or CIFS, use an appropriate option such as _netdev, and inspect boot messages or systemd mount-unit logs.

The filesystem is unexpectedly read-only

Use findmnt to see whether ro was explicitly configured. If it was not, check kernel messages and filesystem health: Linux may remount a filesystem read-only after detecting an error. Perform repair safely while the filesystem is unmounted when required.

Reference Examples

# Root filesystem
UUID=<root-uuid> / ext4 defaults 0 1

# Additional local data partition
UUID=<data-uuid> /srv/data ext4 defaults 0 2

# Optional USB disk
UUID=<usb-uuid> /media/backup ext4 nofail,noauto 0 0

# FAT removable media with ownership mapping
UUID=<removable-uuid> /media/share vfat rw,uid=<user-id>,gid=<group-id>,umask=022,nofail 0 0

# Swap partition
UUID=<swap-uuid> none swap sw 0 0

Exam- and Administration-Relevant Notes

  • /etc/fstab is a static configuration file, not a list of currently mounted filesystems.
  • The six fields are identifier, mount point, type, options, dump flag, and fsck pass.
  • UUID or LABEL references are generally more stable than kernel-assigned device paths.
  • The mount-point directory must normally exist, and mounting over it hides its previous contents.
  • nofail permits boot to continue when an optional filesystem is unavailable; noauto prevents ordinary automatic mounting.
  • Root commonly uses fsck pass 1, other checkable local filesystems commonly use 2, and swap commonly uses 0.
  • mount -a is the standard pre-reboot validation step, but entries using noauto need separate testing.