qemu树莓派连接网络
修正死循环启动
输入命令:
nano/etc/ld.so.preload
将会打开一个文件,其中只有一行
/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so
在该行最前列处加上#符号(注意现在是英国式键盘):
#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so
如果开始死循环了
使用
qemu-system-arm -kernel kernel-qemu -cpuarm1176 -m 256 -M versatilepb -append “root=/dev/sda2 panic=1 init=/bin/sh rw” -hda 2013-07-26-wheezy-raspbian.img
加了panic=1init=/bin/shrw
扩容
qemu-imgresize2012-12-16-wheezy-raspbian.img+2G
rasp-config
选expand_rootfs
会报错
therewasanerrorrunningdo_expand_rootfs
需要进入树莓派
vi/etc/udev/rules.d/90-qemu.rules
创建文件。
输入内容:
viewplaincopytoclipboardprint?
KERNEL=="sda", SYMLINK+=”mmcblk0” KERNEL=="sda?", SYMLINK+=”mmcblk0p%n”, 注意有逗号 参考http://hi.baidu.com/shenaodong/item/bd82e0c931041a7fcfd4f835 或cp /usr/bin/raspi-config ~ sed -i ‘s/mmcblk0p2/sda2/’ ~/raspi-config sed -i ‘s/mmcblk0/sda/’ ~/raspi-config sudo ~/raspi-config 参考http://www.shumeipai.net/thread-13642-1-1.html apt-get的源 http://www.linuxidc.com/Linux/2013-10/91012.htm vi /etc/apt/sources.list
修改配置文件pi@aborn~$vi/etc/apt/sources.list
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ wheezy main contrib non-free rpi deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ wheezy main contrib non-free rpi deb http://mirrors.neusoft.edu.cn/raspbian/raspbian/ wheezy main contrib non-free rpi deb-src http://mirrors.neusoft.edu.cn/raspbian/raspbian/ wheezy main contrib non-free rpi deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ wheezy main contrib non-free rpi deb-src http://mirrors.ustc.edu.cn/raspbian/raspbian/ wheezy main contrib non-free rpi
下载
2012-12-16-wheezy-raspbian.img
kernel-qemu
由于2012-12-16-wheezy-raspbian.img需要的内核是3.2.27+
cd/lib/modules&&ls
查看
而kernel-qemu提供的内核是3.10.26+
uname-r
查看
完全匹配的没找到,iptables不好使
报
root@raspberrypi:~# iptables -L libkmod: ERROR ../libkmod/libkmod.c:554 kmod_search_moddep: could not open moddep file ‘/lib/modules/3.10.26+/modules.dep.bin’ iptables v1.4.14: can’t initialize iptables table `filter’: Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded.
但是不影响使用桥接网络
使用桥接连接qemu中的树莓派到网络
配置脚本放在某处,比如/root/xup
viewplaincopytoclipboardprint?
[root@localhost qemu]# cat /root/xup #!/bin/sh /sbin/ifconfig $1 0.0.0.0 promisc up /usr/sbin/brctl addif br0 $1 sleep 2 设置桥接网络 参考http://ju.outofmemory.cn/entry/45837 view plaincopy to clipboardprint? modprobe tun lsmod|grep tun ifdown eth0 ifconfig eth0 0.0.0.0 promisc up brctl addbr br0 brctl addif br0 eth0 brctl stp br0 off ifconfig br0 192.168.1.55 netmask 255.255.255.0 broadcast 192.158.1.255 route add default gw 192.168.1.1 ifup eth0 启动qemu view plaincopy to clipboardprint? [root@localhost qemu]# cat run.sh #!/bin/sh #qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -append "root=/dev/sda2" -hda 2012-12-16-wheezy-raspbian.img -vnc 192.168.1.111:1 -net nic -net user & #qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -append "root=/dev/sda2" -hda 2012-12-16-wheezy-raspbian.img -vnc 192.168.1.111:1 -net nic,vlan=0 & qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -append "root=/dev/sda2" -hda 2012-12-16-wheezy-raspbian.img -vnc 192.168.1.111:1 -net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=/root/xup & 主机网络
[root@localhost qemu]# ifconfig br0 Link encap:Ethernet HWaddr 00:0C:29:D5:D3:28 inet addr:192.168.1.55 Bcast:192.158.1.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fed5:d328/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:22612 errors:0 dropped:0 overruns:0 frame:0 TX packets:30629 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:4281564 (4.0 MiB) TX bytes:8026132 (7.6 MiB) eth0 Link encap:Ethernet HWaddr 00:0C:29:D5:D3:28 inet addr:192.168.1.111 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fed5:d328/64 Scope:Link UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1 RX packets:56725 errors:0 dropped:0 overruns:0 frame:0 TX packets:33717 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:36072369 (34.4 MiB) TX bytes:8180253 (7.8 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:162 errors:0 dropped:0 overruns:0 frame:0 TX packets:162 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:14560 (14.2 KiB) TX bytes:14560 (14.2 KiB) tap0 Link encap:Ethernet HWaddr B6:94:52:0E:11:1F inet6 addr: fe80::b494:52ff:fe0e:111f/64 Scope:Link UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1 RX packets:320 errors:0 dropped:0 overruns:0 frame:0 TX packets:527 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:500 RX bytes:40975 (40.0 KiB) TX bytes:49074 (47.9 KiB) [root@localhost qemu]#
树莓派网络
root@raspberrypi:~# ifconfig eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:56 inet addr:192.168.1.114 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:490 errors:0 dropped:0 overruns:0 frame:0 TX packets:298 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:46824 (45.7 KiB) TX bytes:37286 (36.4 KiB) Interrupt:57 Base address:0x8000 DMA chan:ff lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) root@raspberrypi:~#
其他设置参考
http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/