You are on page 1of 5

# LinuxCBT KVM Edition #

Features:
1. Kernel-based Virtual Machine (KVM)
2. http://linux-kvm.org - for more information
3. Extends the kernel via:
a. kvm.ko - core module regardless of platform (x86(32-bit) || amd64(64-bit)) -
allows kernel to become Hypervisor
Note: With KVM, we retrofit || modify existing kernel to become a hypervisor
4. Provides the following:
b. Exposes: '/dev/kvm' - for usage by HOST manager (typically: QEMU - provides
emulated environment)
c. Requires processor with virtualization extensions: Intel-VT || AMD-V(SVM)
Note: Intel-VT || AMD-V(SVM) accelerate virtualization of guests - improves
performance
Note: It may be necessary to enable hardware virtualiztion via system bios
(possibly disabled by default)
5. Included in mainline kernel since: 2.6.20 - basically included in ALL Linux
distributions over the past couple years
6. Backporting of KVM for < 2.6.20 kernels is possible but ill-advised
7. Supports common GUESTs:
a. Linux
b. BSD
c. Windows
8. Supports following bit configurations:
a. 32 | 64-bit support
b. If HOST = 32-bit, then it may host 32-bit GUESTs
c. If HOST = 64-bit, then it may host: 32 | 64-bit GUESTs
Note: If double-virtualizing, ensure that HOST hypervisor is configured to allow
64-bit flow-through:
i.e. with VMWare ESXi, typically: 'vhv' support must be set to true on a per HOST
basis
Note: If possible, dedicated hardware exclusively to KVM
d. Up to 16-CPUs for GUESTs
e. Up to 160-CPUs for HOST
Note: Based on current (Spring 2014) KVM specs - subject to increases
Note: Despite ubiquitous availability of ample hardware, heavy LAMP workloads
require litte in terms of: CPU, RAM, Storage
Note: Windows introduces an exception in that it is RAM-hungry

9. Various Management GUIS exist: 'virt-manager'(VMM), ConVirt, KIMICHI, OpenNode,


etc.
Note: These management tools support 'libvirt' and often other hypervisors: i.e.
Xen
10. QEMU - user-space tools for - HOSTs - CLI
11. Cloning of VMs (GUESTs) - 'virt-clone'
12. Importation of foreign VMs: i.e. Xen, VMware, etc. - 'virt-convert'
13. Live migration of GUESTs - from HOST-a to HOST-b
14. Snapshots
15. Paravirtualization of:
a. Networking
b. Block devices
c. Graphics
d. Memory
Note: Supported on: Linux, BSD, and Windows GUESTs
Note: Paravirtualization can considerably improve performance
16. Support for NAT (Default) of GUEST's network - provides outbound access only
17. Support for Bridges (public(ALL) & private(intra-VM(GUEST) communications))
18. Environment maintained in: '/var/lib/libvirt' tree
a. INcludes ISO images for installation, VM images, network configuration, etc.

# KVM Installation #

Tasks:
1. Confirm Virtualization support
a. 'egrep '(vmx|svm)' /proc/cpuinfo'
Note: .170 reveals support, .171 does NOT. Debug via ESXi

2. Install
a. 'sudo aptitude install qemu-kvm'
b. 'dpkg -l | grep qemu'
c. 'lsmod' - confirm: 'kvm.ko' && 'kvm_intel.ko' are loaded
3. Explore environment
a. 'dpkg -L qemu-common' - various BIOS and network scripts
b. 'dpkg -L qemu-utils' - Network Block Device (NBD) 'qemu-nbd' && image utility
'qemu-img'
c. 'dpkg -L bridge-utils' - provides bridges to physical interfaces

3. Bridge Configuration - required to provide autonomous network access per GUEST


'/etc/network/interfaces'
Re-configure 'eth0' to resemble the following to enable bridging:
'
auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
address 192.168.75.170
netmask 255.255.255.0
gateway 192.168.75.1
dns-nameservers 192.168.75.101 192.168.75.1
#Bridge Configuration
bridge_ports eth0
bridge_stp off
bridge_maxwait 0
bridge_fd 0
'

b. 'invoke-rc.d networking restart && ifconfig'

Note: Ensure that 'uname -a' returns 'x86_64' or 'amd64' - otherwise, support for
64-bit GUESTs will be disabled

4. Install 'virt-manager' - GUI to manage KVM GUESTs - Installs various


dependencies - http://virt-manager.org
Note: Default connection is made to local QEMU instance: i.e. 'qemu:///system'
a. 'sudo aptitude install virt-manager'
b. 'dpkg -L virt-manager'
c. 'dpkg -L virt-inst' - installs and clones VMs - provides: 'virt-install',
'virt-clone', 'virt-image', 'virt-convert'
Note: 'virt-inst' package is a key CLI package providing the life-cycle of VM
management tools

# VM Deployment #
Tasks:
1. '/etc/libvirt' - config files
2. '/var/lib/libvirt' - main container of VMs and associated files
a. '/var/lib/libvirt/images' - contains VM images and optionally ISO images for
installation
Note: Like other Hypervisors, VM images may be stored anywhere there is ample
storage: i.e. LVM, raw device, NFS, SAN, NAS, etc.
b. '/var/lib/libvirt/network/default.xml' - Default 'NAT' network for GUESTs
using NAT instead of briding: 192.168.122.0/24 with .1 as the routed (NATed)
interface and available addresses of: .2 -> .254

3. Launch and explore 'virt-manager'


a. simple interface: 'ssh -X root@192.168.75.170'
b. 'virt-manager'
Note: 'ifconfig' - reveals: 'virbr0' interface - NATed interface
Note: Ensure that default: /var/lib/libvirt/images has sufficient storage for
desired GUESTs. Otherwise, add other storage pools

4. Install Ubuntu 12.04 LTS


a. ISO Image - Sync from available source (VMWare ESXi instance)
b. Install system with sensible options
c. confirm installation

5. Post-installation
a. Confirm IP settings (DHCP=default)
b. Update IP config
c. Communicate in and out

6. Install 'virt-top' on KVM instance


a. 'aptitude install virt-top' - CLI top-like stats of VMs

7. Install 'virt-manager' on client system: linuxcbtubudesk2 - for across-the-wire


(via SSH) QEMU-KVM access
a. 'aptitude install virt-manager'
b. 'ssh-copy-id root@192.168.75.170' - this facilitates passwordless AUTH to
remote system, including via: 'virt-manager'

8. Install RHEL 6.5 via HTTP


a. Copy ISO image
b. Mount ISO image so full tree is exposed via HTTP

9. Repeat process for CentOS

10. Debug as needed

11. Deploy Windows


a. Ensure that new KVM instance is properly configured
a1. ensure 'vmx|svm' support
a2. ensure ample resources: mem, cpu, disk
a3. Install 'qemu-kvm'
a4. Mirror bridge information from: linuxcbtkvm1 using 'ssh'
a5. confirm 'kvm' modules: 'lsmod | grep kvm'
a6. Install 'virt-manager'
a7. Setup passwordless AUTH between client (linuxcbtubudesk2) and server
(linuxcbtkvm2)
a8. Ensure client has '/etc/hosts' entries for name resolution
a9. Copy Windows ISO(s) to 'linuxcbtkvm2'

b. Connect with: 'virt-manager' from client and deploy OS


b1. Install Windows 7
Note: Each VM is tied to distinct virtual interface: 'vnet#' : i.e. 'vnet0-N' -
typically tied to the same bridge

b2. confirm various settings: i.e. 'virt-top', 'ifconfig',


'/var/lib/libvirt/images', etc.

b3. Install Win2k12 using Win2k8 profile

Win2k12 does NOT install - kill - remove .img reference

# 'virt-install' - CLI tool #


Features:
1. Automation & rapid deployment of VMs (GUESTs)
2. Auto-launches 'virt-viewer' (if available) post-provision || must launch 'virt-
manager' to manage the newly provisioned node (GUEST)
3. Saves time allowing us to indicate ALL options on CLI
Note: 'virt-install' does NOT complete the OS installation, but rather preps to
bootstrap the installer
Note: 'virt-install' is merely a powerful CLI replacement for 'virt-manager' GUI
for provisioning new VMs(GUESTs) - not for other management functions

Tasks:
1. Install 'virt-viewer'

2. Use 'virt-install' to deploy VMs


a. 'virt-install --connect qemu:///system --virt-type kvm --name linuxcbtkvmubu2
--description "Second Ubuntu Instance" --vcpus=1,maxvcpus=2 --ram 1024 --disk
/var/lib/libvirt/images/linuxcbtkvmubu2.img,size=4 --graphics vnc
--cdrom=/var/lib/libvirt/images/ubuntu-12.04.2-server-amd64.iso --os-type=linux
--os-variant=ubuntuprecise -w bridge=br0'

b. Repeat for CentOS|RedHat


b1. 'virt-install --connect qemu:///system --virt-type kvm --name
linuxcbtkvmcent2 --description "Second RedHat Instance" --vcpus=1,maxvcpus=2 --ram
1024 --disk /var/lib/libvirt/images/linuxcbtkvmcent2.img,size=4 --graphics vnc -l
http://192.168.75.101/centos6.5 --os-type=linux --os-variant=rhel6 -w bridge=br0'
b2. Debug and replace: '-c' with '-l URL_TO_OS_TREE'

c. Ensure that ALL nodes auto-start during bootup of Hypervisor

# 'virt-clone' - CLI Tool #


Features:
1. GUI option - 'virt-manager'
2. CLI option - 'virt-clone'
Note: Clones will be identical in terms of OS settings to SOURCE - configuration
changes are necessary
Note: For default clones, boot cloned image first, make changes, then boot SOURCE
to avoid network conflicts, in particular when using static IP assignments. If
using DHCP, this is less of a concern largely due to unique assignment of MAC
address to new clones

Tasks:
1. Clone via GUI
a. 'virt-manager' - shut SOURCE then clone then boot TARGET and configure

2. Clone via CLI


a. 'sudo virt-clone --auto-clone [-n NAME] -o ORIGINAL_VM(GUET)'
a1. 'sudo virt-clone --auto-clone -n linuxcbtkvmwin2 -o linuxcbtkvmwin1'

Note: For performance normalities, dedicated hardware to distinct KVM instances.


Try not to double-virtualize

You might also like