Linux

fstab Syntax in Linux: Complete Configuration Guide

In this guide, you'll learn the structure of the fstab file, how to identify disk UUIDs, and properly configure automatic mounting. After completing, you'll be able to edit fstab for any filesystem type.

Updated at February 15, 2026
15-20 minutes
Medium
FixPedia Team
Применимо к:Linux (any distribution)systemd-based systems

Introduction / Purpose

The fstab file (/etc/fstab) is a key configuration file in Linux that defines how the system should mount partitions and removable media at boot. Proper fstab configuration allows disks to be automatically mounted, avoids manual mounting after each reboot, and sets access parameters. In this guide, you will learn the basic fstab syntax, how to add new entries for various filesystem types, and how to avoid common errors.

Prerequisites / Preparation

Before you begin, ensure you have:

  • Superuser access (sudo privileges).
  • Basic understanding of terms: disk partition, mount point, filesystem.
  • A backup of your current fstab (in case of errors):
    sudo cp /etc/fstab /etc/fstab.backup
    
  • Utilities installed for working with different filesystems (e.g., ntfs-3g for NTFS, cifs-utils for SMB).

Step 1: Understand the fstab Line Structure

Each line in fstab describes one partition or device and consists of six fields, separated by spaces or tabs:

<device> <mount_point> <fs_type> <options> <dump> <pass>

Field explanations:

  1. <device> — How to identify the partition. It is recommended to use UUID (unique identifier) or LABEL (volume label). Examples:
    • UUID=1234-ABCD
    • LABEL=MyData
    • /dev/sda1 (not recommended, as device names can change).
  2. <mount_point> — The directory where the partition will be mounted. It must exist (create it beforehand if needed).
  3. <fs_type> — The filesystem type. Common values:
    • ext4, ext3, ext2 — for Linux partitions.
    • ntfs — for Windows partitions (use the ntfs-3g driver).
    • vfat — for FAT32.
    • swap — for swap partitions.
    • nfs, cifs — for network drives.
    • auto — automatic detection (not always reliable).
  4. <options> — A comma-separated list of mount options without spaces. Most common:
    • defaults — a set of standard options: rw,suid,dev,exec,auto,nouser,async.
    • noatime — do not update file access time (improves performance).
    • nodiratime — same for directories.
    • uid=1000,gid=1000 — set owner and group (for FAT/NTFS).
    • dmask=022,fmask=133 — permission masks for directories and files.
    • noauto — do not mount automatically at boot (only on command).
    • _netdev — wait for network connection (for NFS/SMB).
  5. <dump> — Used by the dump utility. Usually 0 (do not dump).
  6. <pass> — The order in which the filesystem is checked at boot (fsck).
    • 0 — do not check.
    • 1 — for the root partition (/).
    • 2 — for other partitions.

Example line:

UUID=1234-ABCD / ext4 defaults,noatime 0 1

Step 2: Determine the UUID of the Target Partition

UUID is the most reliable way to identify partitions. To find the UUID:

  1. Run the command:
    sudo blkid
    
  2. Find the desired partition in the output. Example:
    /dev/sda1: UUID="1234-ABCD" TYPE="ext4" PARTUUID="..."
    /dev/sdb1: UUID="5678-EFGH" TYPE="ntfs" PARTUUID="..."
    
  3. Copy the UUID value (in quotes) for use in fstab.

💡 Tip: If a partition does not appear in blkid, it may not contain a filesystem or is not connected. Ensure the disk is properly connected.

Step 3: Add a New Entry to fstab

  1. Open the /etc/fstab file in a text editor with superuser privileges (e.g., nano or vim):
    sudo nano /etc/fstab
    
  2. Add a new line at the end of the file, following the format from Step 1. Ensure that:
    • Fields are separated by spaces or tabs (do not mix!).
    • The mount point exists (create it if needed: sudo mkdir -p /mnt/mydisk).
  3. Save the file and close the editor.

Examples for different filesystem types:

  • ext4 (system or user Linux partition):
    UUID=1234-ABCD / ext4 defaults,noatime,errors=remount-ro 0 1
    

    The errors=remount-ro option will remount the partition as read-only on errors.
  • NTFS (secondary Windows partition):
    UUID=5678-EFGH /mnt/ntfs ntfs-3g defaults,uid=1000,gid=1000,dmask=022,fmask=133 0 0
    

    Replace uid=1000,gid=1000 with your own IDs (find them via id -u and id -g).
  • Swap (swap partition):
    UUID=9012-IJKL none swap sw 0 0
    
  • NFS network drive:
    nfs-server:/share /mnt/nfs nfs defaults,_netdev 0 0
    

    _netdev ensures mounting waits for the network to be ready.
  • USB drive FAT32:
    UUID=MNOP-QRST /mnt/usb vfat defaults,utf8,uid=1000,gid=1000 0 0
    

Step 4: Check Syntax and Test Mounting

Do not reboot immediately! First, check the syntax and ensure the new entries work:

  1. Run the command to check all fstab entries:
    sudo mount -a
    
    • If the output is empty and the return code is 0 — the syntax is correct, and all partitions are mounted (or were already mounted).
    • If errors appear (e.g., wrong fs type or no such device), go back to fstab and fix the entry.
  2. Ensure the partition is mounted:
    mount | grep /mount_point
    

    Or:
    df -hT /mount_point
    

    The output should show your partition with the correct filesystem type.
  3. Check permissions (especially for NTFS/FAT):
    ls -ld /mount_point
    

    The owner should be the uid specified in the options (usually your user).

Step 5: Reboot the System or Apply Changes

If mount -a succeeded:

  • Option 1: Reboot the system to test automatic mounting at boot:
    sudo reboot
    
    After booting, check again with df -h.
  • Option 2: If you want to apply changes without rebooting, mount the specific partition:
    sudo mount /mount_point
    

Verifying the Result

After rebooting or manual mounting, ensure that:

  1. The partition appears in the output of df -h or mount.
  2. Files on the partition are accessible for reading/writing (depending on options).
  3. For a swap partition, check: sudo swapon --show (should be listed).

If the partition did not mount automatically, check:

  • The UUID is correct (run blkid again).
  • The mount point exists.
  • There are no typos in fstab (especially in options).

Troubleshooting

1. System does not boot after editing fstab

Symptom: Boot stops with Failed to mount /... or drops to emergency mode. Solution:

  • Boot into recovery mode or use a LiveCD.
  • Unmount the problematic partition if needed: sudo umount /mount_point.
  • Edit fstab, commenting out the problematic line (add # at the beginning).
  • Reboot and fix the entry, comparing with the examples.

2. Error wrong fs type, bad option, bad superblock

Cause: Incorrect filesystem type, options, or corrupted superblock. Solution:

  • Check the filesystem type via sudo blkid and correct the third field.
  • Simplify options: start with defaults.
  • For NTFS, ensure ntfs-3g is installed: sudo apt install ntfs-3g (Debian/Ubuntu) or sudo yum install ntfs-3g (RHEL/Fedora).

3. Partition mounts but access is root-only

Cause: For filesystems that do not support Linux permissions (FAT, NTFS), uid/gid are not set. Solution: Add uid=1000,gid=1000 to the options (substitute your own IDs). For NTFS, you can also use umask=022 for shared permissions.

4. Network drive does not mount at boot

Cause: Network is not yet ready. Solution: Add the _netdev option to the options field. You can also increase the timeout in the systemd unit (but that is an advanced setting).

5. Error mount: /mount_point: special device /dev/sdX1 does not exist.

Cause: The device name has changed (e.g., /dev/sda1/dev/sdb1). Solution: Use UUID instead of the /dev/sdX path. This solves the problem in 99% of cases.

⚠️ Important: Always back up /etc/fstab before editing. One mistake can make the system unbootable.

You are now confident with fstab! For more complex scenarios (such as conditional mounting or encryption), explore advanced options in man mount and man fstab.

F.A.Q.

What is UUID and why is it needed in fstab?
How to disable partition mounting via fstab?
What to do if the system doesn't boot after editing fstab?
Which mount options are safe for NTFS?

Hints

Study the structure of an fstab line
Identify the UUID of the target partition
Add a new entry to fstab
Check syntax and test mounting
Reboot the system or apply changes
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community