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 number | Field name | Purpose | Typical values | Important notes |
|---|---|---|---|---|
| 1 | Filesystem identifier | Selects the device, UUID, label, or special source. | UUID=..., /dev/sda1, none | Stable identifiers are usually safer than device names. |
| 2 | Mount point | Directory where the filesystem is attached. | /, /home, /srv/data, none | The directory normally must already exist. |
| 3 | Filesystem type | Identifies the filesystem format and driver. | ext4, xfs, vfat, swap | auto can request type detection. |
| 4 | Mount options | Controls access, behavior, security, and timing. | defaults, ro, nofail | Options are comma-separated. |
| 5 | Dump flag | Controls inclusion in the traditional dump backup utility. | 0, 1 | Most modern systems use 0. |
| 6 | fsck pass | Sets boot-time filesystem consistency-check order. | 0, 1, 2 | Root 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.
| Format | Example form | Stability | Recommended use |
|---|---|---|---|
| Device path | /dev/sdb1 | May change when hardware is added, removed, or reordered. | Useful for temporary work or when the device identity is controlled. |
| UUID | UUID=4f2a-... | Usually stable for the filesystem until it is reformatted or its identifier is changed. | Preferred for most persistent mounts. |
| LABEL | LABEL=backup | Stable until the filesystem label is changed; must be unique enough to avoid ambiguity. | Convenient when a meaningful human-readable name is desired. |
| Special source | none | Not 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/dataor/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
| Type | Typical use | Notable option considerations |
|---|---|---|
ext4 | Common Linux local filesystem. | Often works with defaults; commonly checked with pass 2 when it is not root. |
ext3 | Older journaling Linux filesystem. | Use options supported by the installed filesystem tools. |
xfs | Scalable Linux filesystem used for local data. | Filesystem checking and repair behavior differs from ext filesystems. |
btrfs | Linux filesystem with features such as subvolumes and snapshots. | Subvolume and distribution-specific options may be required. |
vfat | FAT-family removable media and compatibility partitions. | Use uid, gid, and umask to map ownership and permissions. |
exfat | Large removable media shared with other operating systems. | Ownership and permission behavior depends on the driver and mount options. |
ntfs | NTFS volumes, often shared with Windows. | Use the appropriate installed NTFS driver and its supported options. |
swap | Swap partition or swap file. | Activated with swap tools rather than mounted at a normal directory. |
nfs | Network File System export. | Requires network availability and appropriate client configuration. |
cifs | SMB 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.
| Option | Effect | Typical use case | Security or boot impact |
|---|---|---|---|
defaults | Uses the standard default option set. | Normal local filesystems. | A starting point, not a complete security policy. |
rw / ro | Mount 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 / noexec | Allows 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 / nosuid | Allows or ignores set-user-ID and set-group-ID permission effects. | Untrusted or removable storage. | nosuid limits privilege-related behavior. |
dev / nodev | Allows or ignores device nodes on the filesystem. | Removable or untrusted storage. | nodev prevents device files there from acting as devices. |
user | Allows a user to mount; normally implies restrictions and permits that user to unmount. | User-controlled removable media. | Understand the implied behavior before using it. |
users | Allows users to mount and unmount. | Shared removable media. | Broader permission than user. |
owner | Allows the device owner to mount. | Some removable-device workflows. | Behavior depends on the device and mount system. |
noauto | Excludes the entry from ordinary automatic mounting, including mount -a. | Optional media mounted only on demand. | Prevents an absent device from being automatically attempted. |
nofail | Allows 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. |
_netdev | Marks 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:
| Value | Meaning | Typical placement |
|---|---|---|
0 | Do not schedule an automatic fsck pass from this entry. | Swap, network filesystems, and filesystems where boot checking is not applicable. |
1 | Highest-priority check. | Normally the root filesystem mounted at /. |
2 | Check 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
- Discover the partition. Inspect devices, filesystem types, labels, UUIDs, and current mount points with
lsblk -f. Usesudo blkidwhen more detail is needed. - Format only when intended. Formatting creates a new filesystem and normally destroys existing data. For example, partitioning tools and
mkfstools are separate operations from configuringfstab. - Create the mount point. For a data partition, use
sudo mkdir -p /srv/data. - Back up the configuration. Use
sudo cp /etc/fstab /etc/fstab.bak.$(date +%F). - Edit with administrative privileges.
sudoedit /etc/fstabopens the file through a root-capable editing workflow. - 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.
- 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:
- Use
lsblk -fto identify the new disk and partition. - Partition the disk if necessary, using an appropriate partitioning tool.
- Create a filesystem if the partition is empty and should be formatted.
- Create the intended directory with
mkdir -p. - Retrieve the filesystem UUID and type with
lsblk -forblkid. - Back up and edit
/etc/fstab. - Test with
sudo mount -a. - Confirm the target with
findmnt /srv/dataand inspect capacity withdf -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/pathto confirm which source and options are active. - Use
df -Thto 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
nofailandnoautoprovide 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/fstabis 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.
nofailpermits boot to continue when an optional filesystem is unavailable;noautoprevents ordinary automatic mounting.- Root commonly uses fsck pass
1, other checkable local filesystems commonly use2, and swap commonly uses0. mount -ais the standard pre-reboot validation step, but entries usingnoautoneed separate testing.