QEMU Post Install

Ubuntu

Install QEMU

sudo apt-get install qemu qemu-system qemu-kvm qemu-user-static

Verify if an accelerator it possible, if your processor supports virtualization in hardware. To find out whether it does, run the command:

egrep -o "vmx|svm" /proc/cpuinfo

In my quad-core system, I see:

vmx
vmx
vmx
vmx

so it is possible. You would be looking for the “vmx” flag for an Intel-VT and the “svm” flag for an AMD-V processor. Now install kvm.

sudo apt-get install kvm kvm-pxe

Create disk image

Create standard image file:

qemu-img create debian_x86.img 2G

Net Install Debian

Download Debian NetInstall CD ( businesscard is the smallest ):

http://www.debian.org/CD/netinst/#businesscard-stable

Install on cow image:

kvm -hda debian_x86.img -cdrom debian-6.0.3-i386-businesscard.iso -boot d -m 256

Now it is possible to run the system:

kvm -hda debian_x86.img -m 256

Run Test Image

The “cow” part of qcow2 is an acronym for copy on write, a neat little trick that allows you to set up an image once and use it many times without changing it.

qemu-img create -f qcow2 -b debian_x86.img debian_x86_test01.cow
kvm -hda debian_x86_test01.cow -m 256

Install ssh deamon in QEMU Guest and connect from host

In QEMU Guest install ssh (client and server):

sudo apt-get install ssh
sudo shutdown -h now

Startup QEMU Guest with redir option to ssh port:

kvm -hda debian_x86_test01.cow -m 256 -redir tcp:5022::22

Verify if the port is listen on host:

sudo netstat --tcp --listening --programs
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 localhost:ipp           *:*                     LISTEN      1000/cupsd      
tcp        0      0 *:5022                  *:*                     LISTEN      2850/kvm        
tcp        0      0 *:902                   *:*                     LISTEN      1397/vmware-authdla
tcp        0      0 *:www                   *:*                     LISTEN      1546/apache2    
tcp6       0      0 ip6-localhost:ipp       [::]:*                  LISTEN      1000/cupsd 

It is ok, now it is possible to connect from host to guest QEmu:

ssh localhost -p 5022 -l asdf
asdf@localhost's password: 
Linux debian 2.6.32-5-686 #1 SMP Thu Nov 3 04:23:54 UTC 2011 i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Jan 14 20:36:23 2012 from 10.0.2.2

Open www port on 5080

kvm -hda debian_x86_test01.cow -m 256 -redir tcp:5022::22 -redir tcp:5080::80

Mounting qcow2 qemu disk images

Connect and Mount:

sudo modprobe nbd max_part=8
sudo qemu-nbd --connect=/dev/nbd0 debian_x86_test01.cow
sudo mkdir /media/cow
sudo mount /dev/nbd0p1 /media/cow
cd /media/cow

Unmount and Disconnect:

sudo umount /media/cow
sudo qemu-nbd --disconnect /dev/nbd0

Run CD ISO images

QEMU ARM

QEMU ARM Debian

su
mkdir /home/asdf/opt/debian_cd_armel
cd /home/asdf/opt/debian_cd_armel
wget http://ftp.nl.debian.org/debian/dists/stable/main/installer-armel/current/images/versatile/netboot/vmlinuz-3.2.0-4-versatile
wget http://ftp.nl.debian.org/debian/dists/stable/main/installer-armel/current/images/versatile/netboot/initrd.gz
qemu-img create debian_armel.img 2G
qemu-system-arm -hda debian_armel.img -m 512 -M versatilepb -kernel vmlinuz-3.2.0-4-versatile -initrd initrd.gz -append "root=/dev/sda1" 

Success with QEMU emulator version 1.4.0 (Debian 1.4.0+dfsg-1expubuntu4), Copyright (c) 2003-2008 Fabrice Bellard

zip debian_armel.img.zip debian_armel.img

parted ./debian_armel.img -s unit b print
mkdir -p /tmp/debian
mount -o loop,ro,offset=1048576 ./debian_armel.img /tmp/debian
cp /tmp/debian/boot/vmlinuz-3.2.0-4-versatile .
cp /tmp/debian/boot/initrd.img-3.2.0-4-versatile .
umount /tmp/debian

qemu-system-arm -hda debian_armel.img -m 512 -M versatilepb -kernel vmlinuz-3.2.0-4-versatile -initrd initrd.img-3.2.0-4-versatile -append "root=/dev/sda1" -redir tcp:2222::22

ssh localhost -p 2222 -l asdf

QEMU Mipsel

QEMU Mipsel Debian

su
mkdir /home/asdf/opt/debian_mipsel
cd /home/asdf/opt/debian_mipsel
wget http://ftp.nl.debian.org/debian/dists/stable/main/installer-mipsel/current/images/malta/netboot/vmlinux-3.2.0-4-4kc-malta
wget http://ftp.nl.debian.org/debian/dists/stable/main/installer-mipsel/current/images/malta/netboot/initrd.gz
qemu-img create debian_mipsel.img 2G
qemu-system-mipsel -M malta -hda debian_mipsel.img -m 256 -kernel vmlinux-3.2.0-4-4kc-malta -initrd initrd.gz -append "root=/dev/sda1 console=tty0"
Failed with QEMU emulator version 1.4.0 (Debian 1.4.0+dfsg-1expubuntu4), Copyright (c) 2003-2008 Fabrice Bellard

QEMU Mipsel Debian Preconfig

Windows

Several version of QEMU

Install QEMU

Download and unpack qemu-0.9.0-windows.zip

Create disk image

Create standard image file:

cd c:\qemu-0.9.0-windows\
qemu-img create -f qcow2 ubuntu-12.04.3.img 10G

Install Ubuntu on disk image

cd c:\qemu-0.9.0-windows\
qemu.exe -L . -hda ubuntu-12.04.3.img -cdrom ubuntu-12.04.3-server-i386.iso -boot d -m 1024

Note

QEMU run bad on Windows ( very unstable and slow ), use CoLinux instead.

qemu/qemu_post_install.txt · Last modified: 2014/01/09 17:44 by rkpisanu
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0





Mail