mini6410基于linux2.6.36内核通过NFS启动根文件系统总结(一搭建开发环境——建立NFS服务器)

http://blog.csdn.net/yinjiabin/article/details/7489030

建立 nfs 服务器  

        在嵌入式 linux 开发的时候,常常需要使用 nfs 以方便程序的调试。使用 nfs,用户可以
将板子要用到的根文件系统放在主机目录下,开发板则通过以太网挂载到这个目录并将这个
目录下的文件作为根文件系统的内容,这样用户的程序更新后不比重新烧写板子的根文件系
统便能被重新使用,这点能够大大加快程序的调试。 
Ubuntu 下安装 nfs 服务器的步骤如下: 
step1: 进行 NFS 服务器端与客户端的安装: 
sudo apt-get install nfs-kernel-server   nfs-common   portmap 
安装客户端的作用是可以在本机进行 NFS 服务的测试。 
step2:  配置 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
打开 

step3: 配置挂载目录和权限

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) 

/opt/FriendlyARM/mini6410/linux/rootfs *(rw,sync) 
解释一下: 
#后面的都是解释 
/opt/FriendlyARM/mini6410/linux/rootfs 是 NFS 的共享目录,*表示任何 IP 都可以共享这个目录,你可以改为受限的 IP,rw
表示的是权限,sync 是默认的。 
step4:  更新 exports 文件 
只要你更改了/etc/exports,  你不可以通过 sudo exportfs -r  来更新  这个文件 
step5: 重启 NFS 服务 
Sudo /etc/init.d/portmap start
sudo /etc/init.d/nfs-kernel-server restart  重启 nfs 服务 
step6: 本机进行测试 
尝试一下挂载本地磁盘(我的 linux 系统 IP 为 192.168.1.104,将/opt/FriendlyARM/mini6410/linux/rootfs 挂载到/mnt)   
$ sudo mount 192.168.1.104:/opt/FriendlyARM/mini6410/linux/rootfs/mnt   
运行  $ df  看看结果   

$ sudo umount /mnt

step7: 在开发板上测试(将主机的/home/rootfs挂载到开发板的/mnt目录)

mount -t nfs -o nolock 192.168.1.104:/opt/FriendlyARM/mini6410/linux/rootfs /mnt

posted @ 2013-08-12 22:11  今晚打酱油_  阅读(183)  评论(0编辑  收藏  举报