QEMU usage

From Initq
Jump to: navigation, search

Contents

Needed software

qemu

apt-get install qemu

tunctl

apt-get install uml-utilities

bridge-utils

apt-get install bridge-utils

linux-kernel-headers

apt-get install linux-kernel-headers
apt-cache search linux-headers-$(uname -r)
apt-cache search linux-headers-`uname -r`

kqemu

apt-get install kqemu-source
cd /usr/src
m-a prepare
m-a a-i kqemu

Create an virtual harddrive

qemu-img create debian50_64.img 20G

Note that if you wish to make backups of a newly created image (let's say, just after you installed the OS), you could take advantage of the fact that it's a sparse file and make a tar with the {-S} option, that will make smaller files in this way.

tar cjSf backup-image.tar.bz2 debian50_64.img

Install from image file

qemu -hda debian50_64.img -cdrom /qasket/os/linux/distro/debian/debian-504-amd64-netinst.iso -boot d -m 512

Install windows 7 64

kvm -hda win7pro_64.img -cdrom /qasket/os/windows/2008/win7pro_64.iso -boot d -m 1024

Running QEMU

modprobe tun # to network QEMU
 chmod 666 /dev/net/tun #  make it accessible to all users
 
 modprobe kqemu 
 mknod /dev/kqemu c 250 0
 /bin/chmod 666 /dev/kqemu  # make it accessible to all users

Run an image in 64 bit

qemu-system-x86_64 -m 384 -localtime debian50_64.img

Running a VM with single port forwarded

qemu-system-x86_64 -m 384 -localtime -hda debian50_64.img -net user -net nic,model=rtl8139 
-redir tcp:5022::22

Running a VM with multiple ports forwarded

qemu-system-x86_64 -m 384 -localtime -hda debian50_64.img -net user -net nic,model=rtl8139 
-redir tcp:5022::22 
-redir tcp:5023::22 -redir tcp:5024::22

Running VM for windows machine

qemu-system-x86_64 -m 384 -localtime -hda xp_64.img.img -net user -net nic,model=rtl8139 
-redir tcp:3389::3389

Background qemu

qemu-system-x86_64 -m 384 -localtime -hda debian50_64.img -nographic -serial null 
-monitor null -net user -net nic,model=rtl8139 -redir tcp:5022::22 &

CDROM

-cdrom /dev/cdrom

No kqemu

Use flag

  • -no-kqemu
Personal tools