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=1 init=/bin/sh rw

扩容
qemu-img resize 2012-12-16-wheezy-raspbian.img +2G
rasp-config
选expand_rootfs
会报错
there was an error running do_expand_rootfs
需要进入树莓派
vi /etc/udev/rules.d/90-qemu.rules
创建文件。
输入内容:

view plaincopy to clipboardprint?
   
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

view plaincopy to clipboardprint?
[code="java"]
# 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?

# 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 &
主机网络
[/code]
[code="java"]
# 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)

# [/code]
树莓派网络

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/
### 使用 QEMU 安装适用于树莓派的 AV 镜像 为了使用 QEMU 安装适用于树莓派的 AV 镜像,可以遵循一系列特定的操作流程来准备环境并执行安装过程。 #### 准备工作 确保主机系统已准备好支持 QEMU 的运行。这通常涉及安装必要的软件包和支持库: 对于缺少依赖项的情况,可以通过命令 `sudo apt install libssh2-1-dev` 来解决相关问题[^4]。 #### 获取镜像文件 下载适合于目标硬件架构(如 ARM)的 Raspbian 或其他操作系统映像文件。如果需要调整磁盘空间大小,则可利用工具如 `qemu-img.exe resize 2016-09-23-raspbian-jessie.img +5G` 扩展镜像容量以适应更多数据存储需求[^3]。 #### 设置启动环境 创建用于挂载新镜像的工作目录,并通过脚本完成初始配置。首次挂载后需手动复制辅助程序至指定路径以便后续操作顺利进行: ```bash $ sudo cp /usr/bin/qemu-arm-static /mnt/usr/bin/ $ sudo chroot /mnt ``` 上述指令展示了如何将必需的支持文件拷贝到适当位置以及切换根目录的过程[^2]。 #### 启动虚拟机 最后一步是在本地计算机上模拟启动所选的操作系统映像。此过程中可能需要用到额外参数指明设备模型和其他选项,具体取决于使用的版本和个人偏好设置。 请注意,在实际应用中还需考虑网络连接、图形界面显示等因素的影响;此外,某些功能或许仅能在物理设备而非仿真环境中得到完美体现。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值