NFS - Creating a Network drive Quick NFS how-toFollow @ggarron
NFS or Network File System is a great way to share documents, or expand your disk space, using the disk on another server, I am using it to share documents between my office and home, I have my office disk mounted in my home's PC using NFS.
Well the PC at my office has CentOS, so the first thing I need is to install the necessary software.
yum install nfs-utils portmap
If you are using Debian write:
sudo aptitude install nfs-user-server portmap
Ok, now we need to configure it, there are basically two configuration files one in the server side, and one the client side.
At the server
We need to edit
/etc/exports file and add something like this:
That line tells the server that the directory
/home/user is allowed to be exported to all the class C 192.168.1.0 PCs, and they will have read and write access, and sync makes the server to be sure that files are written to stable storage, and with async the server tells the client it has written while it actually has not, so it improves performance but can corrupt data.
Now we need to start the daemons.
At the client side
Now at the client site, we need to mount the partition, we have two options:
That line is only needed once, and it is to have a mount point.
mount 192.168.1.1:/home/user /media/nfs
/etc/fstab and add the following line:
10.1.1.1:/home/nfs /media nfs rw,hard,intr 0 0
Now it is mounted, the permissions will be the same than in the server side, in my case because I was using CentOS on the server and Debian on the client, I had the problem that all files belonged to user 500 and group 500 (first user in CentOS) but in Debian it is usually 1000, so I had to create another user in the server side:
useradd nfs -u 1000
And then I copied all my needed files on the
Trouble shootingIf you have any trouble use this command to see if everything is ok.
rpcinfo -pThe output should be something like this:
program vers proto port 100000 2 tcp 111 portmapper 100000 2 udp 111 portmapper 100011 1 udp 972 rquotad 100011 2 udp 972 rquotad 100011 1 tcp 975 rquotad 100011 2 tcp 975 rquotad 100003 2 udp 2049 nfs 100003 3 udp 2049 nfs 100003 4 udp 2049 nfs 100003 2 tcp 2049 nfs 100003 3 tcp 2049 nfs 100003 4 tcp 2049 nfs 100021 1 udp 32773 nlockmgr 100021 3 udp 32773 nlockmgr 100021 4 udp 32773 nlockmgr 100021 1 tcp 32774 nlockmgr 100021 3 tcp 32774 nlockmgr 100021 4 tcp 32774 nlockmgr 100005 1 udp 988 mountd 100005 1 tcp 991 mountd 100005 2 udp 988 mountd 100005 2 tcp 991 mountd 100005 3 udp 988 mountd 100005 3 tcp 991 mountdEdit 01/27/09, If you get this error:
wrong fs type, bad option, bad superblockWhen you try to mount the nfs file system, read nfs mounting error Finally I really recommend you to read these documents. CentOS NFS NFS Howto