1、安装tftp服务
apt-get install tftpd-hpa
vi /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/home/hisilicon/3519A/tftp"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="-l -c -s"
chmod 777 /home/hisilicon/3519A/tftp
service tftpd-hpa restart
将前面编译好的内核镜像拷备至tftp根目录
2、安装nfs服务
apt install nfs-kernel-server
vi /etc/exports
# 发布根文件系统所在目录
/home/hisilicon/3519A/nfs *(rw,sync,no_root_squash,no_subtree_check)
service nfs-kernel-server restart
# 查看nfs状态及支持的版本
nfsstat
Server rpc stats:
calls badcalls badfmt badauth badclnt
6638 6 6 0 0
Server nfs v3:
null getattr setattr lookup access
2 0% 593 8% 7 0% 1065 16% 366 5%
readlink read write create mkdir
42 0% 4092 61% 47 0% 199 3% 7 0%
symlink mknod remove rmdir rename
0 0% 0 0% 2 0% 0 0% 198 2%
link readdir readdirplus fsstat fsinfo
0 0% 0 0% 2 0% 0 0% 2 0%
pathconf commit
1 0% 6 0%
3、通过串口修改uboot启动配置,使用网络启动
setenv serverip 192.168.1.7;setenv ipaddr 192.168.1.100;setenv gatewayip 192.168.1.1;setenv netmask 255.255.255.0
setenv bootcmd 'mw.b 42000000 ff 400000;tftp 42000000 uImage;bootm 0x42000000'
setenv bootargs 'mem=256M console=ttyAMA0,115200 root=/dev/nfs rw nfsroot=192.168.1.7:/home/hisilicon/3519A/nfs/rootfs,v3,proto=tcp ip=192.168.1.100 init=/linuxrc'
saveenv
reset
注意:使用ubuntu18.04安装的nfs默认支持nfs v3,在设置bootargs时需要指定nfs版本,否则从nfs挂载根文件系统时会报错:random: fast init done
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "nfs" or unknown-block(2,0): error -6
启动完成后会有一条没有启动脚本的错误提示:can't run '/etc/init.d/rcS': No such file or directory
Please press Enter to activate this console.
敲回车键后可正常进入控制台