qenu + uboot + kernel + rootfs + tftp + nfs(rootfs):
1,创建虚拟网卡设备,设置虚拟网卡,ifconfig查看虚拟网卡已经建立和配置好了。
sudo tunctl -t tap0 -u root; sudo ifconfig tap0 192.168.0.1 netmask 255.255.255.0 promisc
只能单root用户,多窗口不行!!!
2,tftp增强版安装配置启动
参考:https://blog.youkuaiyun.com/oXiaoXue123456789/article/details/81558959
https://blog.youkuaiyun.com/donglicaiju76152/article/details/76651210
sudo service tftpd-hpa restart
测试:
tftp 127.0.0.1
tftp>get test.txt
tftp>put test1.txt
tftp>q
3,nfs安装配置及启动
参考:https://blog.youkuaiyun.com/qq_20023231/article/details/80312250
安装应用
apt install nfs-kernel-server
配置 NFS。在 /etc/exports 文件中添加:
/home/qemu-test/rootfs *(rw,sync,no_root_squash,no_subtree_check)
• 开启 NFS 服务
sudo /etc/init.d/rpcbind restart
sudo /etc/init.d/nfs-kernel-server restart
测试:
sudo mount -t nfs 127.0.0.1:/home/gjh/learning/vexpress/nfs /mnt
2、启动 u-boot 并在内核中挂载 NFS 文件系统
qemu-system-arm -M vexpress-a9 -kernel u-boot -m 512M -nographic -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 -append "root=/dev/mmcblk0 rw console=ttyAMA0"(暂时未用此指令)
共享文件夹:
mount -t nfs -o nolock 192.168.0.1:/home/gjh/learning/vexpress/nfs /gjh
挂载跟文件系统(文件系统可直接mount后拷贝出来再umount):
参考:https://www.cnblogs.com/youthshouting/p/4541727.html
https://blog.youkuaiyun.com/liukuangye123/article/details/44901525
set bootargs noinitrd root=/dev/nfs nfsroot=192.168.0.1:/work/nfs_root/temp/fs_mini_mdev
ip=192.168.0.2:192.168.0.1:192.168.0.255:255.255.255.0::eth0:off init=/linuxrc console=ttySAC0
echo $( bootcmd)可查看
/gjh # cat /proc/cmdline
noinitrd root=/dev/nfs nfsroot=192.168.0.1:/home/gjh/learning/vexpress/nfs/nfsroot ip=192.168.0.2:192.168.0.1:192.168.0.255:255.255.255.0::eth0:off init=/linuxrc rw rootwait console=ttyAMA0
nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
/*
*nfsroot对应你pc机的IP和你解压的文件系统的路径,请酌情修改
* ip指定你的开发板的IP、服务器的ip、网关、掩码,掩码后面应该是域名(可省略)
* 再往后的,网卡eth0,不自动启动off
查看cmdline:
cat /proc/cmdline
4,问题
/ # rm dtb
rm: remove 'dtb'? yes
rm: can't remove 'dtb': Read-only file system
/ # ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1): 56 data bytes
ping: sendto: Network is unreachable
原因:uboot bootarg未设置。
/ # mount -t gjh 192.168.0.1:/home/gjh/learning/vexpress/nfs /gjh
mount: mounting 192.168.0.1:/home/gjh/learning/vexpress/nfs on /gjh failed: No such device
原因:nfs配置,需要进一步配置。支持reboot,写入rcs脚本。