1.安装nfs
sudo apt-get install nfs-kernel-server #安装nfs-kernel-server时,apt会自动安装nfs-common和portmap
2、配置nfs
sudo vi /etc/exports
例如
/opt 192.168.1.108(rw,sync,no_root_squash) /* ubuntu12.04下测试IP地址必须写全 */
/opt - 要挂载的目录。
192.168.1.108 - NFS客户端的IP地址。
rw - 读/写权限,只读权限的参数为ro。
sync - 数据同步写入内存和硬盘,也可以使用async,此时数据会先暂存于内存中,而不立即写入硬盘。
no_root_squash - NFS服务器共享目录用户的属性,如果用户是root,那么对于这个共享目录来说就具有root的权限。
修改完成之后输入以下命令使配置文件生效:
exportfs –r
3、重启nfs服务
sudo /etc/init.d/nfs-kernel-server restart
4、nfs服务器端测试
由于nfs服务器端默认是安装了nfs客户端(nfs-common)的,所以可以在服务器端挂载共享文件夹作测试。
sudo mount 192.168.1.108:/opt/mnt #192.168.1.108是nfs服务器端IP地址
如果看到/mnt文件下包含/opt文件夹里的内容,就说明挂载成功。
要卸载nfs的挂载用命令:
sudo umount /mnt
5、nfs挂载根文件系统常见问题
(1)挂载服务器目录到开发板出现:rpcbind: server localhost not responding, timed out
svc: failed to register lockdv1 RPC service (errno 5).
lockd_up: makesock failed, error=-5
rpcbind: server localhost not responding, timed out
rpcbind: server localhost not responding, timed out
rpcbind: server localhost not responding, timed out
解决办法:加上“-o nolock”参数
[root@FriendlyARM /]# mount -t nfs -o nolock 192.168.1.108:/nfsroot/rootfs /mnt
[root@FriendlyARM /]#
sudo apt-get install nfs-kernel-server #安装nfs-kernel-server时,apt会自动安装nfs-common和portmap
2、配置nfs
sudo vi /etc/exports
例如
/opt 192.168.1.108(rw,sync,no_root_squash) /* ubuntu12.04下测试IP地址必须写全 */
/opt - 要挂载的目录。
192.168.1.108 - NFS客户端的IP地址。
rw - 读/写权限,只读权限的参数为ro。
sync - 数据同步写入内存和硬盘,也可以使用async,此时数据会先暂存于内存中,而不立即写入硬盘。
no_root_squash - NFS服务器共享目录用户的属性,如果用户是root,那么对于这个共享目录来说就具有root的权限。
修改完成之后输入以下命令使配置文件生效:
exportfs –r
3、重启nfs服务
sudo /etc/init.d/nfs-kernel-server restart
4、nfs服务器端测试
由于nfs服务器端默认是安装了nfs客户端(nfs-common)的,所以可以在服务器端挂载共享文件夹作测试。
sudo mount 192.168.1.108:/opt/mnt #192.168.1.108是nfs服务器端IP地址
如果看到/mnt文件下包含/opt文件夹里的内容,就说明挂载成功。
要卸载nfs的挂载用命令:
sudo umount /mnt
5、nfs挂载根文件系统常见问题
(1)挂载服务器目录到开发板出现:rpcbind: server localhost not responding, timed out
例如:
[root@FriendlyARM /]# mount -t nfs 192.168.1.108:/nfsroot/rootfs /mnt
rpcbind: server localhost not responding, timed outsvc: failed to register lockdv1 RPC service (errno 5).
lockd_up: makesock failed, error=-5
rpcbind: server localhost not responding, timed out
rpcbind: server localhost not responding, timed out
rpcbind: server localhost not responding, timed out
解决办法:加上“-o nolock”参数
[root@FriendlyARM /]# mount -t nfs -o nolock 192.168.1.108:/nfsroot/rootfs /mnt
[root@FriendlyARM /]#