Ok, if you want both to be able to act as both a client and server you'll want to make sure these services are on and started on the Red Hat box (which they should be by default if installed):
- Code: Select all
# chkconfig portmap on
# chkconfig nfslock on
# chkconfig nfs on
# service portmap start (if not already started)
# service nfslock start (if not already started)
# service nfs start (if not already started)
On the Debian box you want to make sure the following services are started (which also should be by default if installed and your system is in run level 3 or higher):
- Code: Select all
# /etc/init.d/portmap start
# /etc/init.d/nfs-kernel-server start
# /etc/init.d/nfs-common start
For the following examples let's say machine #1 has address 192.168.0.5 and machine #2 has address 192.168.0.10. Now that you have all of the necessary services running the only thing you have to do now is share some directories and mount them. The NFS shares are defined in the /etc/exports file as I mentioned before. Say you wanted to share /home on machine #1, you would put something like this in your /etc/exports:
- Code: Select all
/home 192.168.0.10(rw)
In order to make the above newly added line take effect you must type "exportfs -a" which will export all unexported directories. What this does is allows the machine #2 to mount our "/home" directory and have read/write access. It is important that your user numbers machine between the two systems or joe might show up as owning sally's files.
Ok, go to machine #2 and type:
- Code: Select all
# showmount -e 192.168.0.5
and it should return this:
- Code: Select all
/home 192.168.0.10
It might show your machine's name rather than it's IP address if you have them in your /etc/hots file, or in DNS but you get the idea. Now you need to mount it. First create a directory to mount it on, maybe under /mnt and then mount the remote share. On machine #2 do this:
- Code: Select all
# mkdir /mnt/home
# mount 192.168.0.5:/home /mnt/home
The mount command will automatically know this is an NFS type of file system because of the syntax (server:/sharename). Now you should be able to access machine #1's /home directory on machine #2 under /mnt/home. Mind you the "root" will not have access to the share for security reasons. If you want root to be able to access the share as well then you need to add "no_root_squash" to your share options:
- Code: Select all
/home 192.168.0.10(rw,no_root_squash)
and of course re-export it (exportfs -r).
If you wanted to add it to your /etc/fstab you could add this:
- Code: Select all
192.168.0.5:/home /mnt/home nfs defaults 0 0
Of course since neither machine will be up 100% of the time I suggest that the mounts and umounts be done manually so make sure it doesn't automount the nfs shares:
Red Hat:
- Code: Select all
# chkconfig netfs off
# service netfs stop
In Debian make sure /etc/init.d/mountnfs.sh is not linked in any of your /etc/rc*.d directories.
That's about it. See the man pages:
$
man exports
$
man exportfs
$
man nfs
$
man mount
$
man fstab