---
# KVM Virtualization 101

**URL:** https://crunchtools.com/kvm-virtualization-101/
Date: 2010-09-20
Author: fatherlinux
Post Type: post
Summary: Background For those of you who are familiar with virtualization, KVM is a hypervisor which is built into the Linux Kernel. This allows a Linux desktop or server to simulate multiple pieces of hardware, which can then have different operating systems installed. KVM uses the QEMU virtual machine format. QEMU may be familiar to thoseContinue Reading "KVM Virtualization 101" →Continue Reading "KVM Virtualization 101" →
Categories: Articles
Tags: Systems Administration, Tutorials, Virtualization
---

[toc]

## Background

For those of you who are familiar with virtualization, [KVM](http://www.linux-kvm.org/page/Main_Page) is a hypervisor which is built into the Linux Kernel. This allows a Linux desktop or server to simulate multiple pieces of hardware, which can then have different operating systems installed. KVM uses the [QEMU](http://en.wikipedia.org/wiki/QEMU) virtual machine format. QEMU may be familiar to those of you who have used video game emulators. KVM is essentially an advanced CPU emulator built into the Linux kernel.

 

## Basics

### Installation

To install kvm on Red Hat Enterprise 5.4 or above box use the following. This will install all of the necessary software to use KVM

`yum install @kvm`

 

To install kvm on a Fedora use the following. This will install all of the necessary software to use KVM and many utilities

`yum install @Virtualization`

 

### Create New Virtual Machines

The fastest and easiest way to use KVM is using virt-manager. From the command line run the following. This program allows you to connect to hypervisors on the local system and can connect to hypervisors on other physical machines using ssh. The virt-manager program has several wizards for creating virtual machines which should be easy to use for anyone familiar with [VMware](http://www.vmware.com) or [VirtualBox](http://www.virtualbox.org/) `virt-manager`

 

### Convert from VMware Virtual Machines

Another way to create virtual machines is to convert them from VMware images. The directory in the command below includes the VMware **.vmx** file and all the **.vmdk** referenced in the **.vmx** file.

`virt-convert -i vmx -o virt-image scott-vmx/ scott-kvm/`

 

*Remember*: VMware images must first be converted to a single file, pre-allocated disk format. Also the **.vmx** file must be changed to match the new names of the **.vmdk** files, or the files must be renamed back to the original name. The vmware-vdiskmanager utility cannot convert disks in place. This must be done on the VMware server before it is moved to the KVM server.

`vmware-vdiskmanager -r scott.vmdk -t 2 scott-padf.vmdk`

 

Now, it is time to make the newly imported virtual machine recognized by the KVM hypervisor

`virt-image scott-kvm/scott.virt-image.xml`

 

### Basic Commands

To list all of the virtual machines which are running on a system use virsh

`virsh list`

 

It is a good idea to backup the configuration for any virtual machines that are created in a format that is easy to import later. I normally save this virsh XML to a file in the directory with the virtual machine. This keeps everything together just like a VMware virtual machine.

`virsh dumpxml > scott-kvm/scott.xml`

 

Finally, once a machine is defined and running, it is a good idea to make it autostart on boot if desired. Notice that the files that are created and removed from **/etc/libvirt/qemu/autostart**

`virsh autostart scott`

 

### Experiment

Once you have backed up the configuration for one of your new virtual machines, try to remove it and re-add it with the virsh *define* and *undefine* commands

`virsh undefine scott`

 

Now look at your list of virtual mchines

`virsh list`

 

Redefine the machine using your backed up XML file

`virsh define scott-kvm/scott.xml `

 

Now look at your list of virtual mchines again

`virsh list`

 

---

## Categories

- Articles

---

## Navigation

- [Home](https://crunchtools.com/)
- [Articles](https://crunchtools.com/category/articles/)
- [Events](https://crunchtools.com/category/events/)
- [News](https://crunchtools.com/category/news/)
- [Presentations](https://crunchtools.com/category/presentations/)
- [Software](https://crunchtools.com/software/)
- [Beaver Backup](https://crunchtools.com/software/beaver-backup/)
- [Check BGP Neighbors](https://crunchtools.com/software/check-bgp-neighbors-nagios/)
- [Chev](https://crunchtools.com/software/chev-check-vulnerabilities-script/)
- [Graph BGP Neighbors](https://crunchtools.com/software/grpah-bgp-neighbors/)
- [Graph MySQL Stats](https://crunchtools.com/software/graph-mysql-stats/)
- [Graph Sockets Pipes Files](https://crunchtools.com/software/graph-sockets-pipes-files/)
- [MCP Servers](https://crunchtools.com/software/mcp-servers/)
- [Petit](https://crunchtools.com/software/petit/)
- [Racecar](https://crunchtools.com/software/racecar/)
- [Shiva](https://crunchtools.com/software/shiva/)
- [About](https://crunchtools.com/about/)
- [Home](https://crunchtools.com)

## Tags

- Systems Administration
- Tutorials
- Virtualization