Show pagesourceOld revisionsBacklinksBack to top × Table of Contents 使用armvirt架构的虚拟镜像来测试LEDE 获取armvirt镜像 运行镜像 准备工作 用initramfs启动 网络配置 设置因特网到LEDE 在LEDE中配置LUCI 高级的启动方式 使用KVM加速 使用一个独立的rootfs分区 使用本地目录作为rootfs分区启动 使用kvmtool运行 使用armvirt架构的虚拟镜像来测试LEDE 一个新的架构 “armvirt” 在2016年12月被添加到LEDE项目中. 这是运行在QEMU模拟器上的系统。 在没有物理路由的情况下,这会对测试修正非常有用。 获取armvirt镜像 可以手动构建镜像,或者从链接下载, 比如. armvirt lede-17.01的armvirt镜像. 运行镜像 准备工作 这种方式会使用到 qemu-system-arm, 因此你需要安装必要的软件包。 在 Debian: apt-get install qemu qemu-system-arm 在 Arch Linux: pacman -S qemu qemu-arch-extra 用initramfs启动 这是能用来测试一个镜像的最简单的方法。然而,它运行在内存中: 任何修改都会在重启后丢失. 这里我们用64MB的内存配置来启动: qemu-system-arm -nographic -M virt -m 64 -kernel lede-armvirt-zImage-initramfs 网络配置 qemu 有几种选项来提供网络连接来模拟镜像, 在qemu(1)中使用 -net 选项来查看. 设置因特网到LEDE qemu的默认网络模式是“用户模式网络栈(user mode network stack)”. 在这种模式下,qemu 作为一个出口连接代理(proxy). 它同样能为模拟系统提供DHCP和DNS服务功能. 给LEDE系统接入因特网,运行以下命令: qemu-system-arm -net nic,vlan=0 -net nic,vlan=1 -net user,vlan=1 \ -nographic -M virt -m 64 -kernel lede-17.01.0-r3205-59508e3-armvirt-zImage-initramfs 这里,我们设置两张网卡到模拟的LEDE系统: eth0, 在LEDE作为LAN口(不用于连接外部网络) eth1, 在LEDE作为WAN口, 并且连接到代理了所有tcp/udp请求的qemu LEDE 系统将会在eth1 (通过DHCP/DHCPv6)获取到一个IPv4和IPv6地址. IPv4和IPv6地址段是10.0.2.0/24 和 fec0::/64 (qemu默认设置, 查看 qemu(1) 来设置其他地址段). 1). 在LEDE中配置LUCI LUCI 是LEDE的web管理界面. 如果你想要检查luci的工作原理,或者查看其他luci应用,这个设置会适合你。 注意: 这个设置需要一些高级权限 (在Linux下的CAP_NET_ADMIN 和 CAP_MKNOD ) ,因为使用sudo会很方便的运行 保存以下脚本,并修改 IMAGE 变量为你的LEDE版本, 然后用sudo运行 #!/bin/sh IMAGE=lede-17.01.0-r3205-59508e3-armvirt-zImage-initramfs LAN=ledetap0 # create tap interface which will be connected to LEDE LAN NIC ip tuntap add mode tap $LAN ip link set dev $LAN up # configure interface with static ip to avoid overlapping routes ip addr add 192.168.1.101/24 dev $LAN qemu-system-arm \ -device virtio-net-pci,netdev=lan \ -netdev tap,id=lan,ifname=$LAN,script=no,downscript=no \ -device virtio-net-pci,netdev=wan \ -netdev user,id=wan \ -M virt -nographic -m 64 -kernel $IMAGE # cleanup. delete tap interface created earlier ip addr flush dev $LAN ip link set dev $LAN down ip tuntap del mode tap dev $LAN 网络的运行原理: eth0, 在LEDE作为LAN口, 并且连接到宿主系统的 ledetap0 (静态地址192.168.1.101/24), luci的连接地址为 http://192.168.1.1 eth1, 在LEDE作为WAN口, 并且连接到代理了所有tcp/udp请求的qemu 高级的启动方式 使用KVM加速 这种方式会启动的更快,但是只能当你的cpu架构和目标镜像的架构相同才能用。(ARM cortex-a15). qemu-system-arm -nographic -M virt,accel=kvm -cpu host -m 64 -kernel lede-armvirt-zImage-initramfs 使用一个独立的rootfs分区 qemu-system-arm -nographic -M virt -m 64 -kernel lede-armvirt-zImage \ -drive file=lede-armvirt-root.ext4,format=raw,if=virtio -append 'root=/dev/vda rootwait' 使用本地目录作为rootfs分区启动 qemu-system-arm -nographic -M virt -m 64 -kernel lede-armvirt-zImage \ -fsdev local,id=rootdev,path=root-armvirt/,security_model=none \ -device virtio-9p-pci,fsdev=rootdev,mount_tag=/dev/root \ -append 'rootflags=trans=virtio,version=9p2000.L,cache=loose rootfstype=9p' 使用kvmtool运行 # 开启一个名为armvirt0的模拟器 lkvm run -k lede-armvirt-zImage -i lede-armvirt-rootfs.cpio --name armvirt0 # 使用virtio-9p的rootfs lkvm run -k lede-armvirt-zImage -d root-armvirt/ # 停止 "armvirt0" lkvm stop --name armvirt0 # 停止所有 lkvm stop --all This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.OKMore information about cookies Last modified: 2017/11/01 23:28by lolikiller