Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
linux_wiki:kernel-based_virtual_machine_kvm [2015/02/13 21:46] billdozor |
linux_wiki:kernel-based_virtual_machine_kvm [2016/03/18 23:18] billdozor [Kernel-based Virtual Machine (KVM)] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Kernel-based Virtual Machine (KVM) ====== | ====== Kernel-based Virtual Machine (KVM) ====== | ||
- | Description: | + | **General Information** |
- | Assumption: Some Red Hat based distro | + | KVM is "a full virtualization solution for Linux on x86 hardware containing virtualization extensions." |
- | 2015-02-13: These are rough notes and in progress as I learn KVM. | + | **Checklist** |
+ | * Distro(s): Enterprise Linux 6 | ||
+ | * Other: This page was written using CentOS 6.6 with GNOME desktop (headless KVM is on the to do list!) | ||
+ | * 2015-02-13: These are rough notes and in progress as I learn KVM. | ||
- | ===== Installation ===== | + | ---- |
+ | |||
+ | ====== Installation | ||
- | * Install: Virtualization | + | ==== Install: |
<code bash> | <code bash> | ||
- | yum groupinstall " | + | yum install qemu-kvm python-virtinst virt-top libvirt libvirt-client |
</ | </ | ||
- | **Group Explanations** | + | **CLI Package |
- | This will install the following | + | * qemu-kvm => The main KVM package. |
- | * Virtualization Tools => Tools for offline virtual image management. | + | * python-virtinst |
- | * Virtualization Platform | + | * virt-top |
- | * Virtualization Client | + | * libvirt |
- | * Virtualization | + | * libvirt-client |
- | For detailed info and a list of packages that will be installed: | + | ==== Install: Optional Virtualization Packages (GUI) ==== |
<code bash> | <code bash> | ||
- | yum groupinfo " | + | yum install virt-manager virt-viewer |
</ | </ | ||
- | | + | **GUI Package Explanations** |
+ | * virt-manager => GUI VM administration tool. | ||
+ | * virt-viewer => GUI local console connection to VMs. | ||
+ | |||
+ | |||
+ | ==== Install: | ||
<code bash> | <code bash> | ||
yum install bridge-utils dejavu-lgc-sans-fonts tigervnc xorg-x11-xauth | yum install bridge-utils dejavu-lgc-sans-fonts tigervnc xorg-x11-xauth | ||
Line 35: | Line 45: | ||
* bridge-utils => network bridging to allow the VMs to use the host machine' | * bridge-utils => network bridging to allow the VMs to use the host machine' | ||
* dejavu-lgc-sans-fonts => Fonts for virt-manager (GUI VM manager) | * dejavu-lgc-sans-fonts => Fonts for virt-manager (GUI VM manager) | ||
- | * tigervnc => VNC to connect | + | * tigervnc => VNC to connect |
* xorg-x11-xauth => X11 forwarding through ssh. (Remote virt-manager for headless servers) | * xorg-x11-xauth => X11 forwarding through ssh. (Remote virt-manager for headless servers) | ||
---- | ---- | ||
- | ===== Verify Installation and Start Services ===== | + | ====== Verify Installation and Start Services |
* Ensure that the KVM kernel module is loaded | * Ensure that the KVM kernel module is loaded | ||
<code bash> | <code bash> | ||
- | lsmod | grep kvm | + | [root@bash ~]# lsmod | grep kvm |
+ | kvm_intel | ||
+ | kvm | ||
+ | </ | ||
+ | |||
+ | * If it is not loaded, attempt to load the module: | ||
+ | <code bash> | ||
+ | modprobe -v kvm | ||
</ | </ | ||
Line 60: | Line 77: | ||
</ | </ | ||
- | * Verify libvirtd is running successfully | + | * Verify libvirtd is running successfully |
<code bash> | <code bash> | ||
service libvirtd status | service libvirtd status | ||
- | virsh -c qemu:// | + | virsh -c qemu:///system list |
</ | </ | ||
---- | ---- | ||
- | ===== Setup Networking ===== | + | ====== Setup Networking |
By default, VMs will be on a private network with no access to the outside world unless they use a physical host network interface as a bridge. | By default, VMs will be on a private network with no access to the outside world unless they use a physical host network interface as a bridge. | ||
Line 125: | Line 142: | ||
NETMASK=" | NETMASK=" | ||
GATEWAY=" | GATEWAY=" | ||
+ | DNS1=" | ||
+ | DNS2=" | ||
</ | </ | ||
+ | Note: Those DNS entries are for OpenDNS. | ||
==== IP Forwarding ==== | ==== IP Forwarding ==== | ||
Line 148: | Line 168: | ||
---- | ---- | ||
- | ===== SELinux ===== | + | ====== SELinux |
- | If SELinux is in Enforcing mode, there is additional configuration if you change the default directory for VM images. | + | If SELinux is on and in Enforcing mode, there is additional configuration if you change the default directory for VM images. |
+ | |||
+ | **Check if SELinux is on/ | ||
+ | <code bash> | ||
+ | [bash]# sestatus | ||
+ | SELinux status: | ||
+ | SELinuxfs mount: | ||
+ | Current mode: | ||
+ | </ | ||
**Default VM Image directory: | **Default VM Image directory: | ||
Line 159: | Line 187: | ||
</ | </ | ||
- | * Install | + | * Set the context |
<code bash> | <code bash> | ||
- | yum install policycoreutils-python | + | chcon -R --reference / |
</ | </ | ||
- | * Set security context for the vm-images directory and everything that is created under it. | + | * Verify |
<code bash> | <code bash> | ||
- | semanage fcontext | + | ls -Z /vm-images |
</ | </ | ||
- | * Restore | + | * Create a symlink to the new location |
<code bash> | <code bash> | ||
- | restorecon | + | rmdir / |
- | </code> | + | ln -s /vm-images /var/ |
- | + | ||
- | * Verify | + | |
- | + | ||
- | <code bash> | + | |
- | ls -Z /vm-images | + | |
</ | </ | ||
---- | ---- | ||
- | ===== Creating VMs ===== | + | ====== Creating VMs ====== |
VMs can be installed via a command line tool (virt-install) or a GUI (virt-manager). | VMs can be installed via a command line tool (virt-install) or a GUI (virt-manager). | ||
Line 252: | Line 272: | ||
Proceed with installation as normal. | Proceed with installation as normal. | ||
+ | |||
+ | ---- | ||
==== GUI: virt-manager ==== | ==== GUI: virt-manager ==== | ||
+ | Installing locally via a GUI. | ||
+ | |||
+ | * Open a terminal and type: | ||
+ | <code bash> | ||
+ | virt-manager | ||
+ | </ | ||
+ | * The virt-manager GUI will open. | ||
+ | * Select the name of the host (probably " | ||
+ | * Click the " | ||
+ | * Step 1 => | ||
+ | * Name: Name the virtual machine | ||
+ | * Choose how to install: Select the install method | ||
+ | * Step 2 => | ||
+ | * Browse for the media | ||
+ | * OS Type/ | ||
+ | * Step 3 => | ||
+ | * Memory/CPU: Select memory and CPU. | ||
+ | * Step 4 => | ||
+ | * Storage: Create or use existing storage | ||
+ | * Step 5 => | ||
+ | * Ready to install: Confirm settings, set advanced options such as Host network device. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ====== Disabling virbr0 NAT Interface ====== | ||
+ | |||
+ | On some desktop installations, | ||
+ | |||
+ | To disable this interface: | ||
+ | * View the interface< | ||
+ | * Turn off the interface< | ||
+ | * Disable auto start on the interface< | ||
+ | * Verify State is " | ||
+ | ip addr show</ | ||
+ | * Restart the network service | ||
+ | * EL6<code bash> | ||
+ | * EL7<code bash> | ||
+ | |||
+ | ---- | ||
+ |