Nfs-utils/ja

Network File System (NFS) は、Article description::ホストシステムが提供するネットワークアタッチドファイルシステム (エクスポートとも呼ばれます) にクライアントマシンがアクセスできるようにする、ファイルシステムプロトコルです. NFS は Linux カーネルによってサポートされており、ユーザスペースデーモンとユーティリティは  パッケージにあります.

カーネル
NFS サーバサポートは NFS クライアントには不要です. 逆も同様で、NFS クライアントサポートは NFS サーバには不要です. inotify サポートは NFSv4 でのみ必要です. NFSv3 はレガシークライアントとの互換性のためだけに必要です. 例えば、BusyBox の mount コマンドは NFSv4 に対応していません.

クライアントサポート
クライアントカーネルサポートは、NFS エクスポートを実行するホストに接続する各システムで有効化する必要があります.

サーバサポート
サーバカーネルサポートは、NFS エクスポートを提供するシステムでのみ必要です. ローカル上のテスト目的では、サーバ上でも前節で示したクライアントサポートも同様に有効化しておくと役に立つかもしれません.

Emerge
をインストールしてください:

サーバ
次の表に、サーバがエクスポートしようとしているファイルシステムを示します:

仮想ルート
エクスポートするファイルシステム群を、単一のディレクトリの下からアクセスできるようにすることがあります. このディレクトリは仮想ルートディレクトリとして知られています:

仮想ルートディレクトリ内に、エクスポートしたいファイルシステムのためのディレクトリ (例えば と ) を作成してください:

エクスポートするファイルシステム群を、仮想ルートディレクトリ内の対応するディレクトリからアクセスできるようにする必要があります. これは コマンドの   オプションによって実現できます:

上のマウントを永続的なものにするには、 に以下を追記してください:

エクスポート
The filesystems to be made accessible for clients are specified in. This file consists of the directories to be exported, the clients allowed to access those directories, and a list options for each client. Refer to for more information about the NFS export configuration options.

The following table briefly describes the server options used in the configuration below:

If changes are made to after the NFS server has started, issue the following command to propagate the changes to clients:

IPv4
Configuration grants access to the exported local shares, access is granted to the clients in the IP network. Client access can also be specified as a single host (IP address or fully qualified domain name), NIS netgroup, or with a single  character which grants all clients access.

IPv6
IPv6 only configuration. Allowed IPv6 prefixes are put after the already configured IPv4 networks. The above configuration grants access to the exported directories by IP network, in this case. These IP networks are allowed to access the exported shares on the NFS server:

Dual stack configuration
IPv4 and IPv6 networks which are allowed to access the exported shares on the NFS server, here  and.

OpenRC
OpenRC では、NFS デーモンは OPTS_RPC_NFSD 変数を利用して設定されます:

systemd
systemd では、NFS デーモンは RPCNFSDARGS 変数を利用して設定されます:

The option  is the number of NFS server threads to start. Since only one thread is started by default, the thread count should be increased for optimal performance. The option  disables NFS version 2, while options ,   and   enable NFS versions 3, 4, and 4.1. Refer to for more information about the NFS daemon configuration options. Technical differences between major NFS versions explained in the wikipedia article.

OpenRC
NFS サーバを開始するには:

The above output shows that many other services are also started along with the service. To stop all NFS services, stop the service:

To start the NFS server at boot:

systemd
To start the NFS server:

To start the NFS server at boot:

サービス
OpenRC

To be able to mount exported directories, start the NFS client:

To start the NFS client at boot:

systemd

The service will be started automatically when systemd detects that exported directories are being mounted.

エクスポートをマウントする
Mount the exported directories:

To make the above mounts persistent, add the following to :

The virtual root directory can be mounted instead of each individual exported directory. This will make all exported directories available to the client:

To make the above mount persistent, add the following to :

When using to mount the exported directories, add the  service to the default runlevel:

If the NFS server or client support NFSv3 only, the full path to the exported directory (e.g. or ) needs to be specified when mounting:

The same applies when mounting the virtual root directory:

When mounting exported directories on an IPv6 network, enclose the IPv6 NFS server address in square brackets:

When mounting a link-local IPv6 address, the outgoing local network interface must also be specified:

With NFSv4, the virtual root directory can be rather 'invisible' depending on server configuration; you may need to use relative path:

For persistence:

Kerberos
It is possible to identify NFS client using Kerberos GSS. This will require a few modifications. In the following instruction, it is supposed that Kerberos is already installed on the same server as NFS (which hostname is server.domain.tld) and that the client (client.domain.tld) is able to to it. The Kerberos default realm it DOMAIN_REALM.TLD.

First, enable the following kernel option ( CONFIG_RPCSEC_GSS_KRB5 ) for both server and client. Note that this option may not appear if all cryptographic dependencies are not selected. See kernel option dependencies for more information:

Then, create principals for the NFS service for both the server and the client. On the server, execute:

Each computer must have its password saved in a local keytab. The easiest way to do it is (on the server):

and then transfer the to the client, with the name. Note that the file should be owned by root with  mode.

The service must run at client side. The following line must appear in of the client:

The services and  must run at server side. The following line must appear in of the server:

The service must be correctly configured (on the server):

Add  to the export options.

It is also possible to increase security with  (user authentication and integrity checking) or even   (user authentication, integrity checking and NFS traffic encryption). The more security, the more resources are needed.

The same option must be added to the mount command at client side.

トラブルシューティング

 * The system may become unresponsive during shutdown when the NFS client attempts to unmount exported directories after udev has stopped. To prevent this issue, a local.d script can be used to forcibly unmount the exported directories during shutdown:


 * Verify that the NFS server is running and listening for connections:


 * Verify which NFS daemons are running:


 * List the exported directories from the NFS server:


 * List the current open connections to the NFS server:


 * Verify that the exported directories are mounted by the NFS client:

外部資料

 * NFSv2, v3 and v4.x versions and variations
 * Ubuntu Wiki - NFSv4Howto
 * Funtoo Wiki - NFS
 * Linux NFS - General troubleshooting recommendations
 * Linux NFS - HOWTO Troubleshooting
 * RFC 1094 - Network File System (NFS) version 2 Protocol
 * RFC 1813 - Network File System (NFS) version 3 Protocol
 * RFC 7530 - Network File System (NFS) version 4 Protocol
 * RFC 8881 - Network File System (NFS) version 4.1 Protocol
 * RFC 7862 - Network File System (NFS) version 4.2 Protocol