qemu 配置tftp/nfs

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.csdn.net/oXiaoXue123456789/article/details/81558959
https://blog.csdn.net/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.csdn.net/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.csdn.net/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脚本。

 

 

 


 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值