There are CPUs with and without virtualization support. To find whether the CPU you work with supports virtualization, run this command:
egrep '(vmx|svm)' /proc/cpuinfo
If it returns anything, the CPU you are using supports virtualization. However even if this is the case, virtualization support may be disabled at BIOS level.
If your computer has a CPU that supports virtualization and you don’t mind messing with BIOS switches, you would be better off if you use KVM or Xen for virtualization. Those solutions make use of the hardware virtualization support and as a result the guest OSs are almost as fast as if they were running without virtualization on a bare metal. If you expect to use the guest OS for any sort of “heavylifting” (e.g. running a build process), you should better use hardware that supports virtualization. You can find instructions on how to install KVM in this my post.
However there are many cases when you can use virtualization without hardware support. For example, you have a computer with x86 CPU architecture and you want to develop for a device which uses CPU with ARM or Atom architecture. Or you want to do something which can break the OS you are experimenting with. And so on. For such cases I would recommend using QEMU emulator. It allows emulating computers with various CPU architectures on x86 host system. It also provides a number of virtual devices. Besides this it uses a number of techniques to make the emulation faster; sometimes the execution speed is even close to what KVM virtualization provides.
QEMU is broadly used, it is a sort of standard de-facto. In fact, KVM uses QEMU virtual machines as well. Another example is Android device emulator. It uses QEMU “under the hood”.
Overall, QEMU is quite amazing piece of software if we consider complexity of the task it performs. It was developed initially by Fabrice Bellard, who is quite remarkable individual as well in my opinion. You can read a good overview of QEMU and its history here.
I have an old 2005 computer running Ubuntu Linux 9.04 which does not have hardware virtualization support; the steps described below were performed on that computer.
A “crash course” on qemu can be found here.
First install QEMU:
sudo apt-get install qemu
If you are planning to run guest OS with x86 architecture on x86 host system, I highly recommend you installing QEMU accelerator. It increases the speed of QEMU emulation when a PC is emulated on a PC. It does it by running most of the target application code directly on the host processor to achieve near native performance. It is very useful when you want to run another x86 OS (for example Windows) on a Linux desktop. The accelerator is optional and it is not installed as a dependency for qemu package. You have to install it explicitly:
sudo apt-get install kqemu-common
If you are going to provide network access for the virtual machine, you have to install bridge-utils package. Its description says:
This package contains utilities for configuring the Linux Ethernet bridge in Linux 2.4 or later. The Linux Ethernet bridge can be used for connecting multiple Ethernet devices together. The connecting is fully transparent: hosts connected to one Ethernet device see hosts connected to the other Ethernet devices directly.
Type this:
sudo apt-get install bridge-utils
Enabling network connectivity requires certain additional steps. Please look at this post, sections Configuring network access and Troubleshooting.
You can also add recommended packages:
sudo apt-get install ubuntu-vm-builder qemu-kvm-extras
ubuntu-vm-builder is a script which automates the process of creating a ready to use VM based on Ubuntu. You can pass command line options to add extra packages, remove packages, choose which version of Ubuntu, which mirror to use etc.
qemu package contains only x86 CPU support as a default option. If you need yo emulate computers with other CPU architectures, you need to install qemu_kvm_extras. The package supports ARM, CRIS, i386, M68k (ColdFire), MIPS, PowerPC, SH4, SPARc and x86-64 emulation. It uses so-called dynamic translation of executed binaries and improves execution speed substantially when you execute non-x86 code on x86 machine. You can find more about QEMU dynamic translation here.
To see what architectures are supported, type this:
ls -l /usr/bin/qemu*
You should see something like this as a result:
-rwxr-xr-x 1 root root 1824540 2011-02-11 19:28 /usr/bin/qemu -rwxr-xr-x 1 root root 741992 2011-02-11 19:28 /usr/bin/qemu-alpha -rwxr-xr-x 1 root root 1032764 2011-02-11 19:28 /usr/bin/qemu-arm -rwxr-xr-x 1 root root 1036860 2011-02-11 19:28 /usr/bin/qemu-armeb -rwxr-xr-x 1 root root 479604 2011-02-11 19:28 /usr/bin/qemu-cris -rwxr-xr-x 1 root root 902284 2011-02-11 19:28 /usr/bin/qemu-i386 -rwxr-xr-x 1 root root 270 2011-02-11 18:46 /usr/bin/qemu-ifdown -rwxr-xr-x 1 root root 138 2011-02-11 18:46 /usr/bin/qemu-ifup -rwxr-xr-x 1 root root 177860 2011-02-11 19:28 /usr/bin/qemu-img -rwxr-xr-x 1 root root 186080 2011-02-11 19:28 /usr/bin/qemu-io -rwxr-xr-x 1 root root 663924 2011-02-11 19:28 /usr/bin/qemu-m68k -rwxr-xr-x 1 root root 913896 2011-02-11 19:28 /usr/bin/qemu-mips -rwxr-xr-x 1 root root 913896 2011-02-11 19:28 /usr/bin/qemu-mipsel -rwxr-xr-x 1 root root 173796 2011-02-11 19:28 /usr/bin/qemu-nbd -rwxr-xr-x 1 root root 1521992 2011-02-11 19:28 /usr/bin/qemu-ppc -rwxr-xr-x 1 root root 2281576 2011-02-11 19:28 /usr/bin/qemu-ppc64 -rwxr-xr-x 1 root root 2264844 2011-02-11 19:28 /usr/bin/qemu-ppc64abi32 -rwxr-xr-x 1 root root 553428 2011-02-11 19:28 /usr/bin/qemu-sh4 -rwxr-xr-x 1 root root 553428 2011-02-11 19:28 /usr/bin/qemu-sh4eb -rwxr-xr-x 1 root root 704840 2011-02-11 19:28 /usr/bin/qemu-sparc -rwxr-xr-x 1 root root 1048912 2011-02-11 19:28 /usr/bin/qemu-sparc32plus -rwxr-xr-x 1 root root 1086124 2011-02-11 19:28 /usr/bin/qemu-sparc64 -rwxr-xr-x 1 root root 2119672 2011-02-11 19:28 /usr/bin/qemu-system-arm -rwxr-xr-x 1 root root 1145884 2011-02-11 19:28 /usr/bin/qemu-system-cris -rwxr-xr-x 1 root root 1289116 2011-02-11 19:28 /usr/bin/qemu-system-m68k -rwxr-xr-x 1 root root 1828124 2011-02-11 19:28 /usr/bin/qemu-system-mips -rwxr-xr-x 1 root root 1963292 2011-02-11 19:28 /usr/bin/qemu-system-mips64 -rwxr-xr-x 1 root root 1959200 2011-02-11 19:28 /usr/bin/qemu-system-mips64el -rwxr-xr-x 1 root root 1824028 2011-02-11 19:28 /usr/bin/qemu-system-mipsel -rwxr-xr-x 1 root root 2260536 2011-02-11 19:28 /usr/bin/qemu-system-ppc -rwxr-xr-x 1 root root 2794492 2011-02-11 19:28 /usr/bin/qemu-system-ppc64 -rwxr-xr-x 1 root root 2272828 2011-02-11 19:28 /usr/bin/qemu-system-ppcemb -rwxr-xr-x 1 root root 1249368 2011-02-11 19:28 /usr/bin/qemu-system-sh4 -rwxr-xr-x 1 root root 1249372 2011-02-11 19:28 /usr/bin/qemu-system-sh4eb -rwxr-xr-x 1 root root 1373404 2011-02-11 19:28 /usr/bin/qemu-system-sparc -rwxr-xr-x 1 root root 1748348 2011-02-11 19:28 /usr/bin/qemu-system-sparc64 -rwxr-xr-x 1 root root 2025544 2011-02-11 19:28 /usr/bin/qemu-system-x86_64 -rwxr-xr-x 1 root root 1136420 2011-02-11 19:28 /usr/bin/qemu-x86_64
Quite impressive, isn’t it?
At this point you are ready to run a guest OS as VM using QEMU.
You can download a number of pre-built OS images from here (we’ll discuss creating and managing images in another post). Let’s use a small Linux image for testing our QEMU installation. Type this to download the image:
curl http://wiki.qemu.org/download/linux-0.2.img.bz2 >linux-0.2.img.bz2
(if you don’t have curl install it by typing sudo apt-get install curl or just download the file using e.g. a browser; whatever works for you will do).
Decompress it:
bzip2 -d linux-0.2.img.bz2
Launch qemu:
qemu linux-0.2.img
After this you should see VM console window; something like this:
You can use it as a regular Linux machine console. Type this for example:
ls -al /
and you will see filesystems mounted on the VM:
Later in other posts we are going to look at creating and managing QEMU VM images and troubleshooting.
That’s all for now.
Thanku for the above info.
Have you tried using qemu-system-sparc64?
I need help with this Qemu application.
Thankyou
Lalitha,
No, I haven’t used qemu-system-sparc64, unfortunately.
Hi,
Thank you for the info. Where can I find your next article about “creating and managing QEMU VM images and troubleshooting”? Thank you.
Sorry, I haven’t been able to return to the topic 😦