Logicalwebhost Cheatsheet

Linux & Open Source Cheatsheets & Howto's

Skip to: Content | Sidebar | Footer

nfs howto

Nfs allows you to remotely mount a directory so it acts like it’s local, and also make it mount the same place every time you boot up. It’s really handy, pretty simple and quite proven in the field.

nfs howto

first set up the server

apt-get install nfs-kernel-server portmap
vi /etc/exports
  /folder/you/want/your/remote/box/to/see 192.168.1.0/24(rw,root_squash,subtree_check))
  add blank line after last one
chown nobody:nogroup /folder/you/want/your/remote/box/to/see
echo "portmap: 192.168.2." >> /etc/hosts.allow
/etc/init.d/nfs-kernel-server restart
exportfs -ra
exportfs

if everything worked, you should see an entry like

/folder/you/want/your/remote/box/to/see    192.168.1.0/24

now mount the folder on your client like:

su
apt-get install nfs-common 
mount -t nfs 192.168.1.5:/folder/you/want/your/remote/box/to/see /place/where/you/want/it/mounted/locally
mount

if things went well, you should see an entry like:

192.168.1.5:/ on /place/where/you/mounted/it/locally type nfs (rw,addr=192.168.1.5)

if you want to make it mount automatically every time you boot the client, add a line to /etc/fstab like:

vi /etc/fstab
  192.168.5.115:/folder/you/mounted/on/the/server /place/where/you/want/it/locally   nfs     _netdev,auto  0  0
mount /place/where/you/want/it/locally
mount
  you should see something that starts with
  192.168.1.5:/folder/blah on /local/blah type nfs4 (rw,...

the _netdev waits until your network comes up before mounting it, the “auto” waits until your system boots up before mounting.

Write a comment

You need to login to post comments!