为arm-linux开发板挂载基于nfs的根文件系统

linux4.14内核,首先设置kernel的bootargs,在make menuconfig中有三种方式来配置:

第一种方式为如果uboot中设置了bootargs环境变量,就采用uboot的bootargs;

第二种展示不清楚

第三种在内核中直接配置启动参数,例如根文件系统位置,等等。

因为方便多次修改bootargs,选用第一种方式,减少重复烧写。

设置uboot的bootargs:

setenv bootargs 'root=/dev/nfs rw nfsroot=192.168.0.12:/home/rzx/system ip=192.168.0.11:192.168.0.12:192.168.0.1:255.255.255.0:rzx:eth0:off rootfstype=ext4 console=ttySAC2,115200 init=/linuxrc'

nfsroot=192.168.0.12:/home/rzx/system  ip是server的,后面接根文件系统路径,要注意的是在配置好server端的nfs服务后(网上教程很多),/etc/exports中要写上根文件系统路径,例如  /home/rzx/system *(rw,sync,no_root_squash)  否则启动内核后会卡住。

ip=192.168.0.11:192.168.0.12:192.168.0.1:255.255.255.0:rzx:eth0:off  第一个是开发板的IP,第二个service的IP,第三个网关,第四个子网掩码

原文地址:https://www.cnblogs.com/-rzx-/p/11715105.html