DEV Community

Rohit Jain
Rohit Jain

Posted on

Linux FSTAB

Linux FSTAB

The /etc/fstab file in Linux is a configuration file that contains information about file systems. It is used to mount file systems automatically during system boot up. Each line in the file represents a separate file system and is organized into columns that provide information about the file system.

Understanding the columns in /etc/fstab

The columns in the /etc/fstab file are as follows:

  1. File system: The location of the file system (e.g. /dev/sda1)
  2. Mount Point: The directory where the file system will be mounted (e.g. /mnt/data)
  3. File System Type: The type of file system (e.g. ext4, ntfs, etc.)
  4. Options: Mount options for the file system (e.g. rw, ro, defaults, etc.)
  5. Dump: Specifies whether to include the file system in the backup process (0 or 1)
  6. Pass: Specifies the order in which fsck checks the file system during boot up (0 or 1)

Adding a file system to /etc/fstab

To add a file system to the /etc/fstab file, you need to know the file system location, mount point, file system type, and mount options.

For example, if you want to add an NTFS partition located at /dev/sda1 and mount it at /mnt/data with read-write permissions, you would add the following line to /etc/fstab:/dev/sda1 /mnt/data ntfs rw 0 0

Note that you need to have root privileges to edit the /etc/fstab file.

Mounting and unmounting file systems

You can mount and unmount file systems using the mount and umount commands. For example, to mount the /mnt/data file system, you would run the following command:

sudo mount /mnt/data

And to unmount the /mnt/data file system, you would run:

sudo umount /mnt/data

It's important to unmount a file system before disconnecting or removing the device to avoid data corruption.

Oldest comments (0)