The /etc/fstab file is your Linux system's filesystem configuration table that tells your machine which storage devices (hard drives, partitions, USB drives) to mount and where to mount them when the system boots up.
- The kernel reads this file during boot time to automatically mount all partitions to the Linux filesystem.
- While the
mount command provides temporary mounting (lost after restart), /etc/fstab enables permanent mounting that survives reboots. - This file is read by programs but only written by the system administrator, it's not meant to be edited by regular users.
- Each line describes one filesystem, and the file contains static information (not dynamically updated) about all available disks and partitions.
- Every entry has exactly six fields separated by spaces or tabs, each serving a specific purpose.
Example:
Here's a simple /etc/fstab to understand the structure:
# /etc/fstab
UUID=4d028ac1-d413-4d3a-94b4-251db287744f / ext4 defaults 1 1
UUID=c13ef520-fac6-49b5-8717-1afd49097ef4 /boot ext4 defaults 1 2
UUID=5010a5d7-9457-4a44-85c7-d836b39e06a2 /home ext4 defaults 0 2
UUID=498ae307-b89e-47ac-b1fb-293c2342d417 swap swap defaults 0 0
Breaking down the first line:
- UUID: Uniquely identifies the partition.
/: This mounts to the root directory (the main filesystem).ext4: The partition uses ext4 filesystem format.defaults: Use standard mount settings.1: Run dump on this filesystem.1: Check this filesystem first during boot (root filesystem priority).
Syntax and Field Breakdown
Each line in /etc/fstab follows this pattern:
<Device> <Mount Point> <File System Type> <Mount Options> <Dump> <Fsck Order>
Let's understand each field:
| Field | Purpose | Example |
|---|
| Field 1 - Device | The partition or disk you want to mount (UUID, device name, or label) | UUID=80b496fa-ce2d-4dcf-9afc-bcaa731a67f1or/dev/sdb1 |
| Field 2 - Mount Point | The directory where this device will be attached in your filesystem | /mnt/dataor/home |
| Field 3 - File System Type | The format of the partition (ext4, ext3, vfat, etc.) | ext4orntfs |
| Field 4 - Mount Options | How the device should be mounted (rw, ro, defaults, etc.) | defaultsorrw,noauto |
| Field 5 - Dump | Whether to back up this filesystem (0 = no, 1 = yes) | 0or1 |
| Field 6 - Fsck Order | Boot-time filesystem check order (0 = skip, 1 = root only, 2+ = others) | 0,1, or2 |
Mount Options
Field 4 has several important options you'll encounter:
rw = Read-Write access; ro = Read-Only accessauto = Mount automatically at boot; noauto = Mount only when explicitly requesteddefaults = Use standard options (rw, suid, dev, exec, auto, nouser, async)exec = Allow executing programs; noexec = Prevent executionsync = Write changes immediately; async = Write changes asynchronously
Adding a New External Drive
Let's say you want to add a USB drive permanently. Here's how an entry would look:
/dev/sdc1 /novi_disk ext3 defaults 0 2
This means:
- Mount the first partition of the third disk (
/dev/sdc1) - At the mount point
/novi_disk (you must create this folder first) - Using ext3 filesystem
- With default options
- No dump backup needed
- Check this disk during boot (but after the root filesystem)
Special Case: Swap Space
Swap is virtual memory on disk:
UUID=498ae307-b89e-47ac-b1fb-293c2342d417 swap swap defaults,pri=1 0 0
Here, the mount point is literally the word "swap" because swap doesn't have a traditional mount point.
Fsck Order Values Explained:
- Root filesystem (
/): Always use 1 - Other filesystems: Use
2 if you want them checked - Skip checking: Use
0 (useful for swap, USB drives)
Dump Field: Most students can safely ignore this field and use 0. The dump program is rarely used in modern systems.
Testing Before Rebooting
After editing /etc/fstab, test your changes with:
sudo mount -a
This applies all entries in /etc/fstab without rebooting, helping you catch errors before they cause boot problems.
Common Mount Options Combinations
Here are realistic examples we might encounter:
| Device Type | Typical Options | Why? |
|---|
| Root filesystem | defaults | Needs all standard permissions |
| User data | defaults | Standard read-write access |
| External USB | rw,noauto | Manual mount when needed |
| Shared network | defaults,nofail | Continue boot if unavailable |
| Windows partition | rw,umask=0077 | Restrict permissions for security |
The /etc/fstab file is essential for Linux system administration because it defines how your storage devices integrate into your filesystem automatically. Always remember: test changes with mount -a before rebooting, and use UUIDs instead of device names for reliability.
Explore
Linux/Unix Tutorial
5 min read
Getting Started with Linux
Installation with Linux
Linux Commands
Linux File System
Linux Kernel
Linux Networking Tools
Linux Process
Linux Firewall
Shell Scripting & Bash Scripting