Difference between revisions of "NFS (简体中文)"

From ArchWiki
Jump to: navigation, search
(http -> https://aur.archlinux.org)
Line 9: Line 9:
 
=必须的软件包=
 
=必须的软件包=
 
服务器端和客户端都需要的软件包(from AUR):
 
服务器端和客户端都需要的软件包(from AUR):
# [http://aur.archlinux.org/packages.php?do_Details=1&ID=13630 librpcsecgss]
+
# [https://aur.archlinux.org/packages.php?do_Details=1&ID=13630 librpcsecgss]
# [http://aur.archlinux.org/packages.php?do_Details=1&ID=13625 nfs4-utils]
+
# [https://aur.archlinux.org/packages.php?do_Details=1&ID=13625 nfs4-utils]
 
下载软件,编译和安装它们。
 
下载软件,编译和安装它们。
 
<br>'''Note: currently pacman doesn't seem to handle replacing when invoked with pacman -U.'''
 
<br>'''Note: currently pacman doesn't seem to handle replacing when invoked with pacman -U.'''

Revision as of 20:14, 24 March 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Tango-preferences-desktop-locale.pngThis article or section needs to be translated.Tango-preferences-desktop-locale.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:NFS (简体中文)#)

目标

这篇文章的目标是让NFSv4 运行在Arch Linux.上
NFSv4 是 NFS 的一个新版本(对旧的NFSv3来说, see Nfs) with new features like strong authentication and integrity via Kerberos and SPKM-3, improved performance, safe file caching, lock migration, UTF-8, ACLs and better support for Windows file sharing semantics.

必须的软件包

服务器端和客户端都需要的软件包(from AUR):

  1. librpcsecgss
  2. nfs4-utils

下载软件,编译和安装它们。
Note: currently pacman doesn't seem to handle replacing when invoked with pacman -U. Therefore, you'll need to remove nfs-utils before installing nfs4-utils (which is a complete drop-in replacement).

配置

服务端

Exports

首先我们需要编辑文件 /etc/exports. 一个典型的 NFSv4 export 应该象这样:

/export    192.168.0.12(rw,fsid=0,no_subtree_check,async,no_root_squash)
/export/music 192.168.0.12(rw,no_subtree_check,async,no_root_squash)

/export is the NFS root here (due to the fsid=0 entry). Everything else that you want to be shared over NFS must be accessible under /export.
For exporting directories outside the NFS root, see below.
Note: the no_root_squash option means that root on the client is also considered root on the server. This is of course a security risk. Remove it if you don't need it.

Exporting directories outside your NFS root

To do this, you'll need to use bind mounts. For example, to bind /home/john to /export/john:

mount --bind /home/john /export/john

Then, /export/john needs to be added to /etc/exports:

/export    192.168.0.12(rw,fsid=0,no_subtree_check,async,no_root_squash)
/export/music 192.168.0.12(rw,no_subtree_check,async,no_root_squash)
/export/john 192.168.12(rw,no_subtree_check,async,no_root_squash,nohide)

The nohide option is required, because the kernel NFS server automatically hides mounted directories. To add the bind mount to /etc/fstab:

/home/john    /export/john    none    bind  0 0

ID mapping

Then, /etc/idmapd.conf needs to be edited. You'll need to at the very least specify your Domain there. Example:

[General]

Verbosity = 1
Pipefs-Directory = /var/lib/nfs/rpc_pipefs
Domain = archlinux.org

[Mapping]

Nobody-User = nobody
Nobody-Group = nobody

Filesystems

Add the following lines to /etc/fstab:

rpc_pipefs /var/lib/nfs/rpc_pipefs rpc_pipefs defaults 0 0
nfsd /proc/fs/nfsd nfsd rw,nodev,noexec,nosuid 0 0

Starting the server

To start the NFS server, just

/etc/rc.d/portmap start
/etc/rc.d/nfs-common start
/etc/rc.d/nfs-server start

If you want to tweak the configuration, feel free to edit /etc/conf.d/nfs-server.conf to your needs.

Clients

ID mapping

/etc/idmapd.conf needs to be edited on all clients and the Domain entry should be identical to the one on the server. Example:

[General]

Verbosity = 1
Pipefs-Directory = /var/lib/nfs/rpc_pipefs
Domain = archlinux.org

[Mapping]

Nobody-User = nobody
Nobody-Group = nobody

[Translation]
Method = nsswitch

Filesystems

Add the following line to /etc/fstab:

rpc_pipefs /var/lib/nfs/rpc_pipefs rpc_pipefs defaults 0 0

Mounting the partitions on the client

On the client, to mount the NFSv4 partition:

/etc/rc.d/portmap start
/etc/rc.d/nfs-common start
mount -t nfs4 server:/ /mnt/server/
mount -t nfs4 server:/music /mnt/music/
mount -t nfs4 server:/john /mnt/john

Replacing 'server' with the hostname or IP address of your NFS server and of course 'server', 'music' and 'john' with the names of whatever directories you exported on the server. Note that the root of the path on the server is the NFS root specified; all paths must be specified relative to it.

If you want the NFS volumes to mount automatically on bootup, add them to fstab.