内核:              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. iOS---初识Swift(一)

    一.Swift简介 ○ 2010年的夏天, 苹果公司的开发人员Chris Latten接到了一个特别的任务, 为OS X 和iOS平台开发下一代编程语言, 也就是Swift. ○ 苹果公司于2014年 ...

  2. MySQL5.6下使用xtrabackup部分备份恢复到MySQL5.7

    现有需求:需要备份MySQL5.6环境下的部分表到MySQL5.7环境下并进行恢复 通过xtrabackup 实现部分备份有三种方式: 参考链接:http://blog.csdn.net/zhu197 ...

  3. ubuntu下code::blocks+opengl的使用与配置

    操作系统:Ubuntu 15.04 gcc version 4.9.2 opengl安装 sudo apt-get install build-essential libgl1-mesa-dev li ...

  4. Linq 备忘录

    public class CTest { public int i { get; set; } public string j { get; set; } } 一.Range var items=En ...

  5. FastFDS配置安装

    先说环境: win7旗舰版,配CRT连接虚拟机,虚拟机用的vmware Player,安装的CentOS6.4版本. 1.添加用户 useradd fastdfs 这步可以不做,后面的操作用root账 ...

  6. 用javascript简单封装AJAX

    1.创建一个AJAX引擎对象 var CreateAjax = function () { var xhr = null; if (window.XMLHttpRequest) { //非IE游览器 ...

  7. 【LeetCode】Roman to Integer & Integer to Roman

    Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within t ...

  8. 无法将文件" "复制到“bin\*.*”。对路径“bin\*.*”的访问被拒绝。 解决方法

    如果没有特别什么代码的错误,而是更新了某个自动获取的Webserive 那么什么都不用管,直接VS关闭,从新打开就好了.

  9. MySQL数据库在linux的安装,编程与操作

    一.安装 ubuntu上安装MySQL非常简单只需要几条命令就可以完成. 1. sudo apt-get install mysql-server   2. apt-get isntall mysql ...

  10. Logback日志系统配置攻略

    logback是log4j作者推出的新日志系统,原生支持slf4j通用日志api,允许平滑切换日志系统,并且对简化应用部署中日志处理的工作做了有益的封装. 官方地址为:http://logback.q ...