nfs文件系统在linux下挂载不上的解决办法

 

标签: mount nfs export
7472人阅读 评论(0) 收藏 举报
 分类:

问题一:

# mount -t nfs -o 192.168.1.51:/mnt /mnt/
mount: can't find /mnt/ in /etc/fstab

这种情况说明我们的/mnt目录或者要共享的目录没有设置为共享,所有要在/etc/export这个目录里面进行配置,如下:

[root@localhost xmlfile]# vim /etc/exports

/mnt  192.168.1.*(rw,sync,no_root_squash)

注:1、/mnt是一个共享目录,该目录的路径必须是绝对路径;

        2、192.168.1.*说明 只要在192.168.1的这个网段上的所有用户都可以访问共享目录,如果是所有IP都可以访问该目录的话,就改为/mnt *(XXX)即可;

        3、rw:读写访问,sync:所有数据在请求时写入共享,no_root_squash:用户具有根目录的完全管理访问权限。

 

问题二:

# mount -t nfs -o 192.168.1.51:/mnt /mnt/
服务器不可达

这种情况一般是windows或者linux的防火墙没有关闭,所有要关闭防火墙,如:

[root@localhost xmlfile]# service iptables stop
iptables:清除防火墙规则:                                   [确定]
iptables:将链设置为政策 ACCEPT:filter         [确定]
iptables:正在卸载模块:                                       [确定]


[root@localhost xmlfile]# service nfs restart     
关闭 NFS mountd:                                                 [确定]
关闭 NFS 守护进程:                                               [确定]
关闭 NFS quotas:                                                  [确定]
关闭 NFS 服务:                                                       [确定]
启动 NFS 服务: exportfs: Warning: ~/gui does not exist
                                                                                      [确定]
关掉 NFS 配额:                                                       [确定]
启动 NFS 守护进程:                                               [确定]
启动 NFS mountd:                                                 [确定]
[root@localhost xmlfile]#

然后在进行挂载。。。。

 

问题三:

# mount -t nfs -o 192.168.1.51:/mnt /mnt/
连接超时

出现这种情况,是个意外,因为之前都恩能够挂载得上,而且上面的两个问题已经解决,按理来说之前能挂载的上那么现在也应该能挂载得上。可是现在真的出现这个问题了。。。。。。。让我很头疼,不过一番周折之后还是解决了,首先查看是不是在同一个网段上,如果不一样,那么在windows上要再创建一个ip与我的板子在同一个网关上,然后看看我的linux的网关有没有设置好,这些都完成了之后还是不能mount上,所以我就把/etc/resolv.conf这个文件里的域名解析给注释掉,这个时候就能mount山了。。。。。


问题四:

# mount -t nfs -o 192.168.1.51:/mnt /mnt/

mount: 192.168.1.51:/mnt faild, reason given by server: permission denied

这个问题困惑了我一下午,我也查了很多资料,虽然也有很多人遇到跟我类似的情况,但是我用他们的办法没能解决我的问题。打开日志文件查看一下:

[yangzheng @ ~]#cat /var/log/message

mount request from unkknow host 192.168.1.51 for /mnt

然后我把/etc/export里面的配置改为:

/mnt 192.168.1.*(rw,sync,no_root_squash) 改为

/mnt 192.168.1.51/24(rw,sync,no_root_squash)

再进行mount,ok。。。。。。。


问题五:
suse添加nfs服务目录
使用字符界面添加nfs服务,结果挂载不上:
# mount -t nfs -o nolock 192.168.29.10:/mnt /mnt
mount: RPC: Unable to receive; errno = Connection refused
解决办法:
suse 13.2上要开个nfs目录用于nfs服务, 配置了个共享目录:开yast--网络服务--nfs服务器--添加目录  中添加目录,比如的:/home/yangzheng/nfs  192.168.29.10/24(rw,sync,no_root_squash),然后要开启nfs服务,关闭防火墙。
关闭防火墙:(suse的关闭防火墙命令感觉很难用,又难记,每次都要网上搜索)
chkconfig SuSEfirewall2 off
chkconfig SuSEfirewall2_init off

又出现问题:suse的nfs挂载时,提示没权限
# mount -t nfs -o nolock 192.168.29.10:/mnt /mnt
mount: 192.168.29.10:/mnt failed, reason given by server: Permission denied
解决办法参考问题四,检查exports文件的配置,重启nfs服务。

#sudo exportfs -rf



原文地址:https://www.cnblogs.com/mouseleo/p/8620906.html