Difference between revisions of "Set up an NFS server"

From Linuxintro
imported>ThorstenStaerk
 
(26 intermediate revisions by 2 users not shown)
Line 1: Line 1:
You want to share folders of your computer in the network. So, your computer plays the role of the [[NFS]] [[server]]. The network drives are ''exported'' by the server, that's how NFS calls it. The following is an example how you get a folder ''/public'' that is shared in your network. It uses [[SUSE]] Linux 10, but the process for other distributions should be similar. It will last about 10 minutes. We use ''server'' as [[hostname]] for the computer exporting directories.
+
{{factbox|time=10 min|distro=SUSE Linux 13.2|type=HowTo}}
  
To do this,
+
You want to share folders of your computer in the network. So, your computer plays the role of the [[NFS]] server. The network drives are ''exported'' by the server, that's how NFS calls it. The following is an example how you get a folder ''/public'' that is shared in your network. To do this, [[find out your distribution]] and proceed accordingly. We use ''server'' as hostname for the computer exporting directories.
* Have NFS installed as described at [[installing software]]
+
 
* Create the [[directory]] ''/public'' (the name ''/public'' will be used here as an example)
+
= SUSE Linux 13.2 =
  [[mkdir]] ''/public''
+
* Have NFS installed as described at [[installing software]], in the case of SUSE Linux:
 +
yast -i nfs-kernel-server
 +
* Create the directory ''/public'' (the name ''/public'' will be used here as an example)
 +
mkdir ''/public''
 +
* Edit /etc/exports, add the line
 +
''/public/''  *(rw,no_root_squash,sync)
 +
* Start the NFS-Server:
 +
rcrpcbind start
 +
/etc/init.d/nfsserver start
 +
 
 +
== make it start on reboot ==
 +
To make the nfsserver start on reboot type
 +
systemctl enable rpcbind
 +
systemctl enable nfsserver
 +
 
 +
= SUSE Linux 12.3 =
 +
* Have NFS installed as described at [[installing software]], in the case of SUSE Linux:
 +
yast -i nfs-kernel-server
 +
* Create the directory ''/public'' (the name ''/public'' will be used here as an example)
 +
mkdir ''/public''
 +
* Edit /etc/exports, add the line
 +
''/public/''  *(rw,no_root_squash,sync)
 +
* Start the NFS-Server:
 +
rcrpcbind start
 +
/etc/init.d/nfsserver start
 +
* find an error message:
 +
redirecting to systemctl  start nfsserver
 +
Failed to issue method call: Unit nfsserver.service failed to load: No such file or directory. See system logs and 'systemctl status nfsserver.service' for details.
 +
* reboot server
 +
* Start the NFS-Server:
 +
rcrpcbind start
 +
/etc/init.d/nfsserver start
 +
...and it works :)
 +
 
 +
= SUSE Linux 12.2 =
 +
* Have NFS installed as described at [[installing software]], in the case of SUSE Linux:
 +
yast -i nfs-kernel-server
 +
* Create the directory ''/public'' (the name ''/public'' will be used here as an example)
 +
mkdir ''/public''
 +
* Edit /etc/exports, add the line
 +
''/public/''  *(rw,no_root_squash,sync)
 +
* Start the NFS-Server:
 +
/etc/init.d/rpcbind start
 +
/etc/init.d/nfsserver start
 +
* If you want your NFS service to start after every reboot, say
 +
chkconfig rpcbind on
 +
chkconfig nfsserver on
 +
 
 +
== Verify the result ==
 +
Issue on your computer:
 +
showmount -e 127.0.0.1
 +
The result will be like this:
 +
Export list for 127.0.0.1:
 +
/public *
 +
By this command, you can see that a share /public is available on your computer, so it is an NFS-Server.
 +
 
 +
== Use the network drive ==
 +
To use the network drive on a client computer, go there and try if you can reach the NFS server:
 +
[[ping]] ''server''
 +
Mount the server's export to (as an example) ''/mnt/nfs''
 +
mkdir -p /mnt/nfs
 +
mount ''server'':/public ''/mnt/nfs''
 +
You can make this mount persistant by using the [[fstab]].
 +
 
 +
= SUSE Linux 12.1 =
 +
* Have NFS installed as described at [[installing software]], in the case of SUSE Linux:
 +
yast -i nfs-kernel-server
 +
* Create the directory ''/public'' (the name ''/public'' will be used here as an example)
 +
mkdir ''/public''
 +
* Edit /etc/exports, add the line
 +
''/public/''  *(rw,no_root_squash,sync)
 +
* Start the NFS-Server:
 +
/etc/init.d/rpcbind start
 +
/etc/init.d/nfsserver start
 +
* If you want your NFS service to start after every reboot, say
 +
chkconfig nfsserver on
 +
 
 +
== Verify the result ==
 +
Issue on your computer:
 +
showmount -e 127.0.0.1. The result will be like this:
 +
Export list for 127.0.0.1:
 +
/public *
 +
By this command, you can see that a share /public is available on your computer, so it is an NFS-Server.
 +
 
 +
== Use the network drive ==
 +
To use the network drive on a client computer, go there and try if you can reach the NFS server:
 +
  [[ping]] ''server''
 +
Mount the server's export to (as an example) ''/mnt/nfs''
 +
mkdir -p /mnt/nfs
 +
mount ''server'':/public ''/mnt/nfs''
 +
You can make this mount persistant by using the [[fstab]].
 +
 
 +
= SUSE Linux 10 =
 +
* Have NFS installed as described at [[installing software]], in the case of SUSE Linux:
 +
yast -i nfs-kernel-server
 +
* Create the directory ''/public'' (the name ''/public'' will be used here as an example)
 +
mkdir ''/public''
 
* Edit /etc/exports, add the line
 
* Edit /etc/exports, add the line
 
  ''/public/''  *(rw,no_root_squash,sync)
 
  ''/public/''  *(rw,no_root_squash,sync)
 
* Start the NFS-Server:  
 
* Start the NFS-Server:  
 
  /etc/init.d/nfs-user-server start || /etc/init.d/nfsserver start
 
  /etc/init.d/nfs-user-server start || /etc/init.d/nfsserver start
This [[command]] [[make]]s sure your nfs server gets started, no matter if your [[distribution]] names its startup [[script]] "nfs-user-server" or "nfsserver".
+
This [[command]] [[make]]s sure your nfs server gets started, no matter if your distribution names its startup script "nfs-user-server" or "nfsserver".
 +
* If you want your NFS service to start after every reboot, say
 +
chkconfig nfsserver on || chkconfig nfs-user-server on
 +
This [[command]] [[make]]s sure your nfs server gets started on reboot, no matter if your distribution names its startup script "nfs-user-server" or "nfsserver".
  
 
== Verify the result ==
 
== Verify the result ==
Line 19: Line 118:
  
 
== Use the network drive ==
 
== Use the network drive ==
To use the network drive on a [[client]] computer, go there and try if you can reach the NFS server:
+
To use the network drive on a client computer, go there and try if you can reach the NFS server:
 
  [[ping]] ''server''
 
  [[ping]] ''server''
[[Mount]] the server's export to (as an example) ''/mnt/nfs''
+
Mount the server's export to (as an example) ''/mnt/nfs''
  [[mkdir]] -p /mnt/nfs
+
  mkdir -p /mnt/nfs
  [[mount]] ''server'':/public ''/mnt/nfs''
+
  mount ''server'':/public ''/mnt/nfs''
 
You can make this mount persistant by using the [[fstab]].
 
You can make this mount persistant by using the [[fstab]].
 +
 +
= TroubleShooting =
 +
In case of troubles, watch the syslog (/var/log/messages) on your NFS server. In one case, the server's IP was in /etc/exports instead of the client's IP.
  
 
= See also =
 
= See also =
 
* [[nfs]]
 
* [[nfs]]
 +
* [[smb]]
 +
* [[PXE]]
 +
* http://lists.opensuse.org/opensuse/2011-12/msg01054.html
 +
* http://www.unix.com/302873603-post8.html

Latest revision as of 12:54, 26 June 2015


Tutorial Factbox

Time to replay 10 min
Example Distro SUSE Linux 13.2
Type HowTo

You want to share folders of your computer in the network. So, your computer plays the role of the NFS server. The network drives are exported by the server, that's how NFS calls it. The following is an example how you get a folder /public that is shared in your network. To do this, find out your distribution and proceed accordingly. We use server as hostname for the computer exporting directories.

SUSE Linux 13.2

yast -i nfs-kernel-server
  • Create the directory /public (the name /public will be used here as an example)
mkdir /public
  • Edit /etc/exports, add the line
/public/   *(rw,no_root_squash,sync)
  • Start the NFS-Server:
rcrpcbind start
/etc/init.d/nfsserver start

make it start on reboot

To make the nfsserver start on reboot type

systemctl enable rpcbind
systemctl enable nfsserver

SUSE Linux 12.3

yast -i nfs-kernel-server
  • Create the directory /public (the name /public will be used here as an example)
mkdir /public
  • Edit /etc/exports, add the line
/public/   *(rw,no_root_squash,sync)
  • Start the NFS-Server:
rcrpcbind start
/etc/init.d/nfsserver start
  • find an error message:
redirecting to systemctl  start nfsserver
Failed to issue method call: Unit nfsserver.service failed to load: No such file or directory. See system logs and 'systemctl status nfsserver.service' for details.
  • reboot server
  • Start the NFS-Server:
rcrpcbind start
/etc/init.d/nfsserver start

...and it works :)

SUSE Linux 12.2

yast -i nfs-kernel-server
  • Create the directory /public (the name /public will be used here as an example)
mkdir /public
  • Edit /etc/exports, add the line
/public/   *(rw,no_root_squash,sync)
  • Start the NFS-Server:
/etc/init.d/rpcbind start
/etc/init.d/nfsserver start
  • If you want your NFS service to start after every reboot, say
chkconfig rpcbind on
chkconfig nfsserver on

Verify the result

Issue on your computer:

showmount -e 127.0.0.1

The result will be like this:

Export list for 127.0.0.1:
/public *

By this command, you can see that a share /public is available on your computer, so it is an NFS-Server.

Use the network drive

To use the network drive on a client computer, go there and try if you can reach the NFS server:

ping server

Mount the server's export to (as an example) /mnt/nfs

mkdir -p /mnt/nfs
mount server:/public /mnt/nfs

You can make this mount persistant by using the fstab.

SUSE Linux 12.1

yast -i nfs-kernel-server
  • Create the directory /public (the name /public will be used here as an example)
mkdir /public
  • Edit /etc/exports, add the line
/public/   *(rw,no_root_squash,sync)
  • Start the NFS-Server:
/etc/init.d/rpcbind start
/etc/init.d/nfsserver start
  • If you want your NFS service to start after every reboot, say
chkconfig nfsserver on

Verify the result

Issue on your computer: showmount -e 127.0.0.1. The result will be like this:

Export list for 127.0.0.1:
/public *

By this command, you can see that a share /public is available on your computer, so it is an NFS-Server.

Use the network drive

To use the network drive on a client computer, go there and try if you can reach the NFS server:

ping server

Mount the server's export to (as an example) /mnt/nfs

mkdir -p /mnt/nfs
mount server:/public /mnt/nfs

You can make this mount persistant by using the fstab.

SUSE Linux 10

yast -i nfs-kernel-server
  • Create the directory /public (the name /public will be used here as an example)
mkdir /public
  • Edit /etc/exports, add the line
/public/   *(rw,no_root_squash,sync)
  • Start the NFS-Server:
/etc/init.d/nfs-user-server start || /etc/init.d/nfsserver start

This command makes sure your nfs server gets started, no matter if your distribution names its startup script "nfs-user-server" or "nfsserver".

  • If you want your NFS service to start after every reboot, say
chkconfig nfsserver on || chkconfig nfs-user-server on

This command makes sure your nfs server gets started on reboot, no matter if your distribution names its startup script "nfs-user-server" or "nfsserver".

Verify the result

Issue on your computer: showmount -e 127.0.0.1. The result will be like this:

Export list for 127.0.0.1:
/public *

By this command, you can see that a share /public is available on your computer, so it is an NFS-Server.

Use the network drive

To use the network drive on a client computer, go there and try if you can reach the NFS server:

ping server

Mount the server's export to (as an example) /mnt/nfs

mkdir -p /mnt/nfs
mount server:/public /mnt/nfs

You can make this mount persistant by using the fstab.

TroubleShooting

In case of troubles, watch the syslog (/var/log/messages) on your NFS server. In one case, the server's IP was in /etc/exports instead of the client's IP.

See also