I want to merge information found here and there in order to record in one answer all steps to set my NFS network between my two Ubuntu PCs
This is useful time to time, for example when switching to a new Ubuntu version, I need to reset :
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityLets say that «boris» is my logon such as /home/boris
is my home folder.
install nfs-kernel-server and nfs-common
$ sudo apt-get install nfs-kernel-server
$ sudo apt-get install nfs-common
in /etc/exports
, define the folder to be shared by adding this:
/home/boris 192.168.1.0/24(rw,sync,all_squash,anonuid=1001,anongid=1001,subtree_check)
with:
/home/boris
is the folder to be shared
rw
for read and write access of the client
sync
??
all_squash
??
192.168.1.0/24
is a range of client computer IP address of your local network
1001
is the user and group ID. To find it $ id boris
manage hosts, 1st allow nobody in /etc/hosts.deny
add
portmap:ALL
nfsd:ALL
mountd:ALL
Then allow your client computer in /etc/hosts.allow
add
portmap:192.168.1.0/24
lockd:192.168.1.0/24
nfsd:192.168.1.0/24
mountd:192.168.1.0/24
rquotad:192.168.1.0/24
statd:192.168.1.0/24
with 192.168.1.0/24
is a range of client computer IP address of your local network
set the firewall UFW
$ sudo ufw enable
$ sudo ufw default deny incoming
$ sudo ufw default deny outgoing
$ sudo ufw allow from 192.168.1.0/24
$ sudo ufw allow out from 192.168.1.0/24
with 192.168.1.0/24
is a range of client computer IP address of your local network
start the server
$ sudo /etc/init.d/nfs-kernel-server start
or after a modification of /etc/exports
$ sudo /etc/init.d/nfs-kernel-server restart
install nfs-common and autofs
$ sudo apt-get install nfs-common
$ sudo apt-get install autofs
create the folder used to mount the connection with the server
$ sudo mkdir /media/shareFolder
set autofs to automatically mount this folder,
in /etc/auto.master
add this line:
/media/shareFolder /etc/auto.nfs --ghost, --timeout=60
in /etc/auto.nfs
add this line
boris -fstype=nfs,rw,intr,uid=1001,guid=1001 192.168.1.1:/home/boris
with:
192.168.1.1
is the address of server computer
/home/boris
is the folder shared on server computer.
1001
is the user and group ID. To find it $ id boris
rw
for read and write access
set the firewall UFW
$ sudo ufw enable
$ sudo ufw default deny incoming
$ sudo ufw default deny outgoing
$ sudo ufw allow to 192.168.1.1
$ sudo ufw allow out to 192.168.1.1
with 192.168.1.1
is the address of the server computer
and reboot your client computer.