How to share files between Linux computers using NFS

Table of contents:

How to share files between Linux computers using NFS
How to share files between Linux computers using NFS
Anonim

The Network File System Access Protocol (NFS) is a standard component of most * nix kernels. You will be able to use it on almost all Linux builds.

This is a simple guide. If you want to know more, check out this resource

Steps

These are tasks for sysadmins and must be done as root (su - to go to root or sudo)

Method 1 of 3: Server

Share Files Between Linux Computers Using NFS Step 1
Share Files Between Linux Computers Using NFS Step 1

Step 1. Modify / etc / exports, add a line for each exported directory

  • directory hostname (options) hostname2 (options)

    • directory is the path to the local directory that you wish to export.
    • hostname is the IP address of the client who will not be able to access the directory or * if you are not going to set restrictions.
    • options: see man exports for all available options, eg ro, rw …

Step 2. Get the nfs server to reread / etc / exports

exportfs -ra

Share Files Between Linux Computers Using NFS Step 2
Share Files Between Linux Computers Using NFS Step 2

Method 2 of 3: Client

Share Files Between Linux Computers Using NFS Step 3
Share Files Between Linux Computers Using NFS Step 3

Step 1. Create an installation point

mkdir / mnt / remotefs

Share Files Between Linux Computers Using NFS Step 4
Share Files Between Linux Computers Using NFS Step 4

Step 2. Install NFS export

mount -t nfs: / exportedDir / mnt / remotefs Step 3. Use the remote file system as if it were local, opening directories in this way.

/ mnt / remotefs: ls / mnt / remotefs

Share Files Between Linux Computers Using NFS Step 5
Share Files Between Linux Computers Using NFS Step 5

Method 3 of 3: Example

These are tasks for sysadmins and must be done as root (su - to go to root or sudo)

In this example, we export the temp (/ tmp) directory, read write for all users on your network, the client will install or attach the directory to his system:

On the server 192.168.5.5/24

Share Files Between Linux Computers Using NFS Step 6
Share Files Between Linux Computers Using NFS Step 6

Step 1.edit / etc / exports add the following

  • # export tempo for everyone
  • / tmp 192.168.5. * (rw)

Step 2. Make nfsd read the export information

exportfs -ra

Share Files Between Linux Computers Using NFS Step 2
Share Files Between Linux Computers Using NFS Step 2

On the client's machine 192.168.5.105/24

Share Files Between Linux Computers Using NFS Step 8
Share Files Between Linux Computers Using NFS Step 8

1 mkdir / mnt / sharedTmp

Share Files Between Linux Computers Using NFS Step 9
Share Files Between Linux Computers Using NFS Step 9

Step 2.mount -t nfs 192.168.5.5:/ tmp / mnt / sharedTmp

When finished: on the server, ls / tmp will display the same data as on the client's ls / mnt / sharedTmp

Advice

  • Use the man pages - this is your help: man exports, man mount, man exportfs other
  • These are tasks for sysadmins and must be done as root (su - to go to root or sudo)

Popular by topic