QEMU

Create image

qemu-img create -f raw image_file 4G

Run iso with image

qemu-system-i386 -cdrom _iso_image_ -boot order=d _qemu_image_

Setting up memory

-m 512

Setting up network card

-net nic

Setting up tun device

brctl addbr tun0
iw dev wlp3s0 set 4addr on
brctl addif tun0 wlp3s0

Lunching image

If everything installed then image could be runed just with

qemu-system-i386 _options_ _disk_image_

Lunching self compiled kernel

Let compile kernel and prepare initramfs to lunch it. Create file init.c

#include <stdio.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
  printf("Hello world!\n");
  sleep(999999999);
}

compile

gcc init.c -o init -static

and create image to lunch

echo init | cpio -o -H newc | gzip > test.cpio.gz

And now we have luncuble stuff to test if kernel loads fine

qemu-system-x86_64 -m 512 -kernel ./bzImage -initrd test.cpio.gz

If everything whent fine we will see "Hello world"

Compile qemu

To get qemu you can download file or just clone git repo here is page to download files http://wiki.qemu.org/Download and git repo located at

git clone git://git.qemu-project.org/qemu.git

To see avaliable targets run

./configure --help

there alos many different options and targets just choose one that you need most

Configure targets:

./configure --target-list=arm-softmmu,arm-linux-user

or could be choosen to compile all targets

./configure --enable-system

Compile

make

Reference

  1. https://wiki.archlinux.org/index.php/QEMU
  2. http://www.cnx-software.com/2012/03/08/how-to-build-qemu-system-arm-in-linux/
  3. https://wiki.linaro.org/PeterMaydell/KVM/HowTo/BuildQEMU
  4. http://www.cs.rochester.edu/~sandhya/csc256/assignments/qemu_linux.html
  5. https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt