Sharing data with NFS

From ArchWiki

Jump to: navigation, search
Image:Tango-document-new.png This article is a stub.
It may be confusing, not contain enough information, or be a placeholder for an article to come. People are invited to expand it to full article status and remove this box.

Contents

[edit] Installing the server

# pacman -S nfs-utils

[edit] Configuring the server

Edit the file /etc/exports, add directories which you want to share and ip addresses or hostnames of machines that will be allowed to mount them:

/mnt/data  192.168.0.3(rw,sync)

You can also share it to a whole subnet:

/mnt/data  192.168.0.0/255.255.255.0(rw,sync)

For a detailed config explanation: man exports

[edit] Allowing connections to the server

You must allow the clients to connect to the server. Add the following services along with the clients' IP addresses into /etc/hosts.allow:

portmap: 192.168.0.3
lockd: 192.168.0.3
rquotad: 192.168.0.3
mountd: 192.168.0.3
statd: 192.168.0.3

Or if you want to enable the access to all of the running services, then simply add this:

ALL: 192.168.0.3

[edit] Starting the server

# /etc/rc.d/portmap start
# /etc/rc.d/nfslock start
# /etc/rc.d/nfsd start

If you plan the server to be started automatically, put it into DAEMONS array in /etc/rc.conf:

DAEMONS=(portmap nfslock nfsd)

[edit] Mounting

On a client side:

  • Install and start the portmap daemon:
# pacman -S portmap
/etc/rc.d/portmap start

(if /etc/rc.d/portmap start results in message FAIL then do /etc/rc.d/portmap stop and then rerun /etc/rc.d/portmap start)

or add it into DAEMONS array in /etc/rc.conf:

DAEMONS=(portmap)
  • Create a mountpoint:
# mkdir /mnt/data
  • Add the entry into /etc/fstab
192.168.0.1:/mnt/data /mnt/data nfs noauto,user 0 0

where 192.168.0.1 is the IP address of the server

  • Mount the directory:
# mount /mnt/data
Personal tools