Anda di halaman 1dari 14

GOV Cloud Comp Labs Using QEMU to Build a Virtual Machine from Scratch on Ubuntu 10.04 LTS v1.

Global Open Versity


Cloud Computing Hands-on Labs Training Manual

Using QEMU to Build a Virtual Machine (VM) from Scratch on


Ubuntu 10.04 LTS
Kefa Rabah
Global Open Versity, Vancouver Canada
krabah@globalopenversity.org
www.globalopenversity.org

Table of Contents Page No.

USING QEMU TO BUILD A VIRTUAL MACHINE (VM) FROM SCRATCH ON UBUNTU 10.04 LTS 2

1.0 Introduction 2

Hands-On Labs Session 3

Part 1: Using QEMU to create VM locally on UI: 3


Step 1: Install Pre-requisite Packages 3
Step 2: Preparation of the QEMU Virtual Environment 4
Step 3: VM Contextualization 4
Step 4: Run & Install your Distro of an Operating Systems from ISO to the QEMU Environment 5
Step 5: Shutdown the your DSL Virtual Machine 10

Part 2: Troubleshooting VM Installation “pxe-rtl8139.bin” Error 11

Part 3: Need More Training on Linux: 12


Ubuntu Server Administration Training 12

Part 4: Hands-on Labs Assignments 12

Other Related Articles & Hands-on Lab Manuals References: 12

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

www.globalopenversity.org High Performance Computing Labs


GOV Cloud Comp Labs Using QEMU to Build a Virtual Machine from Scratch on Ubuntu 10.04 LTS v1.0

Global Open Versity


Cloud Computing Hands-on Labs Training Manual

Using QEMU to Build a Virtual Machine (VM) from Scratch


on Ubuntu 10.04 LTS

By Kefa Rabah, krabah@globalopenversity.org Aug 15, 2010 GTI Institute

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

www.globalopenversity.org High Performance Computing Labs


GOV Cloud Comp Labs Using QEMU to Build a Virtual Machine from Scratch on Ubuntu 10.04 LTS v1.0

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.

Hands-On Labs Session


In this Hands-on manual, you will learn build from scratch a virtual machine and how to setup and install it
on Ubuntu 10.04 LTS (Lucid Lynx). Upon completion of this hands-on lab session you should have gained
expertise and skills to plan design implement and deploy your own virtual machines on Linux Ubuntu
10.04 LTS server. You could put your virtual machine for all kind of uses: Data storage & backup, web
server, database server etc. You can use this knowledge to build VM for cloud computing e.g., when
building your own cloud using OpenNebula cloud computing.

Part 1: Using QEMU to create VM locally on UI:


Why use an emulator? - QEMU emulates everything, including the CPU, so it is slower than the host
system. Hardware acceleration will not be as effective for a software OS emulator. Nevertheless, it is a
pretty good way of testing a distribution, without having to repartition your drive or set up new hardware

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).

Step 1: Install Pre-requisite Packages


QEMU is available as a standard package in the Universe repository. (There are on how to install
packages elsewhere in this guide. Unlike some other virtualization systems (like VMWare), separate
kernel modules are not needed.

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:

sudo apt-get install qemu-kvm –y

sudo apt-get install aptitude kvm-pxe –y

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

www.globalopenversity.org High Performance Computing Labs


GOV Cloud Comp Labs Using QEMU to Build a Virtual Machine from Scratch on Ubuntu 10.04 LTS v1.0

Step 2: Preparation of the QEMU Virtual Environment


1. A virtual disk is needed for the virtual machine. A virtual disk is made by creating a file of a size
appropriately large to contain the full guest OS.

2. Let’s create a clean “Hard disk” as follows:

qemu-img create mydistro.img 3G

Note 1: If your machine has CPU with KVM capability, then you can also create your image container
as follows:

sudo qemu-img create -f qcow2 mydistro.img 10G

Note 2: You may need to change ownership of your image file to root user and make it writable, as
follows:

sudo chown root:root disk.img


sudo chmod 755 disk.img

3. Now download your favorite distro, this could also be Windows OS:

wget http://mydistro.iso

4. In this lab session, we’re going to use Damnsmall Linux distro:

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.

5. Let’s create a clean “Hard disk” as follows:

qemu-img create dsl-image.img 3G

6. You’re done with this section.

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

www.globalopenversity.org High Performance Computing Labs


GOV Cloud Comp Labs Using QEMU to Build a Virtual Machine from Scratch on Ubuntu 10.04 LTS v1.0

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

2. You’re done with this section.

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".

1. Then you can boot it with a virtual cdrom attached as follows:

qemu –hda mydistro-image –cdrom mydistro.iso –m 192 –boot d

that is:
qemu –hda dsl-image –cdrom dsl-4.4.10.iso –m 192 –boot d

Note 1: Alternatively, run this command before starting the emulator:

sudo /sbin/ifconfig eth0 172.20.0.1

Note 2: If your machine has CPU with KVM capability, then you can also boot your image as follows:

sudo kvm -hda dsl-image -cdrom dsl-4.4.10.iso -m 1024 -boot d

2. The Command-line instruction and pre-bootup is shown in Fig. 2.

Fig. 2

5
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada

www.globalopenversity.org High Performance Computing Labs


GOV Cloud Comp Labs Using QEMU to Build a Virtual Machine from Scratch on Ubuntu 10.04 LTS v1.0

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

www.globalopenversity.org High Performance Computing Labs


GOV Cloud Comp Labs Using QEMU to Build a Virtual Machine from Scratch on Ubuntu 10.04 LTS v1.0

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

www.globalopenversity.org High Performance Computing Labs


GOV Cloud Comp Labs Using QEMU to Build a Virtual Machine from Scratch on Ubuntu 10.04 LTS v1.0

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

www.globalopenversity.org High Performance Computing Labs


GOV Cloud Comp Labs Using QEMU to Build a Virtual Machine from Scratch on Ubuntu 10.04 LTS v1.0

9. Fig. 9 shows the final screen. Hooray! – We’re at the home of Damnsmall Linux. Enjoy!

Fig. 9: Damnsmall Linux Desktop.

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

www.globalopenversity.org High Performance Computing Labs


GOV Cloud Comp Labs Using QEMU to Build a Virtual Machine from Scratch on Ubuntu 10.04 LTS v1.0

11. Browse the Internet etc. as shown in Fig. 11.

Fig. 11

12. You’re done with this section.

Step 5: Shutdown the your DSL Virtual Machine


1. After you've finished installing, it’s important that shutdown properly.

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

www.globalopenversity.org High Performance Computing Labs


GOV Cloud Comp Labs Using QEMU to Build a Virtual Machine from Scratch on Ubuntu 10.04 LTS v1.0

Fig. 13

Note: Uncheck Backup from Fig. 9 and click OK to exit.

4. If all went well, you should be able to start your image again with the following command:

qemu –had dsl-image –cdrom dsl-4.4.10.iso –m 192

Note 1: If your machine has CPU with KVM capability, then you can also run your image as follows:

sudo kvm -no-acpi -hda dsl-image -m 1024

5. We’re done with this section and also the lab session

Part 2: Troubleshooting VM Installation “pxe-rtl8139.bin” Error


1. If during the installation of your distro image you get the following error:

"pci_add_option_rom: failed to find romfile "pxe-rtl8139.bin"

as shown in Fig. 14.

Fig. 14

Then issue the command:

sudo apt-get install aptitude kvm-pxe –y

and all should be good to go.

2. You’re done with this section.

11
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada

www.globalopenversity.org High Performance Computing Labs


GOV Cloud Comp Labs Using QEMU to Build a Virtual Machine from Scratch on Ubuntu 10.04 LTS v1.0

Part 3: Need More Training on Linux:


Are you having trouble understanding or comprehending the working of Linux distros, if so, then check out
some of our introductory and advance courses on Linux at: Global Open Versity, Vancouver Canada.

Ubuntu Server Administration Training


You can now register and take our superb Ubuntu Server Administration Training course, covering Ubuntu
10.04 LTS, EHCP and ISPConfig ISP hosting solutions, RESTORE backup, EJBCA PKI and DTC
GPLHost Control Panel solutions and many more…

• ICT105 - Ubuntu Server Administration Training

Call us today:
Email: info@globalopenversity.org. URL: www.globalopenversity.org

Part 4: Hands-on Labs Assignments


1. Install and configure Ubuntu 10.04 LTS (Lucid Lynx) Server from a clean install

2. Install and configure a virtual machine using Ubuntu 8.04.4 LTS (Hardy Heron) ISO. Get it from here:
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.

Other Related Articles & Hands-on Lab Manuals References:


1. Build & Deploy a Private Cloud Using OpenNebula Cloud Computing v1.0
2. Step-By-Step Install Guide eyeOS Cloud Computing Operating System
3. Build your Own Private Cloud using Ubuntu 10.04 Eucalyptus Enterprise Cloud Computing
Platform
4. Build & Deploy Desktop Personal Cloud using eyeOS Cloud Computing Operating System on
Linux v1.0
5. Using Webmin and Bind9 to Setup DNS Server on Linux
6. Build your own ISP Hosting using EHCP on Ubuntu 10.04 LTS Server
7. Build your own ISP Hosting using ISPConfig on Ubuntu Server v1.0
8. Step-By-Step Install Guide DTC on Linux CentOS5 Server v1.0
9. Install Guide Secure Sendmail with Dovecot & Roundcube Webmail v1.0
10. Build your Own Private Data Center Backup Solutions using Ubuntu Powered RESTORE Backup
Server v1.0
11. Install Guide IPCop Firewall for Network Security with Spam and Virus Protection
12. Install & Setup Astaro Security Gateway to Protect Corporate Network v1.1

12
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada

www.globalopenversity.org High Performance Computing Labs


GOV Cloud Comp Labs Using QEMU to Build a Virtual Machine from Scratch on Ubuntu 10.04 LTS v1.0

Linux Administration Training


Make a smart move, its time you reconfigure your skill-sets and move your career into the fastest moving
high tech gravy train of the Linux Open Source world, join our Linux program today:

• Linux Enterprise Infrastructure Engineering Diploma – ICT202

-----------------------------------------------
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.

Fellow us on Twitter: Global Open Versity and Kefa Rabah

A GOV Open Access Technical Academic Publications


Enhancing education & empowering people worldwide through eLearning in the 21st Century

13
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada

www.globalopenversity.org High Performance Computing Labs

Anda mungkin juga menyukai