linux_wiki:kernel-based_virtual_machine_kvm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux_wiki:kernel-based_virtual_machine_kvm [2015/02/23 23:00]
billdozor
linux_wiki:kernel-based_virtual_machine_kvm [2019/05/25 23:50] (current)
Line 1: Line 1:
 ====== Kernel-based Virtual Machine (KVM) ====== ====== Kernel-based Virtual Machine (KVM) ======
  
-Description: KVM is "a full virtualization solution for Linux on x86 hardware containing virtualization extensions." ([[http://www.linux-kvm.org/page/Main_Page|KVM Main Page]]) It can be run on the desktop with GUI managers or on a headless server.+**General Information**
  
-Assumptions:  +KVM is "a full virtualization solution for Linux on x86 hardware containing virtualization extensions.([[http://www.linux-kvm.org/page/Main_Page|KVM Main Page]]) It can be run on the desktop with GUI managers or on a headless server.
-  * Some Red Hat based distro is already installed. (CentOS, Scientific, RHEL, etc) +
-  * 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.+**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 Groups+==== Install: Required Virtualization Packages (CLI) ====
  
 <code bash> <code bash>
-yum groupinstall "Virtualization*"+yum install qemu-kvm python-virtinst virt-top libvirt libvirt-client
 </code> </code>
  
-**Group Explanations** +**CLI Package Explanations** 
-This will install the following package groups: +  * qemu-kvm => The main KVM package. 
-  * Virtualization Tools => Tools for offline virtual image management+  * python-virtinst => CLI tools and libraries for creating VMs
-  * Virtualization Platform => Provides an interface for accessing and controlling virtualized guests and containers+  * virt-top => CLI VM stats
-  * Virtualization Client => Clients for installing and managing virtualization instances+  * libvirt => Toolkit for libvirtd service
-  * Virtualization => Provides an environment for hosting virtualized guests.+  * libvirt-client => Toolkit for VM clients.
  
-For detailed info and a list of packages that will be installed:+==== InstallOptional Virtualization Packages (GUI) ====
 <code bash> <code bash>
-yum groupinfo "Virtualization*"+yum install virt-manager virt-viewer
 </code> </code>
  
-  * Install: Additional Useful Packages+**GUI Package Explanations** 
 +  * virt-manager => GUI VM administration tool. 
 +  * virt-viewer => GUI local console connection to VMs. 
 + 
 + 
 +==== Install: Optional Useful Packages ====
 <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 37: Line 45:
   * bridge-utils => network bridging to allow the VMs to use the host machine's physical interfaces as a bridge.   * bridge-utils => network bridging to allow the VMs to use the host machine's physical interfaces as a bridge.
   * 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 locally to VM console+  * tigervnc => VNC to connect remotely to VM's GUI.
   * 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              55496  0  
 +kvm                   337900  1 kvm_intel 
 +</code> 
 + 
 +    * If it is not loaded, attempt to load the module: 
 +<code bash> 
 +modprobe -v kvm
 </code> </code>
  
Line 62: Line 77:
 </code> </code>
  
-  * Verify libvirtd is running successfully+  * Verify libvirtd is running successfully (Yes, 3 forward slashes)
  
 <code bash> <code bash>
 service libvirtd status service libvirtd status
-virsh -c qemu://system list+virsh -c qemu:///system list
 </code> </code>
  
 ---- ----
  
-===== 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 127: Line 142:
 NETMASK="255.255.255.0" NETMASK="255.255.255.0"
 GATEWAY="192.168.0.1" GATEWAY="192.168.0.1"
 +DNS1="208.67.222.222"
 +DNS2="208.67.220.220"
 </code> </code>
 +Note: Those DNS entries are for OpenDNS.
  
 ==== IP Forwarding ==== ==== IP Forwarding ====
Line 150: Line 168:
 ---- ----
  
-===== SELinux =====+====== SELinux ======
 If SELinux is on and 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.
  
Line 169: Line 187:
 </code> </code>
  
-  * Install the following package to enable use of the "semanage" utility. +  * Set the context of the new directory, referencing the default
 <code bash> <code bash>
-yum install policycoreutils-python+chcon -R --reference /var/lib/libvirt/images /vm-images
 </code> </code>
  
-  * Set security context for the vm-images directory and everything that is created under it. +  * Verify
 <code bash> <code bash>
-semanage fcontext -a -t virt_image_t "/vm-images(/.*)?"+ls -/vm-images
 </code> </code>
  
-  * Restore the security context (I don't know why you have to do this yet...but you do) +  * Create a symlink to the new location to ensure that is survives a SELinux relabel.
 <code bash> <code bash>
-restorecon -/vm-images +rmdir /var/lib/libvirt/images 
-</code> +ln -/vm-images /var/lib/libvirt/images
- +
-  * Verify +
- +
-<code bash> +
-ls -Z /vm-images+
 </code> </code>
  
 ---- ----
  
-===== 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 287: Line 297:
     * Step 5 =>     * Step 5 =>
       * Ready to install: Confirm settings, set advanced options such as Host network device.       * Ready to install: Confirm settings, set advanced options such as Host network device.
 +
 +----
 +
 +====== Disabling virbr0 NAT Interface ======
 +
 +On some desktop installations, a NAT interface "virbr0" is auto created.
 +
 +To disable this interface:
 +  * View the interface<code bash>virsh net-list</code>
 +  * Turn off the interface<code bash>virsh net-destroy default</code>
 +  * Disable auto start on the interface<code bash>virsh net-autostart default –disable</code>
 +  * Verify State is "inactive" and Autostart is "no", then ensure virbr0 is not in the interface list<code bash>virsh net-list --all
 +ip addr show</code>
 +  * Restart the network service
 +    * EL6<code bash>service network restart</code>
 +    * EL7<code bash>systemctl restart network</code>
 +
 +----
 +
  • linux_wiki/kernel-based_virtual_machine_kvm.1424750448.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)