qemu – running emulation

I managed to get CENTOS5 booting today. In a virtual machine on my FreeBSD workstation. This post is mainly just notes for myself.

Create the blank HDD image file on my host OS:

qemu-img create -f qcow2 c.img 3G

Installing the new guest OS, by booting from the ISO image which appears as a CDROM:

qemu -cdrom CentOS-5.2-i386-bin-DVD.iso.iso -hda c.img -m 256 -boot d

Setting up the bridging between the guest and the host OS:

/sbin/ifconfig tap0 destroy
/sbin/ifconfig tap create
/sbin/ifconfig bridge0 destroy
/sbin/ifconfig bridge create
/sbin/ifconfig bridge0 addm tap0 addm em0 up

… where em0 is the NIC on my host system.

# ifconfig
em0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=98<VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
        ether 00:23:ae:78:ae:a8
        inet 192.168.1.101 netmask 0xffffff00 broadcast 192.168.1.255
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
plip0: flags=108810<POINTOPOINT,SIMPLEX,MULTICAST,NEEDSGIANT> metric 0 mtu 1500
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
        inet6 ::1 prefixlen 128
        inet 127.0.0.1 netmask 0xff000000
lo5: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        inet 10.10.10.2 netmask 0xffffffff
        inet 10.10.10.1 netmask 0xffffffff
pflog0: flags=141<UP,RUNNING,PROMISC> metric 0 mtu 33160
tap0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:bd:11:1f:7a:00
        inet 0.0.0.0 netmask 0xff000000 broadcast 0.255.255.255
        Opened by PID 33013
bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 2a:66:5d:fd:62:f9
        id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
        maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
        root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
        member: em0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 1 priority 128 path cost 200000
        member: tap0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 6 priority 128 path cost 2000000

The ifup script:

# cat /usr/local/etc/qemu-ifup
#!/bin/sh
ifconfig ${1} 0.0.0.0 up

To start the image:

qemu -hda /usr/local/qemu/CentOS-5.2-i386.img -m 256 -boot c \
      -net nic -net tap,ifname=tap0,script=/usr/local/etc/qemu-ifup

My references:

  1. http://calamari.reverse-dns.net:980/cgi-bin/moin.cgi/QuickStartGuide
  2. http://www.nongnu.org/qemu/user-doc.html
  3. http://www.gnome.org/~markmc/qemu-networking.html
  4. http://wiki.freebsd.org/qemu
  5. http://www.oszoo.org/wiki/index.php/Main_Page
  6. http://compsoc.dur.ac.uk/~djw/qemu.html

MrOlsen’s startup script:

#!/bin/sh
/sbin/ifconfig tap0 destroy
/sbin/ifconfig tap create
/sbin/ifconfig bridge0 destroy
/sbin/ifconfig bridge create
/sbin/ifconfig bridge0 addm tap0 addm re0 up
/usr/local/bin/qemu -daemonize -net nic -net tap,script=/etc/qemu-ifup -hda /usr/img/RFMS.img -boot c -vnc :10
/sbin/ifconfig bridge0 up

NOTE this day: first time I’ve worked with iptables. This got things flowing:

iptables --flush
Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Comment

Scroll to Top