CMDLINE_VALUE = "mem=64M console=ttyS0,115200 init=/init root=/dev/nfs rw nfsroot=192.168.111.238:/opt/nfs,v3,proto=tcp,nolock,rsize=4096,wsize=4096,intr ip=192.168.111.239:::255.255.254.0"
Error
nfs: server 192.168.111.238 not responding, still trying
Fixed
因为NFS默认采用UDP进行传输中途容易丢包,所以修改成TCP进行传输问题解决
proto=tcp
This is a problem with NFS and 2.6 kernels, fast server NICs and
comparatively slower client NICs. This will show up when the server has
a 1000Mb card and the client a 100Mb, or when the server has a 100Mb
card and the client a 10Mb.
rsize=4096,wsize=4096
通过设定大的同时传输的数据块大小(bytes),以提高NFS读写的速度。改变这些值时要当心,一些旧的linux内核和网卡在大的块大小不能正常工作
nfsroot.c
Linux Kernel 2.6 nfsroot支持的参数:
nfsroot=xxx
static match_table_t __initdata tokens = {
{Opt_port, "port=%u"},
{Opt_rsize, "rsize=%u"},
{Opt_wsize, "wsize=%u"},
{Opt_timeo, "timeo=%u"},
{Opt_retrans, "retrans=%u"},
{Opt_acregmin, "acregmin=%u"},
{Opt_acregmax, "acregmax=%u"},
{Opt_acdirmin, "acdirmin=%u"},
{Opt_acdirmax, "acdirmax=%u"},
{Opt_soft, "soft"},
{Opt_hard, "hard"},
{Opt_intr, "intr"},
{Opt_nointr, "nointr"},
{Opt_posix, "posix"},
{Opt_noposix, "noposix"},
{Opt_cto, "cto"},
{Opt_nocto, "nocto"},
{Opt_ac, "ac"},
{Opt_noac, "noac"},
{Opt_lock, "lock"},
{Opt_nolock, "nolock"},
{Opt_v2, "nfsvers=2"},
{Opt_v2, "v2"},
{Opt_v3, "nfsvers=3"},
{Opt_v3, "v3"},
{Opt_udp, "proto=udp"},
{Opt_udp, "udp"},
{Opt_tcp, "proto=tcp"},
{Opt_tcp, "tcp"},
{Opt_acl, "acl"},
{Opt_noacl, "noacl"},
{Opt_err, NULL}
};
服务依赖
错误如下:
user:~ # sudo mount -t nfs -o rw 10.9.87.65:/filedir /filedir
mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
mount.nfs: Operation not permitted
nfs mount 默认选项包括文件锁,依赖于 portmap 提供的动态端口分配功能或者是没有启动 rpcbind 服务
mount -o nolock
# sudo mount -t nfs -o rw,nolock 10.9.87.65:/filedir /filedir
- 启动 server
$ sudo service nfslock restart $ sudo service rpcbind restart $ sudo service nfs restart
查看状态
查看支持版本
$ sudo cat /proc/fs/nfsd/versions
-2 +3 +4 +4.1 +4.2
修改 /etc/default/nfs-kernel-server
,在文件末尾加入一句:RPCNFSDOPTS="--nfs-version 2,3,4 --debug --syslog"
以支持 v2
查看 nfs 状态
$ nfsstat -s
$ nfsstat -c
挂载测试
$ mount -t nfs -o vers=4 192.168.1.10:/mnt/data /data
$ mount -t nfs -o vers=3 192.168.1.10:/mnt/data /data
查看 mount 状态
$ showmount -e 192.168.110.55
$ mount