zoukankan      html  css  js  c++  java
  • NFS服务开启

    一、开启NFS服务 

    使用如下命令安装 NFS 服务:

    sudo apt-get install nfs-kernel-server rpcbind

    等待安装完成,安装完成以后在用户根目录下创建一个名为“nfs”的文件夹,创建的 nfs 文件夹供 nfs 服务器使用,以后我们可以在开发板上通过网络文件系
    统来访问 nfs 文件夹,要先配置 nfs,使用如下命令打开 nfs 配置文件/etc/exports:

    sudo vi /etc/exports

    打开/etc/exports 以后在后面添加如下所示内容:

    /home/topeet/nfs *(rw,sync,no_root_squash)

    添加完成以后的/etc/exports 如图所示:

    重启 NFS 服务,使用命令如下:

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

    二、挂载NFS目录

    如果虚拟机IP地址是192.168.0.2,则开发板可以通过下面命令挂载目标系统:

    mount -t nfs 192.168.0.2:/home/topeet/nfs /mnt -o nolock

    如果挂载失败,可能是nfs版本不统一,需要用以下命令挂载:

    mount -t nfs -o nolock,nfsvers=3,vers=3 192.168.0.2:/home/topeet/nfs /mnt

    三、NFS根文件系统

    Linux内核支持从网络加载根文件系统。使用NFS根文件系统,首先需要内核中网卡驱动已经正常工作,并且在内核已经支持网络并配置了NFS根文件系统支持,同时将内核参数设置为通过NFS启动。

    设置内核NFS启动的参数一般格式为:

    root = /dev/nfs rw console=$(consolecfg) nfsroot=$(serverip):$(rootpath) ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname):$(device):$(autoconf) 

    参数的意义如下:

    root=/dev/nfs: 使用网络文件系统

    consolecfg: 调试串口配置

    serverip: NFS服务器IP

    rootpath: 主机NFS根文件系统路径

    ipaddr: 本机IP(目标系统IP)

    gateway: 网关

    netmask: 子网掩码

    hostname: 目标板的主机名

    device: 网卡设备,默认一个网卡就填eth0

    autoconf: 自动连接,填off不自动连接

    如“使用调试串口屏ttyS0,NFS服务器IP为192.168.0.2,NFS根文件系统路径为/home/topeet/nfs,目标板IP为192.168.0.3”的启动参数配置为:

    root=/dev/nfs rw console=ttyS0,115200 nfsroot=192.168.0.2:/home/topeet/nfs ip=192.168.0.3:192.168.0.2:192.168.0.1:255.255.255.0::eth0:off

    把文件系统rootfs.tar.bz2复制Linux主机上的/home/topeet/nfs目录,然后解压该包: $ tar -xjvf rootfs.tar.bz2 解压完成后,将得到/home/topeet/nfs/rootfs目录,这个目录将用作NFS根文件系统的目录。

    在uboot里设置的方法是:

    => setenv root "/dev/nfs rw console=ttyS0,115200 nfsroot=192.168.0.2:/home/topeet/nfs ip=192.168.0.3:192.168.0.2:192.168.0.1:255.255.255.0::eth0:off"

    => setenv ipaddr "192.168.0.3"

    => setenv serverip "192.168.0.2"

    => saveenv

  • 相关阅读:
    BZOJ 3744 Gty的妹子序列
    BZOJ 3872 Ant colony
    BZOJ 1087 互不侵犯
    BZOJ 1070 修车
    BZOJ 2654 tree
    BZOJ 3243 向量内积
    1003 NOIP 模拟赛Day2 城市建设
    CF865D Buy Low Sell High
    CF444A DZY Loves Physics
    Luogu 4310 绝世好题
  • 原文地址:https://www.cnblogs.com/-tbd-/p/12598686.html
Copyright © 2011-2022 走看看