From wiki.network-crawler.de
Jump to: navigation, search
qemu-img create debian_sarge.img 5G
qemu-system-i386 -localtime -hda /mnt/debian_sarge.img -cdrom /dev/cdrom -boot d

Mount qemu images

mount -t ext3 /opt/qemu/tempImage /mnt/tempImage -o loop,offset=sector_size*partition_start

Most of the time sector_size is 512 and parition_start 63. It's possible to check this with

fdisk -lu /opt/qemu/tempImage. 

Example output:

/etc/xen$ fdisk -lu /xen_mnt/Sarge.img
You must set cylinders.
You can do this from the extra functions menu.

Disk /xen_mnt/Sarge.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes

             Device Boot      Start         End      Blocks   Id  System
/xen_mnt/Sarge.img1   *          63     9976364     4988151   83  Linux
/xen_mnt/Sarge.img2         9976365    10474379      249007+   5  Extended
/xen_mnt/Sarge.img5         9976428    10474379      248976   82  Linux swap / Solaris

kqemu for SuSE:

Leech: http://gcc.fyxm.net/releases/gcc-3.3.6/gcc-3.3.6.tar.gz

./configure --prefix=/opt/gcc33 --program-suffix=-3.3
make bootstrap
make install

Leech qemu and kqemu from: http://fabrice.bellard.free.fr/qemu/download.html
unpack kqemu in qemu - then:

./configure --prefix=/usr/local --cc=/opt/gcc33/bin/gcc-3.3 --enable-adlib \
--target-list="i386-user arm-user armeb-user sparc-user ppc-user i386-softmmu ppc-softmmu sparc-softmmu x86_64-softmmu mips-softmmu"

If make fails with TLS error look here

cd kqemu*
make clean
cd ..
make install
modprobe kqemu major=0


  • More RAM for the VM (example):
qemu ... -m 512
  • QEMU Monitor:
[Strg]-[Alt]-[2]: switch to Qemu-monitor
[Strg]-[Alt]-[1]: back to guest
  • Additional directories from Linux system (example)
qemu ... -hdb fat:/tmp
  • Serial communication:
qemu ... -serial /dev/ttyS0

KVM with Ubuntu 7.04 + HW VT support

startup script:

modprobe kvm
modprobe kvm-intel

echo 1 > /proc/sys/net/ipv4/ip_forward
brctl addbr br0
ifconfig eth0 up
brctl addif br0 eth0
ifconfig br0
chmod 666 /dev/net/tun

#dhclient br0

kvm -hda /exchange/WinXP_4_12_07.img -m 1024 -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 -redir tcp:3389::3389 -nographic -monitor "tcp:,server,nowait"

typical setup for win7

kvm -usb -hda win7.img -cdrom /dev/cdrom -m 2000 -net nic,model=ne2k_pci,vlan=0 -net tap,vlan=0,ifname=tap0 -redir tcp:3389::3389 -vnc :1 -monitor "tcp:,server,nowait" &

getting special network binaries (use e.g. with ubuntu):

wget -O pxe-ne2k_pci.bin http://svn.savannah.gnu.org/viewvc/*checkout*/trunk/pc-bios/pxe-ne2k_pci.bin?root=qemu
wget -O pxe-rtl8139.bin http://svn.savannah.gnu.org/viewvc/*checkout*/trunk/pc-bios/pxe-rtl8139.bin?root=qemu
wget -O pxe-e1000.bin http://svn.savannah.gnu.org/viewvc/*checkout*/trunk/pc-bios/pxe-e1000.bin?root=qemu
sudo mv pxe*.bin /ush/share/qemu/
kvm up script (/etc/kvm/kvm-ifup):
sudo /sbin/ifconfig $1 promisc up
sudo /usr/sbin/brctl addif br0 $1