目标板通过nfs挂载根文件系统

目标板挂载根文件系统的方法有两种(这里所说的服务端就是ubuntu,Ubuntu已经成功安装了nfs服务,并且保证服务端与目标板ping 通)

第一种:等待开发板启动之后去挂载,此时文件系统从Flash中启动,然后手动的通过命令去挂载服务端的文件系统

首先修改配置文件/etc/export,在export文件中最后一行加入:[文件系统的目录]  *(rw,sync,no_subtree_check,no_root_squash)

/home/linux/root_fs/first_fs/  *(rw,sync,no_subtree_check,no_root_squash)///home/linux/root_fs/first_fs/ 为文件系统的目录

整个export文件为

# /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,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
/source/rootfs *(rw,sync,no_subtree_check,no_root_squash)
/home/linux/root_fs/first_fs/  *(rw,sync,no_subtree_check,no_root_squash)

export文件

设置好之后,重新启动nfs服务

sudo /etc/init.d/nfs-kernel-server restart

在服务器段自己测试挂载是否成功

sudo mount -t nfs 192.168.1.24:/home/linux/root_fs/first_fs/ /mnt/

在服务端/mnt/目录下查看挂载到的文件,在服务端调通之后,就进行重要环节,

在目标板上通过nfs进行挂载,命令如下:

mount -t nfs -o nolock 192.168.1.24:/home/linux/root_fs/first_fs/ /mnt/

第二种方法:直接从nfs启动,这样服务端所生成的目标文件,目标端可以直接执行,不需要挂载

这种做法就是在u-boot启动之后,设置nfs挂载参数。首先必须掌握nfs命令,

root=/dev/nfs

  This is necessary to enable the pseudo-NFS-device. Note that it‘s not a
  real device but just a synonym to tell the kernel to use NFS instead of
  a real device.

nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]

  If the `nfsroot‘ parameter is NOT given on the command line,
  the default "/tftpboot/%s" will be used.

  <server-ip>    Specifies the IP address of the NFS server.
        The default address is determined by the `ip‘ parameter
        (see below). This parameter allows the use of different
        servers for IP autoconfiguration and NFS.

  <root-dir>    Name of the directory on the server to mount as root.
        If there is a "%s" token in the string, it will be
        replaced by the ASCII-representation of the client‘s
        IP address.

  <nfs-options>    Standard NFS options. All options are separated by commas.
        The following defaults are used:
            port        = as given by server portmap daemon
            rsize        = 4096
            wsize        = 4096
            timeo        = 7
            retrans        = 3
            acregmin    = 3
            acregmax    = 60
            acdirmin    = 30
            acdirmax    = 60
            flags        = hard, nointr, noposix, cto, ac

ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>

  This parameter tells the kernel how to configure IP addresses of devices
  and also how to set up the IP routing table. It was originally called
  `nfsaddrs‘, but now the boot-time IP configuration works independently of
  NFS, so it was renamed to `ip‘ and the old name remained as an alias for
  compatibility reasons.

  If this parameter is missing from the kernel command line, all fields are
  assumed to be empty, and the defaults mentioned below apply. In general
  this means that the kernel tries to configure everything using
  autoconfiguration.

  The <autoconf> parameter can appear alone as the value to the `ip‘
  parameter (without all the ‘:‘ characters before) in which case auto-
  configuration is used.

  <client-ip>    IP address of the client.

          Default:  Determined using autoconfiguration.

  <server-ip>    IP address of the NFS server. If RARP is used to determine
        the client address and this parameter is NOT empty only
        replies from the specified server are accepted.

        Only required for for NFS root. That is autoconfiguration
        will not be triggered if it is missing and NFS root is not
        in operation.

        Default: Determined using autoconfiguration.
                 The address of the autoconfiguration server is used.

  <gw-ip>    IP address of a gateway if the server is on a different subnet.

        Default: Determined using autoconfiguration.

  <netmask>    Netmask for local network interface. If unspecified
        the netmask is derived from the client IP address assuming
        classful addressing.

        Default:  Determined using autoconfiguration.

  <hostname>    Name of the client. May be supplied by autoconfiguration,
          but its absence will not trigger autoconfiguration.

          Default: Client IP address is used in ASCII notation.

  <device>    Name of network device to use.

        Default: If the host only has one device, it is used.
             Otherwise the device is determined using
             autoconfiguration. This is done by sending
             autoconfiguration requests out of all devices,
             and using the device that received the first reply.

  <autoconf>    Method to use for autoconfiguration. In the case of options
                which specify multiple autoconfiguration protocols,
        requests are sent using all protocols, and the first one
        to reply is used.

        Only autoconfiguration protocols that have been compiled
        into the kernel will be used, regardless of the value of
        this option.

                  off or none: don‘t use autoconfiguration (default)
          on or any:   use any protocol available in the kernel
          dhcp:        use DHCP
          bootp:       use BOOTP
          rarp:        use RARP
          both:        use both BOOTP and RARP but not DHCP
                       (old option kept for backwards compatibility)

                Default: any

nfs命令格式

在u-boot界面,输入print就可以显示如下参数

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

然后根据nfs命令格式,具体格式解析要看nfs命令介绍。

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

将启动参数设置为

set bootargs noinitrd root=/dev/nfs nfsroot=192.168.1.24:/home/linux/root_fs/first_fs/ ip=192.168.1.12:192.168.1.24:192.168.1.1:255.255.255.0::eth0:off init=/linuxrc console=ttySAC0

当文件系统启动之后,服务器端的文件会共享过来。

时间: 2024-08-27 10:02:36

目标板通过nfs挂载根文件系统的相关文章

根文件系统制作、NFS配置与安装及利用NFS挂载根文件系统

最近打算从头开始制作根文件系统,下面是开发过程. 一.根文件系统的制作 0.FHS(Filesystem Hierarchy Standard)标准介绍 该标准规定了根目录下各个子目录的名称及其存放的内容: 目录名 存放的内容 /bin 必备的用户命令,例如ls.cp等 /sbin 必备的系统管理员命令,例如ifconfig.reboot等 /dev 设备文件,例如mtdblock0.tty1等 /etc 系统配置文件,包括启动文件,例如inittab等 /lib 必要的链接库,例如C链接库.内

NFS挂载根文件系统

当NFS跟文件系统挂载不上的时候原因很多,但有一个原因不可忽略,那就是目标板内核支持的NFS版本以及默认版本,我吃过亏,特意做个笔记: setenv bootargs console=ttySAC0 root=/dev/nfs rw nfsroot=192.168.1.103:/home/guoguo/root_qtopia,nfsvers=3 rootdelay=10 ip=192.168.1.226:192.168.1.103:192.168.1.1:255.255.255.0:SMDK24

Linux挂载根文件系统

NFS根文件系统挂载 **这里只是记录自己使用NFS挂载根文件系统时出现的错误,并不涉及技术细节** 开发板:Smart210 Bootloader: u-boot-2012-10 Linux: Linux3.10.46 刚开始时在uboot中设置的参数如下: setenv bootargs root=/dev/nfs nfsroot=192.168.10.101:/home/weirdo/Share/rootfs_rtm_210 ip=192.168.10.120:192.168.10.101

Qemu搭建ARM vexpress开发环境(三)----NFS网络根文件系统

Qemu搭建ARM vexpress开发环境(三)----NFS网络根文件系统 标签(空格分隔): Qemu ARM Linux 经过上一篇<Qemu搭建ARM vexpress开发环境(二)----通过u-boot启动Linux内核>,已经实现了通过u-boot加载Kernel启动开发板,并且挂载根文件系统,本文讲述通过NFS网络挂载根文件系统. 通过NFS网络根文件系统,可以实现开发板在通过u-boot启动内核后,通过NFS网络在别的PC主机上挂载根文件系统.对于开发调试阶段的工作学习提供

2017.3.2学习笔记----------nfs以及根文件系统

根文件系统的制作烧写,nfs,驱动程序的编译 <1> 根文件系统的制作烧写: 类似于前一节,步骤可以参考手册,将补丁文件打入虚拟机,再安装即可. 具体步骤参考开发板应用手册3.4节 <2> 使用flash上的根文件系统启动沪,手工MOUNT NFS: mount -t nfs -o nolock,vers=2 192.168.1.132:/work/nfs_root /mnt ls  /mnt <3>使用nfs作为根文件系统来启动 进入uboot: set bootar

hi3516a 与ubuntu18.04 使用nfs 启动根文件系统 过程中遇到的一个问题

以前使用ubuntu14.04启动hi3516的根文件系统时没有问题,但是今天使用ubuntu18.04启动根文件系统时出现了不能启动的问题, 在ubuntu18.04  中使用nfsstat 查看nfs状态,发现只支持nfsvers=4的版本,所以在hi3516的bootargs 中添加proto=tcp,nfsvers=4,之后hi3516正常启动 原文地址:https://www.cnblogs.com/eastgeneral/p/11369767.html

Linux之搭建自己的根文件系统

Hi!大家好,我是CrazyCatJack.又和大家见面了.今天给大家带来的是构建Linux下的根文件系统.希望大家看过之后都能构建出符合自己需求的根文件系统^_^ 1.内容概述 1.构造过程 今天给大家展示的根文件系统构造过程如下图所示: 正如大家看到的,这是一个环环相扣的过程.因为在这四个方面的内容其实相互包含,有很多交集的地方,所以我用环图给大家展示.在第一部分,我会给大家讲解如何在etc/目录下编写相应的配置文件,包含etc/init.d/rcS和etc/fstab等:在第二部分,将会教

根文件系统构建

1:新建nfs目录以存放我们构建的根文件系统,因为通过nfs挂载根文件系统,更加方便调试工作:在/etc/exports文件中添加如下内容/home/zonda/linux/nfs *(rw,sync,no_root_squash) 2:解压busybox,设置架构与编译器 CROSS_COMPILE ?= /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- ...

使用Uboot启动内核并挂载NFS根文件系统

配置编译好内核之后,将生成的内核文件uImage拷贝到/tftpboot/下,通过tftp服务器将内核下载到开发板,使用命令:tftp 31000000 uImage.下载完成之后配置bootargs环境变量:setenv bootargs noinitrd console=ttySAC0,115200 init=/init root=/dev/nfs rw nfsroot=192.168.1.118:/home/rootfs,proto=tcp,nfsvers=3 ip=192.168.1.1