Tag Archive : qemu

/ qemu

QEMU on Windows

December 5, 2015 | Article | 1 Comment

QEMU is an emulator for various CPUs. QEMU can emulate Operating System like Linux, Windows, FreeBSD, etc such as Virtual Box and VMWare do. But unlike other emulator, QEMU can also emulate machine. Hence you can get an ARM “run” on top of your machine.

When used as a machine emulator, QEMU can run OSes and programs made for one machine (e.g. an ARM board) on a different machine (our machine) by using dynamic translation with very good performance. When used as a virtualizer, QEMU achieves near native performance by executing the guest code directly on the host CPU.

On previous article we have discuss many things on QEMU such as: Installing Slackware on QEMU and also Installing QEMU on Slackware64. In this article we will discuss something different. We will discuss about how to install QEMU on Windows using Windows 8 64-bit. Although I use Windows 8 64 bit as example, you can also build QEMU on your 32-bit Windows machine.

Obtain the Materials

QEMU binaries for Windows is officially not supported and not maintained by QEMU. To obtain QEMU for Windows we can get the unofficial binaries from some contributors. Here we have some providers:

  1. Prashant Satish’s build
  2. Eric Lassauge’s build
  3. Takeda Toshiya’s build
  4. Stefan Weil’s build

Thanks for your work for providing the binaries.

In this article, I will use QEMU 1.5.2 which is provided by Prashant Satish. You can do direct download the specified file here.

Make sure you have application that can open and extrace .lzma type. I recommend you to use 7zip for this purpose.

Installation

Well, there is no special treatment for QEMU installation. First, extract the archive (in this case: qemu-1.5.2-win32.tar.lzma). You will get a directory qemu and some binaries inside. Let’s move this directory to C: thus we will get C:\qemu now.

Next, we need to “register” qemu binaries so Windows can execute them.

Now open Control Panel. Now choose Edit the system environment variables. If you can’t find it, enter Control Panel\System and Security\System to address bar and choose Advanced system settings. Click on Environment Variables button and edit path. Add following: “;C:\qemu” without quote “.

Open up command prompt, and let’s try to boot QEMU.

qemu-system-i386

You should see a new window appear like a new PC just booting up.

qemu_window

Installing Windows XP on QEMU

December 5, 2015 | Article, Labs | No Comments

On other article we have discussed about running Debian ARM on QEMU, and also Slackware ARM on QEMU. Now,  in this article we will attempt install Windows XP on QEMU.  In this article I use:

  1. Slackware64 14.0 as host OS
  2. QEMU
  3. Windows XP ISO / CD

Obtain the Materials

Make sure you have install QEMU. If you have not installed it yet, you can read article here.

Another thing we need is Windows XP ISO or CD for installation. Make sure you have product key for activation. This article won’t give you link to obtain any of them so you should find them by yourself. Either ISO or CD is OK, just pick one.

Preparing the Environment

First we need to set the environment before do installation.

Make Working Directory

All progress we did will be stored on a single directory. You can create any directory but for this article I assume you create it on ~/QEMU/WinXP directory. Also, save ISO file, if you do installation by ISO file, to this directory.

Create Disk

We need to create a raw hard disk. At minimum, 4GB disk is sufficient. In this article I use 6GB disk. You don;t need to partitioning your disk. All work will be done on an image disk. The image can be created by qemu:

qemu-img create -f raw WinXP.img 6G

On above command, we create a disk with 6GB capacity. The -f switch tell qemu to create a raw disk. The disk then stored as an image file with filename WinXP.img

Installation

First we need to boot the ISO. On our working directory, invoke following command:

qemu-system-i386 -m 512 -hda WinXP.img -cdrom winxp_n_sp2.ISO -boot d

The platform we use is i386 or generic Intel x86 CPU therefore we use qemu-system-i386 to boot. Here are the explanation of all arguments we put:

  • -m 512: allocate 512 MB of RAM for virtual machine
  • -hda WinXP.img: Search for WinXP.img on current directory and use it as hard disk.
  • -cdrom winxp_n_sp2.ISO: Use ISO file with filename winxp_n_sp2.ISO on current directory. The name may be vary and you should adjust it with your ISO’s name. If you use installation CD, insert your CD and replace winxp_n_sp2.ISO with /dev/cdrom or whatever your CD device file node is.
  • -boot d: instructs QEMU to let the virtual machine boot from the (virtual) CD-ROM drive we’ve specified using -cdrom

A window might appear and then you can see the installation CD is now booting. You can continue with usual installation procedure, it’s not different compared to when you install to actual machine. And it still ask you about product key so you better enter the correct code.

Once the installation finish, you will got you Windows XP running on QEMU. Now, whenever you want to boot Windows XP, you can at minimum invoke following command:

qemu-system-i386 -m 512 -hda WinXP.img

Now, happy hacking 😀

Here are some screenshots

Slackware on Slackware using QEMU

December 5, 2015 | Article | 2 Comments

After successfully install QEMU-KVM on Slackware64 (previous article) and running a Debian for ARM on QEMU article, we will try something more.

In this article, we will discuss about installing Slackware for ARM using QEMU on Slackware64 (Slakwareception?). On this article we will use:

  1. Slackware64 14.0 (as host)
  2. QEMU 14.0 as discussed on this article
  3. Slackware for ARM (as guest)

Obtaining the Materials

If you have not installed QEMU, I suggest you to install it first following this article.

Create a working directory, for example (adjust with yours):

mkdir -p /home/xathrya/SlackARM
cd /home/xathrya/SlackARM

Then we need to download the kernel:

cd /home/xathrya/SlackwareARM
mkdir -p kernels/versatile
cd kernels/versatile
wget -c "ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-14.0/kernels/versatile/zImage-versatile"

Verify that you have finish download it. Then we will download the initial ramdisk for it, by:

cd /home/xathrya/SlackwareARM
mkdir -p isolinux
cd isolinux
wget -c "ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-14.0/isolinux/initrd-versatile.img"

Now we will create storage will be sued for our Slackware. Do it by:

cd /home/xathrya/SlackwareARM
mkdir hdd; cd hdd
qemu-img create hdd/arm.qcow 2G

A 2GB is sufficient for our experiments. Then downloads following packages from here . For simplicity, We only need a packages and l packages. But firstly, fo this command:

mkdir -p /home/xathrya/SlackwareARM/slackware
cd /home/xathrya/SlackwareARM/slackware
mkdir a l

Then download these package. The packages on a packages must be downloaded to a directory, while l package must be downloaded to l directory. The list of packages:

“a” packages

  1. aaa_base-14.0-arm-4.tgz
  2. aaa_elflibs-14.0-arm-2.tgz
  3. aaa_terminfo-5.8-arm-1.tgz
  4. bash-4.2.037-arm-1.tgz
  5. bin-11.1-arm-2.tgz
  6. coreutils-8.19-arm-1.tgz
  7. e2fsprogs-1.42.6-arm-1.tgz
  8. etc-14.0-arm-1.tgz
  9. kernel-modules-versatile-3.4.11_versatile-arm-1.tgz
  10. kernel_versatile-3.4.11-arm-1.tgz
  11. pkgtools-14.0-noarch-2.tgz
  12. shadow-4.1.4.3-arm-6.tgz
  13. sysvinit-2.88dsf-arm-2.tgz
  14. sysvinit-functions-8.53-arm-1.tgz
  15. sysvinit-scripts-2.0-noarch-9.tgz
  16. util-linux-2.21.2-arm-3.tgz

“l” packages

  1. glibc-2.15-arm-8.tgz

Then make iso files on /home/xathrya/SlackwareARM (adjust with your path) with content of isolinux, kernels, and slackware. You can do following command:

cd /home/xathrya/SlackwareARM
mkisofs -udf -o /home/xathrya/slackware-arm-14.0.iso -R -J \
-V "Slackware ARM 14.0" -hide-rr-moved -v -d -N -A "Slackware ARM 14.0" .

Notice the dot “.” on the last sentence as part of command. It will create an iso file slackware-arm-14.0.iso on /home/xathrya/.

Running the System

With initrd, kernel, and ISO file, we march to last step which is running the system (and also install it). Do the followings:

cd /home/xathrya/Slackware/ARM
qemu-system-arm -M versatilepb -kernel kernels/versatile/zImage-versatile \
-initrd isolinux/initrd-versatile.img hdd/arm.qcow \
-cdrom /home/xathrya/slackware-arm-14.0.iso

Some error messages might occurred such as

/bin/grep: No such file or directory

But don’t worry, if you follow this article you can able to install Slackware using QEMU.

Emulation with QEMU

December 5, 2015 | Article | 1 Comment

On previous article, we have discuss about how to install QEMU-KVM on Slackware64 and Windows. In this article we will discuss about Virtualization and Emulation using QEMU.

QEMU – Overview

QEMU is an emulator and vitualization tool like VMware, KVM, VirtualBox, and Xen did. It emulates hardware, but with more options available. QEMU is available to emulates some hardware architectures, including embedded system. Processor architecture supported by QEMU are: x86, ARM, MIPS, etc.

QEMU is cross platform, available for many Operating System such including Linux, Microsoft Windows, and any Unix-like as its host operating system.

How it work

QEMU is like any virtualization tools, dividing resource for native OS (the host) and virtual machine (guest). It support virtualization with Xen Hypervisor or Linux KVM modules. With KVM, QEMU can emulate x86, server and embedded PowerPC, and also S390.

As result of resource division, there will be a decreasing in performance both on host and guest system. However, QEMU use dynamic translation to translate machine code of guest to host which makes the performance good enough.

Operating Mode

QEMU has two operating mode, which are:

  1. User Mode Emulation – QEMU can emulate own Linux process which is compiled to a CPU on different CPU.
  2. Full System Emulation – QEMU emulate whole system, including every resource (suh as processor and peripheral). This mode is useful to do some debugging and code testing on virtual machine. Using QEMU we can run some virtual machines simultaneously on a host (of course we should measure the resource needed).

Installation

The installation can be done easily. You can install QEMU by following this article for Linux and this article for Windows.

Running Kernel Image

You can read this article to run a simple Debian for ARM distribution.

Playing with Arguments

Following are arguments that can be used for running a system.

Function Command Notes
 Specifying amount of RAM  -m x  X is the amount of RAM in MB
 Use initial ramdisk  -initrd PATHANDFILENAME
 Add additional disks  -hdb DISK2 -hdc DISK3 -hdd DISK4
 Add cdrom drive  -cdrom FILE  FILE can be ISO or /dev/cdrom on UNIX
 Disable graphic  -nographic  Useful for emulate a headless raspi or to route the output directly to terminal
 Make QEMU exits when the system reboot  -no-reboot
 Pass argument to kernel  -append “KERNEL OPTIONS”  the kernel OPTIONS will be discussed on next section.

Kernel Options

Following are arguments that can be passed to kernel (the one QEMU boot).

Function Command Notes
 Specify what partition of disk will be the root partition  root=DEVICE
 Specify what file to run after kernel is loaded  init=FILE
 Prevent QEMU from simply freeze when the kernel is panic  panic=x  x is the number of seconds before rebooting. Usefule with the -no-reboot option
 Specify default console device for the output.  console=DEVICE

Disk Operation

In this section we will discuss about creating a disk image for QEMU. It is recommended to use Linux. The general syntax for creating a disk is:

qemu-img create <FILENAME> <SIZE>

Where <FILENAME> is filename and path if you don’t want to create the image on current directory. The size is written in numerical value followed by size unit in:

  • k or K for Kilobyte (1024 byte)
  • m or M for Megabyte (1025 kb)
  • g or G for Gygabyte (1024m mb)

The created file contain 0 (zero) and mean nothing to system.

To format a disk, we can use UNIX & Linux utility:

  • EXT2 => mkfs.ext2 <FILENAME>
  • EXT3 => mkfs.ext3 <FILENAME>
  • etc

We can also mounting <FILENAME> to modify it.

Installing QEMU-KVM from Source

December 5, 2015 | Article | 9 Comments

Update: If you are searching for QEMU only installation, see here.

KVM stands for Kernel-based Virtual Machine, is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V). It consists of a loadable Kernel module, kvm.ko, that provides the core virtualization infrastructure and processor specific module.

QEMU-KVM  is a QEMU modified for use with KVM.

Using KVM, one can run multiple virtual machines running unmodified Linux or Windows images.

In this article we will discuss about installing QEMU-KVM for Slackware64 14.0. Thus, we will use:

  1. Slackware64 14.0, although any version is OK
  2. qemu-kvm 1.2.0
  3. kvm-kmod
  4. zlib libraries and headers
  5. SDL libraries and headers
  6. alsa libraries and headers (optional for alsa support)
  7. gnutls libraries and headers (optional VNC TLS support)
  8. kernel source code and headers

Also in hardware parts, you need A VT capable Intel processor, or an SVM capable AMD processor.

Downloading the Source

Most Linux distros already have KVM kernel modules and userspace tools available. However, our purpose is to build our own from scratch, so we will need the source codes. However there are some note.

The source can be obtained from Sourceforge. Download the latest qemu-kvm source code here.

Installation

Next thing to do is doing configuration and make the binary code. Remember to use enough credentials to install. We will install it to /usr/local thus need root privilege. If you plan to install it elsewhere, need to make sure you have privilege to do it.

Now invoke following command:

tar -xzf qemu-kvm-1.2.0.tar.gz
cd qemu-kvm-1.2.0
./configure --prefix=/usr/local
make
make install

If you are using kernel from http://www.kernel.org/ do not use the kvm-mod modules. Use the provided modules (which is most likely already installed).

If you are using kernel 2.6 series, you have option to compile the modules by yourself. Which, you need to download kvm-kmod with version available for your kernel.

Now, to verify the kernel, test it by invoking following command:

qemu-kvm

Congratulation! You have installed qemu.

Social media & sharing icons powered by UltimatelySocial