Date: 2017-12-11
Author: SoaringLee
===================================================================================
1、要点:
本地电脑作为NFS服务器,虚拟机中的Ubuntu系统作为NFS客户机。
将本地电脑上目录作为共享目录挂载到虚拟机Ubuntu系统的挂载点上。
通过SSH远程登录虚拟机的方法 参考: 【PE】通过SecureCRT远程登录telnet连接虚拟机的linux系统
2、问题:
mount -t nfs -o tcp 192.168.177.1:e:/work/share /home/nfs
当前挂载时报错:mount.nfs: mounting 192.168.177.1:e:/work/share failed, reason given by server: No such file or directory
推测应该是exports文件设置有问题?
3、解决方案:
exports文件格式:
e:\Work\share -name:test_nfs -public -alldirs
此处没有指定IP,就是说所有IP的客户端都可以访问共享的目录(e:\Work\share),并且此处使用选项-name,给共享的目录指定了别名。
注意:所有对输出表文件的修改必须在服务器重启后才生效!
mount挂载:
mount -t nfs -o nolock,tcp 192.168.177.1:/test_nfs /share
其中192.168.177.1是NFS客户端IP地址,/test_nfs是NFS客户端上的共享目录,/share是NFS服务器上的挂载点 。
umount卸载:
umount /share
4、实战:
Updated at 2019.6.9
重新安装虚拟机后遇到如下问题:
root@ubuntu:~# mount -t nfs -o nolock,tcp 192.168.126.1:/nfs_dir /share
mount: wrong fs type, bad option, bad superblock on 192.168.126.1:/nfs_dir,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount.<type> helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so
经过分析:
(1)安装smbfs(解决cifs及ntfs报错):
$ sudo apt-get intall smbfs
(2)安装nfs-common(解决nfs报错):
$ sudo apt-get install nfs-common
问题解决!