NFS setup on Ubuntu (include fstab)


Hi all,
Past of month, I was too busy to write new blog, though I learn a lot of new things from work.

During working, my customer asked me to build up the NFS (net file system) for them,
so that they can fetch the file between computers by internal network.

When It comes to NFS, you might think about SAMBA server, which can be mounted with CIFS.
SAMBA is a service compatible with linux and window operating system.

Since I just need to make linux OS computer connected, that is no need to build up a SAMBA server on my server PC.

So let's start,

First of all

You have to install the nfs-server and nfs-common on server and client side.
you can also check if the service is installed or not by :
$ dpkg -l | grep nfs-kernel-server

if not,  install the service on server and client :
Server :
# apt-get install nfs-kernel-server

Client:
# apt-get install nfs-common 

Now we can go through the step 2 -- setting up server.

Server :
    create the setting file if you don;t have it
# vim /etc/exports
    Add...
/tmp              *(rw,sync,no_root_squash)
<share folder>   <hostname>(<setting>)
You can replace * with one of the hostname formats. Make the hostname declaration as specific as possible so unwanted systems cannot access the NFS mount.

the setting :
parametercontent
rw
ro
Permission of share folder (read-write or read-only).
NOTE : Actaul permission still up to system permission(eg. 755 or 777)
sync
async
sync respond to write data to hard disk synchrously. However, async will store the data oin memory temporarily.
no_root_squash
root_squash
What will server do, if client use root to access the file?
root_squash : transfer client from root to nobody!
all_squashAll of you are nobody(nfsnobody)!Haha!
anonuid
anongid
anon (anonymous), you can set the nobody's GID, but have to exist in /etc/password

Ok, now we can start the service!!
# sudo systemctl start nfs-kernel-server.service

connect with Client

Now, we can move to client, make sure you have already install the nfs-common.
We can connect with server by :
# 10.87.87.87:/tmp /mnt
< sudo mount example.hostname.com:/ubuntu /local/ubuntu>

Auto mount whenever reboot

To save us from retyping the mount command every time,
we can set it to the fstab
vim /etc/fstab
Add your NFS in fstab
10.87.87.87:/tmp /mnt nfs auto 0 0
Done!

                                       provide


Comments

Popular posts from this blog

UBoot with iMX6 - Part 1

Install chrome on CentOS

Can't find pip3 ? Here is it!