How to share folder - NFS

Share Linux 2 Linux - NFS

The actors are…

  • Debian 6 (client)
  • Linux Mint 12 (server)

How to start - just open Linux terminal.

1. To see IP:

My result is…

inet addr:192.168.1.1 (for the server - Linux Mint)
inet addr:192.168.1.18 (for the client - Debian)

The command is:

$ /sbin/ifconfig

2. Server PC (Linux Mint)

The share dir is /home/ro/Public

Note: change IP and folder with your IP and your dir (~/Public)


If folder no exist - make it…
$ mkdir ~/Public

In my case… ~/Public = /home/ro/Public

2.1. Install NFS

# apt-get  install nfs-common portmap  nfs-kernel-server

2.2. Edit /etc/exports

# nano /etc/exports

Add this line in /etc/exports

/home/ro/Public 192.168.1.18(rw,sync,no_subtree_check)

2.3. Restart NFS

# /etc/init.d/nfs-kernel-server restart

If not work - see Error messages

3. Client PC (Debian)

Debian (192.168.1.18)

3.1. Install NFS

# apt-get  install nfs-common portmap

3.2. Make a folder

# mkdir -p /mnt/share

Change permission…

# chown -Rv my_user /mnt/share/

Now you user can: mount, read & write - in folder and subfolder.

3.3. First mount

# mount -t nfs 192.168.1.1:/home/ro/Public /mnt/share

Note: use server IP (in my case - 192.168.1.1)

3.4. Edit /etc/fstab

Open the file…

nano /etc/fstab

For auto-mount, add this line:

192.168.1.1:/home/ro/Public   /mnt/share  nfs defaults  0       0

If you want mount manually every time when you need, use that line…
192.168.1.1:/home/ro/Public   /mnt/share  nfs user,rw,noauto  0       0

3.5. Mount / unmount

You can mount as a normal user (no need: su, or sudo):

$ mount  /mnt/share

To unmount…
$ umount  /mnt/share

4. Error messages…

Message 1

exportfs: No host name given with /home/ro/Public (rw,sync,no_subtree_check), suggest *(rw,sync,no_subtree_check) to avoid warning

Solution: Remove spease betin "/home/ro/Public" and "(rw,sync,no_subtree_check)" - in file /etc/exports (in server PC).

Message 2

exportfs: scandir /etc/exports.d: No such file or directory

The "solution" is…

mkdir /etc/exports.d

Comment: Is looking for not existing folder. So, just give it to him (in server PC).

How to stop server?

In server PC

/etc/init.d/nfs-kernel-server stop
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License