内核:              linux-3.0

u-boot:          2010.09

开发板:         fl2440(s3c2440主芯片)

交叉编译器:   2011.11

我们在上面移植了initramfs文件系统,并且已经成功运行了。下面我们开始移植nfs,之前开启PC上的nfs服务功能

确认并安装NFS服务依赖软件包

一般NFS服务器要提供服务,必须启动inet,nfs, mount,portmap或rpcbind这些守护进程并保持在后台状态运行. 这里需要提示的是从RHEL6开始, 系统使用rpcbind替换了以前早期版本中NFS依赖的portmap服务。

在使用NFS共享文件之前,我们首先使用rpm命令确认我们安装了这些应用程序。如果没有安装,则从安装光盘中找到他们并安装,或者使用yum安装。下面显示我们在安装系统时,已经选择安装了NFS服务相关软件

1.

[weishusheng@localhost ~]$ rpm -qa | grep nfs
nfs4-acl-tools-0.3.3-6.el6.x86_64
nfs-utils-lib-1.1.5-4.el6.x86_64
nfs-utils-1.2.3-36.el6.x86_64

[weishusheng@localhost ~]$ rpm -qa | grep rpcbind
rpcbind-0.2.0-11.el6.x86_64

2.

修改主机上的NFS配置文件,导出/opt目录使用NFS共享:

[weishusheng@localhost ~]$ sudo vim /etc/exports
/opt/ *(sync,no_root_squash,rw)
/home/lingyun/keyue *(rw,sync,no_root_squash)
/home/lingyun/yangzheng *(rw,sync,no_root_squash)
/home/lingyun/yangxu *(rw,sync,no_root_squash)
/home/lingyun/yanshifu *(rw,sync,no_root_squash)
/home/lingyun/huangyidong *(rw,sync,no_root_squash)
/home/lingyun/liuchengdeng/s3c2440/fs/nfs *(rw,sync,no_root_squash)
/home/zhouguangfeng/ *(rw,sync,no_root_squash)
/home/weishusheng/rootfs_tree/rootfs *(sync,no_root_squash,rw)
/home/zhanbiqiang/rootfs *(rw,sync,no_root_squash)
/home/lingyun/suosuo/rootfs *(rw,sync,no_root_squash)

下面是一些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

关于/etc/exports文件的更加详细的配置说明,我们可以使用man exports命令来查看帮助手册。

3.重新启动rpcbind或portmap和nfs服务

使用root权限运行“service rpcbind restart”(RHEL高于6.0版本)或“service portmap restart”(RHEL5及以下版本)命令重启NFS依赖的服务:

[weishusheng@localhost ~]$ sudo service rpcbind restart
Stopping rpcbind: [ OK ]
Starting rpcbind: [ OK ]

[weishusheng@localhost ~]$ sudo service rpcbind restart
Stopping rpcbind: [ OK ]
Starting rpcbind: [ OK ]
[weishusheng@localhost ~]$ sudo service nfs restart
Shutting down NFS daemon: [ OK ]
Shutting down NFS mountd: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: exportfs: Failed to stat /home/lingyun/yangxu: No such file or directory

exportfs: Failed to stat /home/lingyun/yangzheng: No such file or directory

exportfs: Failed to stat /home/lingyun/keyue: No such file or directory

[ OK ]
Starting NFS quotas: rpc.rquotad: Cannot bind to given address: Address already in use
[ OK ]
Starting NFS mountd: [ OK ]
Stopping RPC idmapd: [ OK ]
Starting RPC idmapd: [ OK ]
Starting NFS daemon: [ OK ]
[weishusheng@localhost ~]$

4.使用service rpcbind status命令和“service nfs status”命令查看相关服务的运行状态,同时可以使用“showmount –e”命令可以查看我们通过NFS服务共享的文件:

[weishusheng@localhost ~]$ service rpcbind status
rpcbind (pid 8879) is running...

[weishusheng@localhost ~]$ service nfs status
rpc.svcgssd is stopped
rpc.mountd (pid 8966) is running...
nfsd (pid 9031 9030 9029 9028 9027 9026 9025 9024) is running...
rpc.rquotad (pid 8962) is running...

5.[weishusheng@localhost ~]$ showmount -e

[weishusheng@localhost ~]$ showmount -e
Export list for localhost.localdomain:
/home/lingyun/suosuo/rootfs *
/home/zhanbiqiang/rootfs *
/home/weishusheng/rootfs_tree/rootfs *
/home/zhouguangfeng *
/usr/local/src/lingyun/liuchengdeng/s3c2440/fs/nfs *
/usr/local/src/lingyun/huangyidong *
/usr/local/src/lingyun/yanshifu *
/home/lingyun/yangxu *
/home/lingyun/yangzheng *
/home/lingyun/keyue *
/opt

6.测试NFS访问

在另外一个Linux机器上,或者在本机上通过mount命令挂载并测试如下:

[weishusheng@localhost ~]$ sudo mkdir -p /mnt/wss
[weishusheng@localhost ~]$ ls /mnt/
ls: cannot access /mnt/nfs4: Stale file handle
ls: cannot access /mnt/ww: Stale file handle
ky-nfs nfs nfs1 nfs2 nfs3 nfs4 nfs_zhou wss ww yz_nfs

[weishusheng@localhost ~]$ sudo mount -t nfs 192.168.1.3:/home/weishusheng/rootfs_tree/rootfs /mnt/wss

[weishusheng@localhost ~]$ mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sdb1 on /usr/local/src type ext4 (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
192.168.1.2:/var/ftp/pub on /opt/pub type nfs (rw,vers=4,addr=192.168.1.2,clientaddr=192.168.1.3)
nfsd on /proc/fs/nfsd type nfsd (rw)
192.168.1.3:/opt on /mnt/nfs type nfs (rw,vers=4,addr=192.168.1.3,clientaddr=192.168.1.3)
192.168.1.3:/opt on /mnt/nfs1 type nfs (rw,vers=4,addr=192.168.1.3,clientaddr=192.168.1.3)
192.168.1.3:/opt on /mnt/nfs3 type nfs (rw,vers=4,addr=192.168.1.3,clientaddr=192.168.1.3)
192.168.1.3:/home/zhanbiqiang/rootfs/ on /mnt/nfs4 type nfs (rw,vers=4,addr=192.168.1.3,clientaddr=192.168.1.3)
192.168.1.3:/home/weishusheng/rootfs_tree/rootfs on /mnt/wss type nfs (rw,vers=4,addr=192.168.1.3,clientaddr=192.168.1.3)

[weishusheng@localhost ~]$ ls /home/weishusheng/rootfs_tree/rootfs
apps data etc init linuxrc proc sbin tmp var
bin dev info lib mnt root sys usr weishusheng

[weishusheng@localhost ~]$ ls /mnt/wss
apps data etc init linuxrc proc sbin tmp var
bin dev info lib mnt root sys usr weishusheng

7.添加内核对nfs的支持

[weishusheng@localhost linux-3.0-nfs]$ pwd
/home/weishusheng/kernel/linux-3.0-nfs
[weishusheng@localhost linux-3.0-nfs]$ vt100
[weishusheng@localhost linux-3.0-nfs]$ sudo make menuconfig

General setup  --->

[ ] Initial RAM filesystem and RAM disk (initramfs/initrd) support

[*] Networking support  --->

Networking options  --->

[*]   IP: kernel level autoconfiguration

[ ]     IP: DHCP support

[ ]     IP: BOOTP support

[ ]     IP: RARP support

File systems  --->

[*] Network File Systems  --->

[*]   Root file system on NFS

[weishusheng@localhost linux-3.0-nfs]$ make

[weishusheng@localhost linux-3.0-ubifs-dm9000]$ du -h linuxrom-mini2440-wei.bin
2.5M linuxrom-mini2440-wei.bin

8.添加uboot对nfs支持

[fl2440@weishusheng]#set bootcmd_rootfs 'nand read 30008000 100000 400000;bootm 30008000'

[fl2440@weishusheng]#set bootcmd 'run bootcmd_rootfs'

[fl2440@weishusheng]#set bootargs_nfs 'noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/home/weishusheng/rootfs_tree/rootfs ip=192.168.1.23:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off'

[fl2440@weishusheng]#set bootargs 'noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/home/weishusheng/rootfs_tree/rootfs ip=192.168.1.23:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off'

(bootargs_nfs没起作用,真正起作用的是bootargs,bootargs_nfs只是一个备忘的作用,因为我们接下来会做jffs2,yaffs2,ubifs等文件系统,而每个文件系统的bootargs与bootcmd不一样,当我们需要换文件系统时便用到bootargs_nfs了)

上面的设置中ip=<my-ip>:<serv-ip>这两个是必须在bootargs中出现,不然可能无法启动。

my-ip就是开发板上你自己设的ip

serv-ip就是服务器ip

[fl2440@weishusheng]#set bkr 'tftp 30008000 linuxrom-mini2440-wei.bin;nand erase 100000 800000;nand write 30008000 100000 800000'

(大家如抱着学习的态度尽量不要复制粘贴,因为每个人的ip,下载地址不会一样,当然你可以设置和我的一样,自己敲收获会更大,还要注意不要有中文标点)

[fl2440@weishusheng]#save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... done

9.下载启动

[fl2440@weishusheng]# run bkr

dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.23
Filename 'linuxrom-mini2440-wei.bin'.
Load address: 0x30008000
Loading: #################################################################
#################################################################
#############################################
done
Bytes transferred = 2563280 (271cd0 hex)

NAND erase: device 0 offset 0x100000, size 0x800000
Erasing at 0x8e0000 -- 100% complete.
OK

NAND write: device 0 offset 0x100000, size 0x800000
8388608 bytes written: OK

[fl2440@weishusheng]#boot

......

Copyright (C) 2014 weishusheng
root login: root
Password:
>: ls
apps dev init mnt sbin usr
bin etc lib proc sys var
data info linuxrc root tmp weishusheng
>:

我们已经启动内核,下面测试nfs文件系统是否正常,在服务器上新建一个目录nfs-done

[weishusheng@localhost rootfs]$ pwd
/home/weishusheng/rootfs_tree/rootfs
[weishusheng@localhost rootfs]$ ls
apps data etc init linuxrc proc sbin tmp var
bin dev info lib mnt root sys usr weishusheng
[weishusheng@localhost rootfs]$ mkdir nfs-done
[weishusheng@localhost rootfs]$ ls
apps data etc init linuxrc nfs-done root sys usr weishusheng
bin dev info lib mnt proc sbin tmp var

在开发板上输入

>: ls
apps etc linuxrc root usr
bin info mnt sbin var
data init nfs-done sys weishusheng
dev lib proc tmp
>:

看到nfs-donne,说明nfs文件系统制作成功。

(当启动不成功时,看看是否添加了Dm9000网卡的驱动,如果没有添加,就需要自己添加,可以网上找一个可用的,再和自己的内核做个patch包,然后对着patch包改,把patch包里所有的MD9000网卡相关的都加进去,当学到驱动时就会明白为什么这么加了。如果网上找不到,可以发邮件到<642613208@qq.com>,我给你发,当你在启动信息里看到:dm9000 dm9000.0: eth0: link up, 100Mbps, full-duplex, lpa 0x41E1

Copyright (C) 2014 weishusheng
root login:

之类的信息时才行)

NFS文件系统制作的更多相关文章

  1. jffs2文件系统制作

    内核:                linux-3.0 uboot:             2010.09 开发板:             fl2440 交叉编译器:         2011. ...

  2. linux根文件系统制作

    在嵌入式中移植的内核下载到开发板上,是没有办法真正的启动Linux操作系统的,会出现无法加载文件系统的错误. 那么根文件系统在系统启动中到底是什么时候挂载的呢?先将/dev/ram0挂载,而后执行/l ...

  3. 内核移植和文件系统制作(4):UBIFS根文件系统制作总结

    UBIFS文件系统简介: 无排序区块图像文件系统(UnsortedBlock Image File System, UBIFS)是用于固态硬盘存储设备上,并与LogFS相互竞争,作为JFFS2的后继文 ...

  4. 嵌入式 hi3518平台uboot引导nfs文件系统

    首先贴出来我的bootargs的设置(注没有换行符!!!): setenv bootargs noinitrd mem=64M root=/dev/nfs init=/linuxrc rw nfsro ...

  5. qemu 模拟-arm-mini2440开发板-启动u-boot,kernel和nfs文件系统

    qemu 本文介绍了如何编译u-boot.linux kernel,然后用qemu启动u-boot和linux kernel,达到与开发板上一样的学习效果! 虽然已经买了2440开发板,但是在实际学习 ...

  6. hi3531 SDK已编译文件系统制作jffs2文件系统镜像并解决问题 .

    一, 安装SDK 1.Hi3531 SDK包位置 在"Hi3531_V100R001***/01.software/board"目录下,您可以看到一个 Hi3531_SDK_Vx. ...

  7. Exynos4412从SD卡启动的简单网络文件系统制作

    Exynos4412从SD卡启动的简单网络文件系统制作 1. 简介 嵌入式系统能够在开发板上正常运行,需要先进行系统配置,一个完整的嵌入式系统应该包含的几个部分::uboot,kernel,rootf ...

  8. qemu 模拟-arm-mini2440开发板-启动u-boot,kernel和nfs文件系统【转】

    转自:http://www.cnblogs.com/riskyer/p/3366001.html qemu 本文介绍了如何编译u-boot.linux kernel,然后用qemu启动u-boot和l ...

  9. S5PV210的根文件系统制作

    一.移植BusyBox1.下载BusyBox的源代码下载地址:http://www.busybox.net/downloads/,此处下载busybox-1.20.2.tar.bz2.2.解压并进入目 ...

随机推荐

  1. C# 里的if/switch

    今天又重新翻了翻C# Step by Step if 语句 if(bool 表达式) { 语句块: } else { 语句块: } switch(day) { case 0: dayName=&quo ...

  2. Python开发入门与实战22-简单消息回复

    22. 简单消息回复 本章节我们来实现一个微信库存查询功能,使用我们前面的BIZ业务逻辑层示例如何利用微信入口来实现文本消息类的库存查询服务. 22.1. 在responseMsg函数里增加处理微信文 ...

  3. Nginx + uwsgi

    1. 安装uwsgi依赖yum groupinstall "Development Tools"yum install pythonyum install python-devel ...

  4. 移动混合开发之android文件管理demo

    框架采用cordova,android编译环境为android studio.系统为mac,cordova 环境搭建参考网址:http://cordova.apache.org/docs/en/5.0 ...

  5. mount: /dev/sdb1 already mounted or /mnt/hdb busy 导致NameNode无法启动

    最近,公司由于断电导致的服务器关机,等到来电了,重启集群发现Namenode无法启动,查看原因是由于无法加在faimage文件,在查看一下Namenode的磁盘挂在情况(df -h命令查看),发现磁盘 ...

  6. Objective-C学习笔记-第四天(1)

    解决以下昨天遇到的问题 1.@class与import是怎么样的呢?参考:http://www.cnblogs.com/ios8/p/ios-oc-test.html 在头文件中, 一般只需要知道被引 ...

  7. hard

    硬盘电路板将信号转化为电压高低,电压控制电脉冲被送到磁头,产生一个电磁.磁盘和磁头很紧密.读写都是不断扫描磁盘的过程.有操作系统负责控制文件的组织,可能在不同的块中.

  8. 如何在tomcat中如何部署java EE项目

    如何在tomcat中如何部署java EE项目 1.直接把项目复制到Tomcat安装目录的webapps目录中,这是最简单的一种Tomcat项目部署的方法,也是初学者最常用的方法.2.在tomcat安 ...

  9. SQL联合查询(内联、左联、右联、全联)的语法

    联合查询效率较高,举例子来说明联合查询:内联inner join .左联left outer join .右联right outer join .全联full outer join 的好处及用法. 联 ...

  10. Android Studio 常用快捷键

     继承Eclipse的快捷键 : File->Settings->Keymap->有一个Keymaps 下拉菜单,选择Eclipse.    这里讲主要常用的快捷键 :  Ctrl ...