NFS服务器安装配置实现Ubuntu 12.04与ARM文件共享,亲测成功。这是NFS基础,大神飘过~~~
具体介绍和解释请参考《鸟哥的Linux私房菜_服务器架设篇 第三版》的NFS相关介绍 下载见 http://www.linuxidc.net/thread-2268-1-1.html
实现步骤:
1.服务器端:sudo apt-get install portmap
2.服务器端:sudo apt-get install nfs-kernel-server
3.客户端:sudo apt-get install nfs-common
4.服务器端配置:sudo gedit /etc/exports
添加:/home/share 192.168.1.*(rw,sync,no_root_squash)
(共享目录) (允许IP)
(rw权限是可擦写,还有ro只读,
sync代表数据会同步写入到内存与硬盘中,async则代表数据会先暂存于内存当中,而非直接写入硬盘,
开放客户端使用root身份来操作服务器的文件系统,那么开no_root_squash才行,root_squash不允许)
5.服务器端启动:sudo /etc/init.d/portmap restart
6.服务器端启动:sudo /etc/init.d/nfs-kernel-server restart
7.arm板连接时:主机:sudo ifconfig eth0 192.168.1.101 netmask 255.255.255.0
arm板:ifconfig eth0 192.168.1.102 netmask 255.255.255.0
8.arm板上mount:mount -t nfs 192.168.1.101:/home/share /mnt/hosts
(主机IP和共享目录) (arm板目录)
mount上之后arm板上文件自动同步
(
1.出现问题:
reason given by server: Permission denied
解决:
服务器端启动一定要sudo启动,不然启动失败,服务拒绝
2.出现问题:
svc: failed to register lockdv1 RPC service (errno 111).
lockd_up: makesock failed, error=-111
mount: mounting 192.168.1.101:/home/share on /mnt/hosts failed: Connection refused
则改成:
mount -t nfs -o nolock 192.168.1.101:/home/share /mnt/hosts
3.出现问题:
mount: mounting 192.168.1.101:/home/share on /mnt/hosts failed: Device or resource busy
解决:
mount上之后在进行mount命令会出现此提示,设备正在运行,不用再次mount
如果想再次mount可以先umount /mnt/hosts
)
首先对于第一次用的话,在Ubuntu下,默认是没有nfs服务的。因此在终端下输入命令:
sudo apt-get install nfs-kernel-server portmap
如果是Ubuntu下,希望能用静态IP继续上网的话,最好还是用图形界面配置好IP地址和网关、DNS服务器等。
否则只是虚拟机或者没所谓要不要链接Internet的话,也可以直接用
ifconfig eth0 192.168.0.10
类似命令来配置(假设使用这个IP)
ip配置成功后,修改 /etc/exprots 文件如下:
其它nfs常用的参数有:
ro
只读访问
rw 读写访问sync 所有数据在请求时写入共享
async
nfs在写入数据前可以响应请求
secure
nfs通过1024以下的安全TCP/IP端口发送
insecure
nfs通过1024以上的端口发送
wdelay
如果多个用户要写入nfs目录,则归组写入(默认)
no_wdelay
如果多个用户要写入nfs目录,则立即写入,当使用async时,无需此设置。
hide 在nfs共享目录中不共享其子目录
no_hide
共享nfs目录的子目录
subtree_check
如果共享/usr/bin之类的子目录时,强制nfs检查父目录的权限(默认)
no_subtree_check
和上面相对,不检查父目录权限
all_squash
共享文件的UID和GID映射匿名用户anonymous,适合公用目录。
no_all_squash
保留共享文件的UID和GID(默认)
root_squash
root用户的所有请求映射成如anonymous用户一样的权限(默认)
no_root_squas
root用户具有根目录的完全管理访问权限
anonuid=xxx
指定nfs服务器/etc/passwd文件中匿名用户的UID
anongid=xxx
指定nfs服务器/etc/passwd文件中匿名用户的GID
重启服务
sudo /etc/init.d/portmap restart
sudo /etc/init.d/nfs-kernel-server restart
此时可以运行以下命令来显示一下共享出来的目录:
showmount -e