Created
January 19, 2016 10:00
-
-
Save zsrkmyn/41c7de991afd216fecd5 to your computer and use it in GitHub Desktop.
用qemu搭建一个debian-mips环境
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. 下载镜像 https://people.debian.org/~aurel32/qemu/mips{,el}/ ; mips 为大端,mipsel 为小端 | |
2. 设置宿主机网络 | |
```bash | |
#$ cat network_setup | |
sudo ip link add qbr0 type bridge | |
sudo ip addr add 172.20.0.1/16 dev qbr0 | |
sudo ip link set qbr0 up | |
# sudo dnsmasq -C dnsmasq.conf # for dynamic ip support | |
``` | |
```conf | |
#$ cat dnsmasq.conf # 静态 ip 配置不需要此文件 | |
listen-address=172.20.0.1 | |
#interface=qbr0 # 这行会导致 dnsmasq 监听 127.0.0.1,如果已经有 dnsmasq 运行的话会导致启动失败 | |
bind-interfaces | |
dhcp-range=172.20.0.2,172.20.255.254 | |
``` | |
3. 保存原始 snapshot | |
```bash | |
qemu-img snapshot -c origin debian_wheezy_mips_standard.qcow2 | |
qemu-img snapshot -l debian_wheezy_mips_standard.qcow2 # 确认 snapshot 成功 | |
``` | |
4. 启动虚拟机 | |
```bash | |
#$ cat start | |
qemu-system-mips64 \ | |
-M malta \ | |
-kernel vmlinux-3.2.0-4-5kc-malta \ | |
-hda debian_wheezy_mips_standard.qcow2.layout.1 \ | |
-append "root=/dev/sda1 console=tty0" \ | |
-m 256M \ | |
-net nic,vlan=0 \ # eth0 | |
-net user,vlan=0 \ # eth0 直通网络,可以从虚拟机访问宿主机和 internet,但宿主机不能访问虚拟机(似乎可以用 ssh 做反向隧道?) | |
-net nic,vlan=1 \ # eth1 | |
-net bridge,br=qbr0,vlan=1 \ # eth1, bridge, 用于和宿主机通信,不能访问 internet (除非宿主机配置好),方便 ssh | |
#-vnc :5 | |
#似乎不能指定 —smp,否则无法启动 | |
``` | |
5. 删掉一些不要的启动项,在 /etc/rc2.d/ 里。这个 mips 虚拟机的速度真是特别特别慢啊 Orz | |
6. 配置虚拟机网络 | |
``` | |
# /etc/network/interfaces | |
# The loopback network interface | |
auto lo | |
iface lo inet loopback | |
# The primary network interface | |
auto eth0 | |
allow-hotplug eth0 | |
iface eth0 inet dhcp | |
auto eth1 | |
iface eth1 inet static # 如果前面设置用 dnsmasq 非配动态 ip 的话这里照 eth0 写就好。静态 ip 方便 ssh | |
address 172.20.0.2 | |
netmask 255.255.0.0 | |
gateway 172.20.0.1 | |
``` | |
`ifup -a` 启动网络,现在可以从宿主机 ssh 过去了。 | |
7. 安装一些必要的软件 | |
`apt-get update && apt-get install vim debian-keyring sudo` | |
update 的过程会非常慢,bzip2 解压特别耗时间 Orz 处理器太渣了! | |
8. 配置成功后最后再建立一个 snapshot | |
```bash | |
qemu-img snapshot -c initial_config debian_wheezy_mips_standard.qcow2 | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment