Hi3519v101通过NFS挂载到服务器启动

1、服务器安装nfs服务软件

sudo apt-get install nfs-kernel-server

2、创建共享目录,并更改文件夹权限

mkdir /home/osrc/Hi3519V101_SDK_V1.0.4.0/osdrv/opensource/busybox/busybox-1.20.2/rootbox
chmod 777 /home/osrc/Hi3519V101_SDK_V1.0.4.0/osdrv/opensource/busybox/busybox-1.20.2/rootbox

3、修改nfs配置文件/etc/exports

/home/osrc/Hi3519V101_SDK_V1.0.4.0/osdrv/opensource/busybox/busybox-1.20.2/rootbox *(rw,sync,no_subtree_check,no_root_squash,insecure,nohide)

* 为主机IP,网上是不能用*来通配,否则在客户机上会出现访问拒绝,但我是测试是可以的

参数说明:

ro:共享目录只读;

rw:共享目录可读可写;
all_squash:所有访问用户都映射为匿名用户或用户组;
no_all_squash(默认):访问用户先与本机用户匹配,匹配失败后再映射为匿名用户或用户组;

root_squash(默认):将来访的root用户映射为匿名用户或用户组;

no_root_squash:来访的root用户保持root帐号权限;

anonuid=<UID>:指定匿名访问用户的本地用户UID,默认为nfsnobody(65534);
anongid=<GID>:指定匿名访问用户的本地用户组GID,默认为nfsnobody(65534);

secure(默认):限制客户端只能从小于1024的tcp/ip端口连接服务器;

insecure:允许客户端从大于1024的tcp/ip端口连接服务器;
sync:将数据同步写入内存缓冲区与磁盘中,效率低,但可以保证数据的一致性;
async:将数据先保存在内存缓冲区中,必要时才写入磁盘;
wdelay(默认):检查是否有相关的写操作,如果有则将这些写操作一起执行,这样可以提高效率;

no_wdelay:若有写操作则立即执行,应与sync配合使用;
subtree_check(默认) :若输出目录是一个子目录,则nfs服务器将检查其父目录的权限;

no_subtree_check :即使输出目录是一个子目录,nfs服务器也不检查其父目录的权限,这样可以提高效率;

4、主机启动nfs服务,重启exports(Ubuntu要加上这一条语句才行,Debian则不需要)

sudo /etc/init.d/nfs-kernel-server start
sudo exportfs -rv

5、客户机(单板)链接主机

mount -t nfs -o nolock 10.117.197.24:/home/osrc /mnt

10.117.197.24 主机IP

/home/osrc 要访问的目录

/mnt 客户机要挂在的地方

6、单板通过NFS挂载到服务器启动

通过上面的步骤,单板可以顺利挂载到服务器,下一步进行单板一启动就挂载到服务器,为实现此步骤当时也搞了好久!!!

内核配置增加如下选项

Networking support–>Networking options 
–>[*]IP: DHCP support 
–>[*]IP:BOOTP support 
–>[*]IP:RARP support


File systems  --->     
[*] Network File Systems  ---> 
<*>   NFS client support                                                      
   <*>     NFS client support for NFS version 2                                
   <*>     NFS client support for NFS version 3                                
   [*]       NFS client support for the NFSv3 ACL protocol extension           
   <>      NFS client support for NFS version 4     /* 这个不要选,测试发现单板内核无法启动 */                            
   []     Provide swap over NFS support                                                                    
   [*]   Root file system on NFS             /* 必须选上 */

内核配置、编译下载可参考《Hi3519v101烧写uboot、uImage、rootfs文件到emmc》,不多赘述。

单板bootargs设置

可参考/Hi3519V101_SDK_V1.0.4.0/osdrv/opensource/kernel/linux-3.18.y/Documentation/filesystems/nfs/nfsroot.txt bootargs参数说明。

set bootargs 'noinitrd mem=96M root=/dev/nfs init=/linuxrc rw nfsroot=10.117.197.24:/home/osrc/Hi3519V101_SDK_V1.0.4.0/osdrv/opensource/busybox/busybox-1.20.2/rootbox,proto=tcp,nfsvers=3,nolock ip=10.117.197.11:10.117.197.24:10.117.197.1:255.255.255.0::eth0:off console=ttyAMA0,115200'

其中,如下两个参数是一定要特别添加的,不知道是不是我的服务器debian 9存在兼容性问题,网上是这么说的。

proto=tcp 为使用tcp作为mount协议

nfsvers=3 为nfs version 3

不加这两个参数,会出现VFS: Unable to mount root fs on unknown-block问题,当时这里卡了好久。

如下为正常挂载启动打印

Registering SWP/SWPB emulation handler
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
mmc0: BKOPS_EN bit is not set
himci: tuning mmc0: valid phase shift [7, 2] Final Phase 12
himci: HS400 tuning mmc0: valid phase shift [1, 15] Final Phase 8
mmc0: new HS400 MMC card at address 0001
mmcblk0: mmc0:0001 8GME4R 7.28 GiB
mmcblk0boot0: mmc0:0001 8GME4R partition 1 4.00 MiB
mmcblk0boot1: mmc0:0001 8GME4R partition 2 4.00 MiB
 mmcblk0: unknown partition table
hi_gmac_v200 10050000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off
IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
IP-Config: Complete:
     device=eth0, hwaddr=8a:47:7a:92:c0:a5, ipaddr=10.117.197.11, mask=255.255.255.0, gw=.197.1
     host=10.117.197.11, domain=, nis-domain=(none)
     bootserver=10.117.197.24, rootserver=10.117.197.24, rootpath=
VFS: Mounted root (nfs filesystem) on device 0:11.
devtmpfs: mounted
Freeing unused kernel memory: 228K (c0569000 - c05a2000)
random: linuxrc urandom read with 5 bits of entropy available
/etc/init.d/rcS: line 5: can't create /proc/sys/kernel/hotplug: nonexistent directory

Please press Enter to activate this console.
/ #

7、这里说下uboot无法通过nfs启动Ubuntu 18.04.5 LTS内的根文件问题

需要修改/etc/default/nfs-kernel-server如下:

sudo vim /etc/default/nfs-kernel-server

# Number of servers to start up
#RPCNFSDCOUNT=8
RPCNFSDCOUNT="-V 2 8"

# Runtime priority of server (see nice(1))
RPCNFSDPRIORITY=0

# Options for rpc.mountd.
# If you have a port-based firewall, you might want to set up
# a fixed port here using the --port option. For more information,
# see rpc.mountd(8) or http://wiki.debian.org/SecuringNFS
# To disable NFSv4 on the server, specify '--no-nfs-version 4' here
#RPCMOUNTDOPTS="--manage-gids"
RPCMOUNTDOPTS="-V 2 --manage-gids"

# Do you want to start the svcgssd daemon? It is only required for Kerberos
# exports. Valid alternatives are "yes" and "no"; the default is "no".
NEED_SVCGSSD=""

# Options for rpc.svcgssd.
RPCSVCGSSDOPTS="--nfs-version 2,3,4 --debug --syslog"

重启nfs
 

sudo service nfs-kernel-server restart

补充:

要是根文件系统没有/linuxrc文件,则bootargs的init=linuxrc更改为init=/sbin/init或者查看根文件系统能够其他的这些文件/sbin/init、/etc/init、/bin/init、/bin/sh。

要不然会出现下面错误

Kernel panic - not syncing: Requested init /linuxrc failed (error -2).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值