ubuntu下为tiny6410搭建nfs服务器的方法

来源:岁月联盟 编辑:exp 时间:2012-04-09

建立 nfs 服务器    在嵌入式 linux 开发的时候,常常需要使用 nfs 以方便程序的调试。使用 nfs,用户可以将板子要用到的根文件系统放在主机目录下,开发板则通过以太网挂载到这个目录并将这个目录下的文件作为根文件系统的内容,这样用户的程序更新后不比重新烧写板子的根文件系统便能被重新使用,这点能够大大加快程序的调试。   www.2cto.com  
Ubuntu 下安装 nfs 服务器的步骤如下: 1 进行 NFS 服务器端与客户端的安装: sudo apt-get install nfs-kernel-server   nfs-common   portmap 安装客户端的作用是可以在本机进行 NFS 服务的测试。 2 配置 portmap 两种方法任选一种就可以: (1):sudo emacs /etc/default/portmap 去掉  -i 127.0.0.1   (2)sudo dpkg-reconfigure portmap   运行后选择“否” 另外很重要的一点,要用 sysv-rc-conf  (而不是 chkconfig)工具查看一下当前 nfs 和 portmap的状态,若是 off,则用 sudo sysv-rc-conf portmap on  或 sudo sysv-rc-conf nfs-kernel-server on打开 4.3.3 配置挂载目录和权限vim /etc/exports 
我的配置如下: # /etc/exports: the access control list for filesystems which may be exported #  to NFS clients.   See exports(5). # # Example for NFSv2 and NFSv3: # /srv/homes        hostname1(rw,sync) hostname2(ro,sync) # # Example for NFSv4: # /srv/nfs4         gss/krb5i(rw,sync,fsid=0,crossmnt) # /srv/nfs4/homes   gss/krb5i(rw,sync) #   www.2cto.com  /home/rootfs *(rw,sync) 解释一下: #后面的都是解释 /home/rootfs 是 NFS 的共享目录,*表示任何 IP 都可以共享这个目录,你可以改为受限的 IP,rw表示的是权限,sync 是默认的。 4.3.4 更新 exports 文件 只要你更改了/etc/exports,  你不可以通过 sudo exportfs -r  来更新  这个文件 4.3.5 重启 NFS 服务 Sudo /etc/init.d/portmap startsudo /etc/init.d/nfs-kernel-server restart  重启 nfs 服务 6 本机进行测试 尝试一下挂载本地磁盘(我的 linux 系统 IP 为 192.168.1.104,将/home/rootfs 挂载到/mnt)   $ sudo mount 192.168.1.104:/home/rootfs /mnt   运行  $ df  看看结果   $ sudo umount /mnt 7 在开发板上测试(将主机的/home/rootfs挂载到开发板的/mnt目录) mount -t nfs -o nolock 192.168.1.104:/home/rootfs /mnt   作者 yinjiabin