mount nfs4 ....No such file or directory

本文记录了解决NFS挂载时遇到的'No such file or directory'错误的过程。问题源于NFS版本升级到v4,解决方案是在exports中添加fsid参数,并重新exportfs。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天用nfs的时候遇到奇怪的问题:

先是:
bee@Thinkpad-x201:/mnt$ sudo mount 192.168.1.177:/share/mnt/test/
mount.nfs: access denied by server while mounting192.168.1.177:/share

发现是nfs版本的问题,我是通过apt-get install安装的nfs,估计是更新到了nfs v4版本,所以需要加上特殊的参数-t nfs4

但加上-t nfs4参数后server没有拒绝,但是却又有一个错误:
bee@Thinkpad-x201:/mnt$ 
sudo mount -t nfs4192.168.1.177:/share /mnt/test/
mount.nfs4: 192.168.1.177:/share failed, reason given by server: Nosuch file or directory

这就奇怪了,明明有文件有目录,怎么会视而不见呢?

原来针对NFS4,exports需要一个新的参数fsid,
如我的exports:
/home/bee 
*(rw,fsid=0,sync,no_root_squash)

查看exports的帮助:
bee@Thinkpad-x201:~$man exports


fsid=num|root|uuid
 
            NFS needs to  be able  to identify  each filesystem  that  it
 
            exports.  Normally it will use a UUID for thefilesystem (if the
 
            filesystem has such a thing) or the device number ofthe  device
 
            holding  the filesystem  (if the  filesystem  is stored onthe
 
            device).

 
            As not all filesystems  are stored  on devices,  and not  all
 
            filesystems  have UUIDs, it is sometimes necessaryto explicitly
 
            tell NFS how to identify a filesystem.  Thisis  done  with the
 
            fsid= option.

 
            For NFSv4, there is a distinguished filesystem which is theroot
 
            of all exported filesystem.  This is specifiedwith fsid=root or
 
            fsid=0 both of which mean exactly the same thing.

 
            Other  filesystems  can beidentified with a small integer, or a
 
            UUID which should contain 32 hex digits and arbitrary  punctua‐
 
            tion.

 
            Linux  kernels  version 2.6.20and earlier do not understand the
 
            UUID setting so a small integer must be used ifan  fsid  option
 
            needs  to  be set for suchkernels.  Setting both a small number
 
            and a UUID is supported so the same configuration can be madeto
 
            work on old and new kernels alike.


在exports增加fsid这个key word后,
bee@Thinkpad-x201:~$exportfs -r
bee@Thinkpad-x201:/mnt$ 
sudo mount -t nfs4192.168.1.177:/share /mnt/test/
bee@Thinkpad-x201:/mnt$

OK了......
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值