Introduction to NFS in Linux
Are you tired of having to copy files over two systems constantly? Why not mount your local file systems over a network and remote hosts to interact with them as they are mounted locally on the same system. Didn’t understand? In this post, we will be going over the basics of NFS in Linux.
NFS in Linux
NFS (Network File System) as the name indicates is a way of mounting Linux directories over a network. It was basically developed to share files and folders between two Linux systems in a faster and better way. It was developed by Sun Microsystems in 1980 for this sole purpose. NFS uses Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) to provide a stateless connection between client and server.
Why Should We Use NFS?
As they say, sharing is caring. So, NFS is one of the best methods to share between to 2 Linux systems. The main purpose of NFS is back up data into a central server that is accessible to all PCs in a network. Instead of copying a file from a system to a system, it’s easier to create NFS so that all PCs have access to that file. Newer versions of NFS also support ACL, pseudo root mounts. The best part is there is manual refreshing required to see new files. Also, it can be secured with Firewalls and Kerberos.
When Should We Use NFS?
NFS can be used whenever sharing has to be done among Linux systems. To share between a Windows PC and a Linux use Samba on the Windows side. Yea that’s as simple as that!!
How to Setup NFS in Your Linux System?
First things first, install packages for NFS using the command “sudo apt-get install NFS-kernel-server” on the terminal.
If a command is correct, you will be able to see something like this in the terminal, wait for the installation to be over
4.5 (2,900 ratings)
1. Make a folder that needs to be shared. Example: I have created a folder named “nfs_arjun”
2. Edit exports file in /etc with your favorite text editor. If you are not in root mode, use sudo while editing.
3. Add the following line to the exports file in the format
“folder_to_shared” “ip”(specify access and other sharing options in this bracket)
4. Save the edit done to exports file and run the command “exportfs –r”
5. Start NFS service by executing the following command “/etc/init.d/nfs start”
6. Just to make sure your NFS share is visible to the client, run the following command on the NFS server.
7. If your export list shows your folder and IP address, Voila you did it!!
Now all you have to do is mount it and its ready to use.
How to Setup NFS in Between a Linux System and a Windows System?
Now let us learn how to set up NFS between Linux and Windows system. After setting up NFS on the Linux side, enable the features for NFS in Windows.
Open Start > Control Panel > Programs. Select Turn Windows Features on or off. Select Services for NFS. Click OK
We can use the “mount” command to use NFS on windows systems. Also, provide the “nolock” option and other parameters like remote NFS server IP address and local drive which is “Z” here.
mount -o nolock 172.16.3.56:/mnt z:
We can also use “net use” to mount NFS onto Windows system by using command
net use z: \\172.16.3.56\mnt
NFS in Linux is one of the most useful things that you can learn to do. It helps a lot when you have to share a file/folder with multiple PCs. You just learned fundamentals and How to set it up NFS in Linux and mount it onto other systems.
This is a guide to NFS mount in Linux. Here we discuss how to set up NFS in your Linux system? along with why and when should we use NFS?. You may also look at the following articles to learn more –