现在的位置: 首页 > 综合 > 正文

qemu模拟sparc32

2013年09月01日 ⁄ 综合 ⁄ 共 2147字 ⁄ 字号 评论关闭

1. $wget http://wiki.qemu-project.org/download/qemu-1.4.1.tar.bz2

2. $tar -xjf qemu-1.4.1.tar.bz2

3. $cd qemu-1.4.1
   $./configure
   #make install
4. $qemu-sparc64 -version
   qemu-sparc64 version 1.4.1, Copyright (c) 2003-2008 Fabrice Bellard

5. 创建磁盘镜像
   $mkdir spark
   $cd spark
   $qemu-img create -f qcow hda.img 40G
   由于采用了qcow格式,所有非空的扇区才被写入文件中。所以,磁盘文件比较小。
   $du -h hda.img

6. 获取spark内核的镜像
   目前对最新的debian的支持有问题。
   //The last Debian release to support sparc32 (sun4m) was Etch (4.0)
   $http://cdimage.debian.org/cdimage/archive/4.0_r9/sparc/iso-cd/debian-40r9-sparc-netinst.iso
7. 安装debian
   $qemu-system-sparc -hda hda.img -cdrom debian-40r9-sparc-netinst.iso -boot d
   其中boot 选项指定从 CD-ROM 引导。参数 d 指定从 CD-ROM 引导,其中 a 指定从软盘引导,c
   指定从硬盘引导(默认),而 n 指定从网络引导。
 
8. 启动系统
   $qemu-system-sparc -hda hda.img  -boot c

9. 配置网络

   - 确保主机内核已经配置了CONFIG_TUN
     $grep CONFIG_TUN /boot/config-`uname -r`   
      # CONFIG_TUN=m / CONFIG_TUN=y
   - 加载tun模块
     #modprobe tun
   - 确保主机内核配置了CONFIG_BRIDGE

   - 修改主机的网络配置文件/etc/network/interfaces

静态配置:
auto br0
iface   br0     inet    static
address 192.168.2.254
network 192.168.2.0
netmask 255.255.255.0
broadcast       192.168.2.255
gateway         192.168.2.1
bridge_ports    eth0

动态配置:
auto br0
iface   br0     inet    dhcp
bridge_ports    eth0
bridge_maxwait  0
    
   - 安装必须的工具
     # apt-get install bridge-utils
   - 重新启动网络
     #/etc/init.d/networking restart
   - 创建脚本/etc/qemu-ifup,在qemu启动时自动执行

#!/bin/sh
echo "Executing /etc/qemu-ifup"
echo "Bringing up $1 for bridged mode..."
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
echo "Adding $1 to br0..."
sudo /usr/sbin/brctl addif br0 $1
sleep 2

    实际上是将tap0添加到br0(桥接,可以认为是多个端口的一个hub)中。
      
10. 启动qemu

    #qemu-system-sparc -hda hda.img -net nic,macaddr=00:16:3e:00:00:01 -net tap
   
11. 在qemu中配置网络

   #ifconfig eth1 192.168.1.123 up
   //根据host中br0的ip配置,我的为br0 192.168.1.101

   ping host
   #ping 192.168.1.101

   从host上ping qemu
   #ping 192.168.1.123
 
   如果配置正常,就可以相互访问了。

12. qemu连接外网
   
    - 设置host
      开启host的转发功能,确保/proc/sys/net/ipv4/ip_forward的值为1
    - ???什么作用???
      #iptables -t nat -A POSTROUTING -j MASQUERADE
       
    - 这时已经可以ping外网的ip了。
      #ping 119.75.217.56
    - 配置域名解析
      将host下的/etc/resolv.conf中的内容写到qemu虚拟机的/etc/resolv.conf中。
      此时,可以ping外网的域名了。

      #ping www.baidu.com

13. 如果需要安装其他软件可以从debian-40r9-sparc-netinst.iso中的pool中拷贝安装。

     #mount -o loop debian-40r9-sparc-netinst.iso /mnt

   

抱歉!评论已关闭.