Understanding the /etc/fstab File in Linux

By 

Updated on

12 min read

The /etc/fstab file shown as a Linux storage configuration map

The /etc/fstab file (filesystem table) is a system configuration file that defines how filesystems, partitions, and storage devices are mounted at boot time. The system reads this file during startup and mounts each entry automatically.

Understanding /etc/fstab is essential when you need to add a new disk , create a swap file , mount a network share , or change mount options for an existing filesystem.

This guide explains the /etc/fstab file format, what each field means, common mount options, and how to add new entries safely.

/etc/fstab Format

The /etc/fstab file is a plain text file with one entry per line. Each line defines a filesystem to mount. Lines beginning with # are comments and are ignored by the system.

To view the contents of the file safely, use less :

Terminal
less /etc/fstab

A typical /etc/fstab file looks like this:

output
# <file system>                           <mount point>  <type>  <options>         <dump>  <pass>
UUID=a1b2c3d4-e5f6-7890-abcd-ef1234567890  /              ext4    errors=remount-ro  0       1
UUID=b2c3d4e5-f6a7-8901-bcde-f12345678901  /home          ext4    defaults           0       2
UUID=c3d4e5f6-a7b8-9012-cdef-123456789012  none           swap    defaults           0       0
tmpfs                                      /tmp           tmpfs   defaults,noatime   0       0

Each entry contains six space-separated fields:

txt
UUID=a1b2c3d4...  /home  ext4  defaults  0  2
[---------------] [---]  [--]  [------]  -  -
|                   |      |      |      |  |
|                   |      |      |      |  +-> 6. Pass (fsck order)
|                   |      |      |      +----> 5. Dump (backup flag)
|                   |      |      +-----------> 4. Options
|                   |      +------------------> 3. Type
|                   +-------------------------> 2. Mount point
+---------------------------------------------> 1. File system

The fields are separated by spaces or tabs, and the columns do not have to line up. The alignment in the examples above only makes the file easier to read.

Field Descriptions

  1. File system - The device or partition to mount. This can be specified as:

    • A UUID: UUID=a1b2c3d4-e5f6-7890-abcd-ef1234567890
    • A disk label: LABEL=home
    • A device path: /dev/sda1
    • A network path: 192.168.1.10:/export/share (for NFS)

    Using UUIDs is recommended because device paths like /dev/sda1 can change if disks are added or removed. To find the UUID of a partition, run blkid, or lsblk -f if you want the same information laid out as a device tree:

    Terminal
    sudo blkid
  2. Mount point - The directory where the filesystem is attached. The directory must already exist. Common mount points include /, /home, /boot, and /mnt/data. For swap entries, this field is set to none.

  3. Type - The filesystem type. Common values include:

    • ext4 - The default Linux filesystem
    • xfs - High-performance filesystem used on RHEL-based distributions
    • btrfs - Copy-on-write filesystem with snapshot support
    • swap - Swap partition or file
    • tmpfs - Temporary filesystem stored in memory
    • nfs - Network File System
    • vfat - FAT32 filesystem (USB drives, EFI partitions)
    • auto - Let the kernel detect the filesystem type automatically
  4. Options - A comma-separated list of mount options. See the Common Mount Options section below for details.

  5. Dump - Used by the dump backup utility. A value of 0 means the filesystem is not included in backups. A value of 1 means it is. Most modern systems do not use dump, so this is typically set to 0.

  6. Pass - The order in which fsck checks filesystems at boot. The root filesystem should be 1. Other filesystems should be 2 so they are checked after root. A value of 0 means the filesystem is not checked.

Common Mount Options

The fourth field in each fstab entry is a comma-separated list of mount options. The following options are the most commonly used:

  • defaults - Uses the standard default options (rw, suid, dev, exec, auto, nouser, async). Some effective behaviors can still vary by filesystem and kernel settings.
  • ro - Mount the filesystem as read-only.
  • rw - Mount the filesystem as read-write.
  • relatime - Update file access times when the stored access time is not newer than the modify or change time, or when it is more than 24 hours old. The kernel has behaved this way by default since Linux 2.6.30.
  • noatime - Do not update file access times at all. The gain over the default relatime behavior is small on most systems, but it still helps on workloads that read many files.
  • nodiratime - Do not update directory access times.
  • noexec - Do not allow execution of binaries on the filesystem.
  • nosuid - Do not allow set-user-ID or set-group-ID bits to take effect.
  • nodev - Do not interpret character or block special devices on the filesystem.
  • nofail - Do not report errors if the device does not exist at boot. Useful for removable drives and network shares.
  • auto - Mount the filesystem automatically at boot (default behavior).
  • noauto - Do not mount automatically at boot. The filesystem can still be mounted manually with mount.
  • user - Allow a regular user to mount the filesystem.
  • errors=remount-ro - Remount the filesystem as read-only if an error occurs. Common on root filesystem entries.
  • _netdev - The filesystem requires network access. The system waits for the network to be available before mounting. Use this for NFS, CIFS, and iSCSI mounts.
  • x-systemd.automount - Mount the filesystem on first access instead of at boot. Managed by systemd.
  • x-systemd.device-timeout=30 - How long systemd waits for the device to appear before giving up. Useful for external enclosures that take a few seconds to spin up.
  • x-systemd.requires=UNIT - Wait for another systemd unit to start before mounting. Handy when the filesystem depends on a VPN or a decryption service.
  • subvol=NAME - Mount a specific btrfs subvolume instead of the top-level one. Distributions that install on btrfs, such as Fedora and openSUSE, use entries like subvol=root or subvol=@.

You can combine multiple options separated by commas:

txt
UUID=a1b2c3d4...  /data  ext4  defaults,noatime,nofail  0  2

Ownership and Permission Options

Filesystems such as vfat, exfat, and ntfs do not store Unix ownership or permission bits, so the kernel has to assign them at mount time. Everything on the drive ends up owned by root by default, which is why a regular user often cannot write to a freshly mounted USB stick. The following options set what the kernel assigns:

  • uid=1000 - Numeric user ID that owns every file on the filesystem.
  • gid=1000 - Numeric group ID that owns every file on the filesystem.
  • umask=022 - Permission bits to remove from both files and directories, in the same notation as the umask command.
  • dmask=022 - Permission bits to remove from directories only.
  • fmask=133 - Permission bits to remove from files only.

Look up your own IDs with the id command before writing the entry:

Terminal
id -u; id -g
output
1000
1000

The first number is the user ID and the second is the group ID. On cifs mounts, uid, gid, file_mode, and dir_mode apply when the server does not provide Unix ownership and modes. If Unix extensions are available, the values reported by the server normally take precedence.

How fstab Is Used at Boot

On a systemd-based distribution, the mounts in /etc/fstab are not carried out by reading the file line by line at boot. A generator called systemd-fstab-generator runs early in the startup sequence and converts every entry into a native mount unit. An entry for /mnt/data becomes a unit named mnt-data.mount, and systemd starts it the same way it starts any other unit.

The generator also decides when each mount happens. Local filesystems are ordered before local-fs.target, so they are in place before the rest of the system comes up. Network filesystems are ordered before remote-fs.target instead, which waits for networking. systemd recognizes types such as nfs and cifs on its own, and the _netdev option overrides that detection for anything it cannot classify, such as an iSCSI device formatted with ext4.

To see the units that were generated from your file, list the active mount units:

Terminal
systemctl list-units --type=mount

Because those units are generated rather than written by hand, an edit to /etc/fstab does not reach systemd until the manager reloads its configuration. That is the reason for the systemctl daemon-reload in the next section.

Adding an Entry to /etc/fstab

Before editing /etc/fstab, always create a backup:

Terminal
sudo cp /etc/fstab /etc/fstab.bak

Step 1: Find the UUID

Identify the UUID of the partition you want to mount:

Terminal
sudo blkid /dev/sdb1
output
/dev/sdb1: UUID="d4e5f6a7-b8c9-0123-def0-123456789abc" TYPE="ext4"

Step 2: Create the Mount Point

Create the directory where the filesystem will be mounted:

Terminal
sudo mkdir -p /mnt/data

Step 3: Add the Entry

Open /etc/fstab in a text editor :

Terminal
sudo nano /etc/fstab

Add a new line at the end of the file:

/etc/fstabsh
UUID=d4e5f6a7-b8c9-0123-def0-123456789abc  /mnt/data  ext4  defaults,nofail  0  2

Step 4: Reload and Test the Entry

On systemd-based systems, reload the generated mount units after editing /etc/fstab:

Terminal
sudo systemctl daemon-reload

Then verify the file syntax and mount relationships:

Terminal
sudo findmnt --verify

Instead of rebooting, use mount -a to mount fstab entries that are not already mounted and do not use the noauto option:

Terminal
sudo mount -a

If the command produces no output, the entry is correct. If there is an error, fix the fstab entry before rebooting, as an incorrect fstab can prevent the system from booting normally.

Verify the filesystem is mounted :

Terminal
df -h /mnt/data

Common fstab Examples

Swap File

To add a swap file to fstab:

/etc/fstabsh
/swapfile  none  swap  defaults  0  0

NFS Network Share

To mount an NFS share that requires network access:

/etc/fstabsh
192.168.1.10:/export/share  /mnt/nfs  nfs  defaults,_netdev,nofail  0  0

CIFS/SMB Windows Share

To mount a Windows/Samba share with a credentials file:

/etc/fstabsh
//192.168.1.20/share  /mnt/smb  cifs  credentials=/etc/samba/creds,_netdev,nofail  0  0

The credentials file itself holds the account used to reach the share:

/etc/samba/credstxt
username=shareuser
password=sharepassword

Set strict permissions on it so other users cannot read it:

Terminal
sudo chmod 600 /etc/samba/creds
Warning
The credentials file stores the password in plain text. Keep it under /etc, owned by root with 0600 permissions, and never copy it into a project directory or commit it to version control. If a deployment repository refers to the path, add the file to .gitignore and keep the real copy on the server only.

USB or External Drive

To mount a removable drive that may not always be attached:

/etc/fstabsh
UUID=e5f6a7b8-c9d0-1234-ef01-23456789abcd  /mnt/usb  ext4  defaults,nofail,noauto  0  0

The nofail option prevents boot errors when the drive is not connected. The noauto option prevents automatic mounting; mount it manually with sudo mount /mnt/usb when needed.

User-Writable exFAT or FAT32 Drive

Removable drives are usually formatted with exfat or vfat, which carry no ownership information of their own. Map the whole filesystem to your account so you can write to it without sudo:

/etc/fstabsh
UUID=1234-ABCD  /mnt/usb  exfat  defaults,nofail,uid=1000,gid=1000,dmask=022,fmask=133  0  0

The masks give directories 0755 permissions and regular files 0644 permissions, so files are not marked as executable. The UUID here is much shorter than the one on an ext4 partition because vfat and exfat store a volume serial number rather than a full UUID. Use whatever blkid reports for the device.

tmpfs for /tmp

To mount /tmp as a temporary filesystem in memory:

/etc/fstabsh
tmpfs  /tmp  tmpfs  defaults,noatime,size=2G  0  0

Quick Reference

For a printable quick reference, see the mount cheatsheet .

TaskCommand
View fstab contentsless /etc/fstab
Back up fstabsudo cp /etc/fstab /etc/fstab.bak
Find partition UUIDssudo blkid
Reload systemd mount unitssudo systemctl daemon-reload
List generated mount unitssystemctl list-units --type=mount
Verify fstab syntaxsudo findmnt --verify
Mount all fstab entriessudo mount -a
Check mounted filesystemsmount or df -h
Check filesystem typelsblk -f
Restore fstab from backupsudo cp /etc/fstab.bak /etc/fstab

Troubleshooting

System does not boot after editing fstab
A required entry that cannot be mounted may interrupt the boot process and drop you into an emergency shell. If the root filesystem is read-only, remount it read-write before changing anything:

Terminal
mount -o remount,rw /

Restore the backup you took earlier, or open the file and correct the offending line:

Terminal
cp /etc/fstab.bak /etc/fstab

Then reload the generated mount units and reboot:

Terminal
systemctl daemon-reload
reboot

These commands assume that the emergency shell has given you a root prompt. If you cannot reach the shell, boot from a live USB, mount the root partition, and edit /etc/fstab from there. Running sudo findmnt --verify and sudo mount -a before you reboot avoids the situation in the first place.

mount -a reports “wrong fs type” or “bad superblock”
The filesystem type in the fstab entry does not match the actual filesystem on the device. Use sudo blkid or lsblk -f to check the correct type.

Network share fails to mount at boot
Add the _netdev option to tell the system to wait for network availability before mounting. For systemd-based systems, x-systemd.automount can also help with timing issues.

“mount point does not exist”
The directory specified in the second field does not exist. Create it with mkdir -p /path/to/mountpoint before running mount -a.

UUID changed after reformatting a partition
Reformatting a partition assigns a new UUID. Run sudo blkid to find the new UUID and update the fstab entry accordingly.

FAQ

What happens if I make an error in /etc/fstab?
If the entry references a non-existent device without the nofail option, the system may drop to an emergency shell during boot. Always use nofail for non-essential filesystems and test with sudo mount -a before rebooting.

Should I use UUID or device path (/dev/sda1)?
Use UUID. Device paths can change if you add or remove disks, or if the boot order changes. UUIDs are unique to each filesystem and do not change unless you reformat the partition.

What does the nofail option do?
It tells the system to continue booting even if the device is not present or cannot be mounted. Without nofail, a missing device causes the system to drop to an emergency shell.

How do I remove an fstab entry?
Open /etc/fstab with sudo nano /etc/fstab, delete or comment out the line (add # at the beginning), save the file, and then unmount the filesystem with sudo umount /mount/point.

What is the difference between noauto and nofail?
noauto prevents the filesystem from being mounted automatically at boot; you must mount it manually. nofail still mounts automatically but does not cause a boot error if the device is missing.

Conclusion

The /etc/fstab file controls how filesystems are mounted at boot. Each entry specifies the device, mount point, filesystem type, options, and check order. Always back up fstab before editing, use UUIDs instead of device paths, and test changes with sudo mount -a before rebooting.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 1000+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page