Software & AppsOperating SystemLinux

How To Configure NFS Mounting in fstab

Ubuntu 14

In this article, we will walk you through the process of configuring NFS (Network File System) mounting in the /etc/fstab file on a Unix-like operating system. NFS is a distributed file system protocol that allows a user on a client computer to access files over a network much like local storage is accessed.

What is /etc/fstab?

The /etc/fstab file is a system configuration file on Unix and Unix-like operating systems that contains information about major filesystems on the system. It is used to control how disk partitions, various other block devices, or remote filesystems should be mounted into the filesystem namespace of the system.

NFS Mounting in /etc/fstab

To mount an NFS share automatically at system boot, you can add an entry to the /etc/fstab file. This is especially useful for servers that need to access large amounts of data over the network.

Step 1: Open the /etc/fstab file

Open the /etc/fstab file in a text editor with root privileges. You can use nano, vi, or any other text editor you are comfortable with. For example:

sudo nano /etc/fstab

Step 2: Add a new line for the NFS mount

At the end of the file, add a new line for the NFS mount. This line will contain several fields separated by spaces or tabs.

Step 3: Specify the NFS server and shared folder

The first field is the device field, which should contain the IP address or hostname of the NFS server, followed by a colon, and the path to the shared folder on the server. For example:

192.168.0.216:/mnt/HDD1

Step 4: Specify the local mount point

The second field is the mount point for the filesystem. This is the directory where you will access the NFS share on your local system. For example:

/media/freenas/

Step 5: Set the filesystem type

The third field is for the type of the filesystem. For NFS mounts, this should be nfs.

Step 6: Add mount options

The fourth field is for mount options. These options control various aspects of the filesystem’s behavior. For example, the defaults option uses the default NFS mount options. If you want to specify additional options, you can include them in this field, separated by commas. For example:

defaults,proto=tcp,port=2049

In this case, the proto=tcp,port=2049 option specifies the NFS protocol to use and the port number.

Step 7: Specify dump and filesystem check options

The fifth and sixth fields are for dump and filesystem check options. For NFS mounts, these should both be 0 to disable these features.

Here’s an example of a complete NFS mount entry in /etc/fstab:

192.168.0.216:/mnt/HDD1 /media/freenas/ nfs defaults 0 0

Step 8: Save changes and mount the NFS share

After adding the NFS mount entry to the /etc/fstab file, save the changes and close the file. You can then mount the NFS share automatically by running the mount -a command or by rebooting your system.

sudo mount -a

Conclusion

In this article, we’ve covered how to configure NFS mounting in the /etc/fstab file. This is a crucial step for automating the mounting of NFS shares on your system. Remember to be cautious when specifying mount options, as incorrect options can lead to system instability or data loss. Always test new /etc/fstab entries with the mount -a command before rebooting to ensure they work as expected.

What is NFS?

NFS stands for Network File System. It is a distributed file system protocol that allows a user on a client computer to access files over a network much like local storage is accessed.

Why should I configure NFS mounting in `/etc/fstab`?

Configuring NFS mounting in /etc/fstab allows you to automatically mount NFS shares at system boot, making it convenient for servers that need to access large amounts of data over the network.

How do I open the `/etc/fstab` file?

You can open the /etc/fstab file in a text editor with root privileges, such as nano or vi. For example, you can use the command sudo nano /etc/fstab to open it with nano.

What should I specify in the device field when adding an NFS mount entry?

In the device field, you should specify the IP address or hostname of the NFS server, followed by a colon, and the path to the shared folder on the server. For example: 192.168.0.216:/mnt/HDD1.

What is the mount point and how do I specify it?

The mount point is the directory where you will access the NFS share on your local system. You can specify it as the second field in the /etc/fstab entry. For example: /media/freenas/.

What should I set the filesystem type as for NFS mounts?

For NFS mounts, the filesystem type should be set as nfs.

Can I specify additional mount options for NFS?

Yes, you can specify additional mount options in the fourth field of the /etc/fstab entry. Separate multiple options with commas. For example: defaults,proto=tcp,port=2049.

What should I set the dump and filesystem check options for NFS mounts?

For NFS mounts, both the dump and filesystem check options should be set as 0 to disable these features.

How do I save changes and mount the NFS share?

After adding the NFS mount entry to the /etc/fstab file, save the changes and close the file. Then, you can mount the NFS share automatically by running the sudo mount -a command or by rebooting your system.

What should I do if I encounter issues with NFS mounting?

If you encounter issues with NFS mounting, double-check your /etc/fstab entry for any errors. You can also try manually mounting the NFS share using the mount command to see if there are any specific error messages.

Leave a Comment

Your email address will not be published. Required fields are marked *