Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to mount a folder from a Linux machine on another Linux machine. How do I do that? Do I need to update /etc/fstab or /etc/export?

My target is to mount /tmp from the other Linux machine. I have Debian 5.1., that is the IP of the other machine.

For example I tried:

mount -t nfs /tmp
mount: failed, reason given by server: Permission denied
share|improve this question

migrated from Jun 22 '11 at 14:39

This question came from our site for system and network administrators.

Why was this migrated from SF? – Ignacio Vazquez-Abrams Jun 22 '11 at 14:42
@Ignacio Well - the OP most probably is no sysadmin. David, I assumed you have Debian. Correct me if I'm wrong. Anyway, there is no Linux 5.1. – slhck Jun 22 '11 at 14:44
@slhck, @Darth: If you insist. – Ignacio Vazquez-Abrams Jun 22 '11 at 14:48
@David: Please post /etc/exports and the output of netstat -plant and iptables -L from the server. – Ignacio Vazquez-Abrams Jun 22 '11 at 14:48
@David: have you started an NFS server on the server machine? Is iptables running on the server? – Peltier Jun 22 '11 at 14:50

What you are doing is NFS share. On a Debian system you should install the tools necessary. Lets assume that the client (the machine on which you want to mount the remote folde) and server (the machine where remote folder is)

On server you'll need to install

apt-get install nfs-server portmap nfs-common

in new debian versions

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

On the client you'll need to install:

apt-get install nfs-client nfs-common

My package selection could have more or less what you need but, some combinations will do.

Now what you need to do is put the folders you want to share with remote machine in /etc/exports:



exportfs -ra
/etc/init.d/nfs-kernel-server restart
/etc/init.d/portmap restart

Here is the address of your local machine, replace that with your own IP. exports file has the list of machines that can access the shared folder. If your machines don't have firewall restrictions to each other (you can solve this by adding host to /etc/hosts.allow).

Now on your local machine you can use the command:

sudo mount -o soft,intr,rsize=8192,wsize=8192 server_ip:/path_to_tmp_folder/tmp /local_path_to_empty_tmp_folder/tmp

If you want to have automatic mount on boot you need to edit your /etc/fstab file and put the line on your client:

server_ip:/path_to_tmp/tmp /local_empty_folder/tmp nfs rsize=16384,wsize=16384,rw,auto,nolock

This is just an example of settings (copy pased from my own), you need to check nfs help to see what suites you best.

share|improve this answer
any reason why r/wsize is different for the mount approach as opposed to the fstab approach? – puk Sep 26 '13 at 18:23
instead of nfs-server in new versions of debian the nfs-kernel-server should be used. This information is in debian dependency tree. So update of the answer is recommended. – Dee Aug 2 '14 at 10:21
Can you allow a subnet in the exports file? – nonsensickle Aug 13 '14 at 22:33

In order to mount the folder /tmp from another machine, it has to be exposed by a service that allows that. Your question indicates that you intend to use NFS for this.

In this case, you will need to edit /etc/exports and provide a line in it similar to

/tmp 10.45.40/24(ro,insecure,sync,no_subtree_check)

Read the man page for exports for exact details of all the options. Once the options are what you need, restart the NFS service with

exportfs -ra

Then mount the exported folder from your client.

share|improve this answer

You must log in to answer this question.