您的位置:首页 > 其它

busybox nfs 学习笔记

2016-05-21 20:20 267 查看
 cp xxx.ko /work/nfs_root/first_fs 将linux服务器文件拷贝到单板 

 

 open() printf fwrite 等由stdin stdout 等C库支持,

 

 ls cp 由根文件系统 busybox 支持 

 

 安装busybox时不可直接make install 那样会安装到pc而破坏pc系统 

 

 init 进程和 busybox 都是应用程序,init程序本身就是 busybox

 

 mkdir -p /work/nfs_root/first_fs

 make CONFIG_PREFIX=/work/nfs_root/first_fs install

 sudo chmod +x /usr/local/bin/mkyaffs2image 添加可执行属性

 /usr/local/bin 下执行:mkyaffs2image first_fs first.yaffs2 第一个文件系统的映像文件

 输入y用dnw烧写到开发板

 输入b启动

 添加自动挂载proc 修改rcS步骤:

  1./work/nfs_root/first_fs 目录下 vi etc/inittab 添加 ::sysinit:/etc/init.d/rcS 脚本

  2.创建/etc/init.d/rcS 脚本文件 mkdir etc/init.d ;vi etc/init.d/rcS 添加 mount -t proc none /proc 

                                                                       或mount -a(依赖于etc/fstab)

                                                                       vi etc/fstab

                                                                       

  3./work/nfs_root/first_fs 目录下 chmod +x etc/init.d/rcS 添加可执行属性

 

 根据 mdev readme 用法 设置 mdev 可以自动创建设备节点

 
 NFS使用

        :1.给开发板命令 ifconfig 通过 ifconfig eth0 up/down 控制开发板网卡开关

  2.接网线 配置ip ifconfig 192.168.1.140 ping linux服务器 192.168.1.120

  3.挂接 %1.从FLASH上启动根文件系统,再用命令挂接NFS 

        要求:

     1.允许那个目录可被别人挂接(NFS服务 配置文件/etc/exports中定义那个目录即可)

     2.单板去挂接

    想要/work/nfs_root/first_fs能被别人挂接:

        在服务器/work/nfs_root/first_fs目录下 sudo vi /etc/exports

        添加/work/nfs_root *(rw,sync,no_root_squash)
          /work/nfs_root/first_fs *(rw,sync,no_root_squash)
      重启NFS服务 sudo /etc/init.d/nfs-kernel-server restart
      实验 sudo mount -t nfs 192.168.1.120:/work/nfs_root/first_fs /mnt 在服务器上实验能不能自己挂载自己

        

        单板挂载 mkdir /mnt 

                 mount -t nfs -o nolock 192.168.1.120:/work/nfs_root/first_fs /mnt

                 ls /mnt 在单板上看到的/mnt目录下东西与服务器上/mnt目录下一样

                 echo hello > test.txt 

          %2.直接从NFS启动 重启开发板 123时空格 print 打印信息 看命令行参数

          修改bootargs=noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0

          为  bootargs=noinitrd root=/dev/nfs
 init=/linuxrc console=ttySAC0

          设置NFS参数 

                     服务器IP,挂载目录

                     开发板自己IP 

                     

                     格式:

                     在网上搜索root=/dev/nfs 参数

                     在内核中搜索nfsroot=  cd /work/system/linux-2.6.22.6/

                     
 grep "nfsroot=" *-nR 在Documentation/nfsroot.txt中有格式如下

                     nfsroot=[<server-ip>:]:<root-dir>
          [,<nfs-options>]   ip=<client-ip>:<server-ip>  :<gw-ip>    :<netmask>    :<hostname>:<device>:<autoconf>          
           

                     nfsroot=192.168.1.120 :/work/nfs_root/first_fs []表此参数可以省略 ip=192.168.1.140 :192.168.1.120:192.168.1.1:255.255.255.0::eth0:off init=linuxrc console=ttySAC0

             

             命令:

             set bootargs noinitrd root=/dev/nfs nfsroot=192.168.1.120:/work/nfs_root/first_fs ip=192.168.1.140:192.168.1.120:192.168.1.1:255.255.255.0::eth0:off init=linuxrc console=ttySAC0

             save

             挂载成功 但ip冲突,不能同时连接虚拟机,由于PC设置成了140 

             PC
 192.168.1.100

             虚拟机 192.168.1.120

             开发板 192.168.1.140

             挂载成功!

             

             cat /proc/devices 查看驱动

             insmod first_drv.ko 测试程序 firstdrvtest 中打开/dev/xxx 

             rmmod first_drv 卸载驱动 

             

             %1 mknod /dev/xxx c 252 0 手动分配 major 主设备号 

             

             %2 或利用busybox的mdev功能 根据系统信息创建设备节点,通过 firstdrv_class 和 firstdrv_class_dev 这两个函数
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: