/etc/fstab
The /etc/fstab
file is a configuration file on Unix-like operating systems that contains information about different filesystems and partitions and their respective mount points. It is crucial for automating the process of mounting partitions and filesystems at boot time.
Structure of /etc/fstab
/etc/fstab
The file typically contains lines with the following fields:
Device: The device or partition to be mounted.
Mount Point: The directory where the device or partition will be mounted.
Filesystem Type: The type of filesystem on the device or partition (e.g.,
ext4
,xfs
,swap
,nfs
).Options: Mount options (e.g.,
defaults
,ro
,rw
,noatime
).Dump: Used by the
dump
utility to decide if a filesystem should be backed up (usually set to0
or1
).Pass: Used by
fsck
to determine the order in which filesystems should be checked at boot time (usually0
,1
, or2
).
Example /etc/fstab
/etc/fstab
Fields Explained
Device
Can be specified by the device file (e.g.,
/dev/sda1
), UUID (e.g.,UUID=123e4567-e89b-12d3-a456-426655440000
), or LABEL (e.g.,LABEL=root
).
Mount Point
The directory where the filesystem will be mounted. For swap space, use
none
.
Filesystem Type
Common types include
ext4
,xfs
,btrfs
,nfs
,vfat
,ntfs
, andswap
.
Options
defaults
: Uses the default options (rw
,suid
,dev
,exec
,auto
,nouser
,async
).ro
: Mounts the filesystem as read-only.rw
: Mounts the filesystem as read-write.noatime
: Prevents the system from updating the access time on files.auto
: Automatically mounts the filesystem at boot.noauto
: Does not mount the filesystem at boot.user
: Allows a non-root user to mount the filesystem.
Dump
0
: Do not dump.1
: Dump this filesystem.
Pass
0
: Do not check.1
: Check this filesystem first.2
: Check this filesystem after those with a1
.
Common Use Cases
Mounting a Local Disk Partition
Mounting a Swap Partition
Mounting a Network Filesystem (NFS)
Mounting a Filesystem by UUID
Managing /etc/fstab
/etc/fstab
Adding a New Entry
Edit
/etc/fstab
Add the new entry:
Create the mount point:
Mount all filesystems:
Conclusion
The /etc/fstab
file is an essential configuration file for defining how and where disk partitions, network shares, and other filesystems are mounted. Understanding its structure and options allows for effective management of system storage, ensuring that filesystems are correctly mounted at boot time or on demand.
Last updated