Using QEMU To Build and Deploy Virtual Machines (VMS) From Scratch On Ubuntu 10.04 LTS v1.2
Using QEMU To Build and Deploy Virtual Machines (VMS) From Scratch On Ubuntu 10.04 LTS v1.2
USING QEMU TO BUILD AND DEPLOY VIRTUAL MACHINES (VMS) FROM SCRATCH ON UBUNTU
10.04 LTS 2
1.0 Introduction 2
http://creativecommons.org/licenses/by-nc-sa/3.0/
A GOV Open Access Technical Academic Publications
Enhancing education & empowering people worldwide through eLearning in the 21st Century
1
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada
1.0 Introduction
QEMU is a fast processor emulator. The package currently supports arm, powerpc, sparc and x86
emulation. By using dynamic translation it achieves reasonable speed, while being easy to port to new
host CPUs. QEMU has two operating modes:
1. User mode emulation: QEMU can launch individual Linux processes compiled for one CPU on
another CPU.
2. Full system emulation: QEMU can emulate a full system, including the processor and peripherals.
This enables testing and debugging of system code in a contained (and quarantined) virtual system. It
can even be used to host several virtual machines simultaneously on a single server (given enough
host processor power and RAM).
As QEMU requires no host kernel patches to run, it is safe and easy to use. It creates a virtual machine,
similar to VMWare, Virtualbox, KVM, and Xen. It allows you to run one operating system from within
another operating system. The operating systems can be the same ones, or different. Your memory
resources will be divided between your native (host) OS and your virtual machine (guest) OS. You will,
therefore, notice a decrease in performance of activities in both the host OS and the guest OS.
Hence, if you plan to use QEMU only to create a Windows virtual environment in order to run Windows
programs, consider using one of several free Linux SoftwareEquivalents instead. If you need to run only a
single Windows program, also consider using Wine instead of QEMU. Running a virtual machine
environment such as QEMU will slow down your computer noticeably.
In this Hands-on Labs session, we’re going to lean how to install & configure virtual machines on the Linux
Ubuntu 10.04 LTS (Lucid Lynx) server option. Canonical has high hopes that Ubuntu 10.04 LTS (Long
Term Support) will easily become the platform of choice for anybody who intends to build and deploy
large-scale enterprise infrastructure deployment, whether you're trying to build the next Facebook, or the
next Google, or the next eBay. If you want to start on [Amazon's cloud-platform] EC2 and migrate to your
own managed private cloud, Ubuntu 10.04 is going to be the platform for you. Lucid Lynx will be the third
LTS release by Ubuntu. It’s based on open source Debian GNU/Linux. LTS releases arrive bi-annually
and are supported for three years on desktops and five years for servers of free security and maintenance
updates.
2
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada
Assumptions:
1. It’s assumed that you have a good understanding of Linux operating system and its working
environment. It’s also assumed that you know how to install and configure Ubuntu Linux server, if not
go ahead and pop over to scribd.com and check out a good hands-on manual entitled “Step-By-Step
Install Guide Ubuntu 10.04 LTS (Lucid Lynx) Server” to get you started.
Also consider trying a QEMU interface, such as Qemulator, or the package qemu-launcher.
Another QEMU GUI is virt-manager. It manages virtual machines not only for QEMU, but also for KVM
and Xen, in a consistent fashion (through libvirt).
Recent QEMU versions support networking out of the box. There is a "linux-test" add-on at QEMU's
site, a one-line script.
1. Download and install "qemu-kvm " Alternatively you an use "apt-get install" command:
Note: You’ll need to run the second command to avoid getting the error:
"pci_add_option_rom: failed to find romfile "pxe-rtl8139.bin"
3
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada
Note 1: If your machine has CPU with KVM capability, then you can also create your image container
as follows:
Note 2: You may need to change ownership of your image file to root user and make it writable, as
follows:
3. Now download your favorite distro, this could also be Windows OS:
wget http://mydistro.iso
wget ftp://ibiblio.org/pub/Linux/distributions/damnsmall/current/dsl-4.4.10.iso
or you can hope over and manually download Damnsmall Linux distro from here at their main site.
Note: Download the Ubuntu ISO file if you wish to install one into a virtual QEMU environment from
here: the latest development version of Ubuntu.
Step 3: VM Contextualization
1. The ISO image has the contextualization for that VM as indicated in Fig. 1.
4
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada
Fig. 1
Here:
• context.sh: contains configuration variables
• init.sh: script called by VM at start to configure specific services
• certificates: directory that contains certificates for some service
• service.conf: service configuration
Step 4: Run & Install your Distro of an Operating Systems from ISO to the QEMU Environment
We are now ready to install the guest OS. Assuming, for example, your ISO image is named
"mydistro.iso".
that is:
qemu –hda dsl-image –cdrom dsl-4.4.10.iso –m 192 –boot d
Note 2: If your machine has CPU with KVM capability, then you can also boot your image as follows:
Fig. 2
5
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada
3. If all goes well without any catastrophic error, you should see the installations process starting, as
shown in Fig. 3. Hit Enter key to continue. Alternatively, if you wait a bit, it’ll proceed on its own.
Fig. 3
Note: from here on there is no need to hit any key the installation process will continue to the end.
4. Fig. 4 shows the next sequence of screen
Fig. 4
6
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada
5. Fig. 5 shows the next sequence of screen. It’s now autoconfiguring the devices.
Fig. 5
6. Fig. 6 shows the next sequence of screen. It’s now detecting network devices & adding IP address.
Fig. 6
7
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada
7. Fig. 7 shows the next sequence of screen. It’s now at the final screen, INIT: Entering runlevel: 5.
Fig. 7
8. Fig. 8 shows the next sequence of screen. Brighten-up, things are looking good – almost there!
Fig. 8
8
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada
9. Fig. 9 shows the final screen. Hooray! – We’re at the home of Damnsmall Linux. Enjoy!
10. On the top-right-hand corner of your DSL Desktop, you can monitor your system performance, also
see Fig. 10.
Fig. 10
9
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada
Fig. 11
2. Double-click on the Exit icon on the left side of the Desktop, to open the DSL Exit Options
dialog box, as shown in Fig. 12.
Fig. 12
Note: here you have the option to Shutdown, Reboot or Exit to Prompt. You also have the option to
Backup your system just in case things goes disastrous wrong!
3. Select Shutdown option and click OK to exit. Alert windows will pop-up as shown in Fig. 13. Click
Close to finally exit.
10
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada
Fig. 13
4. If all went well, you should be able to start your image again with the following command:
Note 1: If your machine has CPU with KVM capability, then you can also run your image as follows:
5. We’re done with this section and also the lab session
1. First check that your server meets the full hardware virtually capability (HWM), run:
Note: if you get no response, then your system does not meet HWM requirements. For deataisl on
how to set this, checkout: http://blogs.sun.com/VirtualGuru/entry/part_6_quad_core_workstations
11
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada
Fig. 14
12
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada
Call us today:
Email: [email protected]. URL: www.globalopenversity.org
http://releases.ubuntu.com/8.04/ubuntu-8.04.4-desktop-i386.iso
3. Install and configure a LAMP on your VM
4. Install and configure a second VM and set it up as data backup server.
References
1. Complete Guide to Ubuntu Tools - http://ubuntuguide.org/wiki/Ubuntu:Lucid#Xen
2. Xen 4_0_1 on Ubuntu Lucid 10_04 - Desktop - Server - 64 Bits - With OpenGL (Intel GEM) enabled -
From Linuxcon Brazil! -D Xen Users: http://www.gossamer-threads.com/lists/xen/users/184152
3. Ubuntu How: Install Xen: http://mediakey.dk/~cc/ubuntu-howto-install-xen/
4. cloud computing « Akash's Weblog: http://aakash19.wordpress.com/category/open-source-
technologies/cloud-computing/
5. XEN « Make something Software Engineering to Cooking: http://mulps.wordpress.com/tag/xen/
13
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada
-----------------------------------------------
Kefa Rabah is the Founder of Global Technology Solutions Institute. Kefa is knowledgeable in several
fields of Science & Technology, Information Security Compliance and Project Management, and
Renewable Energy Systems. He is also the founder of Global Open Versity, a place to enhance your
educating and career goals using the latest innovations and technologies.
Note: This hands-on lab manual was written in reference to information sourced from:
Ubuntu Documentation: InstallationQemuEmulator:
https://help.ubuntu.com/community/Installation/QemuEmulator. Under the: Creative Commons
Attribution-ShareAlike 3.0 License.
14
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada