Install KVM
$ yum groupinstall "Virtualization" "Virtualization Client" "Virtualization Platform" "Virtualization Tools"
Verify Installation
Check that kvm kernel modules are loaded. There should be two: kvm and either kvm_intel or kvm_amd.
$ lsmod | grep kvm
kvm_intel 54285 0
kvm 332980 1 kvm_intel
If kvm_intel or kvm_amd is not loaded, try to load it. E.g. kvm_intel.
$ modprobe kvm_intel
In my case, I recieved an error. And in the general RHEL log file, i recieved the following.
$ cat /var/log/messages
Jan 4 20:39:23 tester2 kernel: kvm: disabled by bios
So for my HP Elite 7500 I had to enable Virtualization in the BIOS:
- Computer Setup
- Security
- System Security
- Virtualization Technology (VTx/VTd): Enable
- Save and reboot
NOTE: REALLY TRY TO FIX THE PROBLEM OF NOT HAVING LOADED THE KVM_INTEL OR KVM_AMD, OTHERWISE WILL THINGS GO REALLY SLOW.
Start KVM
$ service libvirtd start
Prerequisite RHEL DVD
The easiest way to distribute the RHEL 6 DVD is to actually use the ISO. To make it accessible for the KVM, we place it under libvirt default images folder.
$ cp rhel-server-6.5-x86_64-dvd.iso /var/lib/libvirt/images/
Finally we need to restore the SELinux type for the ISO file.
$ restorecon -F /var/lib/libvirt/images/rhel-server-6.5-x86_64-dvd.iso
Install Guest Virtual Machine Graphically
The easiest way is to do it graphically with Virtual Machine Manager
$ virt-manager
If you had a kickstart file, you could here press TAB and enter the URI for the kickstart file.
Make sure you auto starts the default network. Otherwise you have to manually start it, every time you boot.
Since this is a virtual server, you can fill the entire virtual disk with RHEL.
A nice feature before writing the new partition table to disk is to preview. You do that with the option at the bottom.
Again the RHEL installation will stretch the entire virtual disk, so cleaning the Master Boot Record, MBR, is no problem. But if you were to install a system along with other OS, you must have good strategy how these OS can work alongside and be booted.
The most common installation is for server is Minimal and for client it is Desktop.
Install Guest Virtual Machine CLI
$ virt-install --prompt
What is the name of your virtual machine?
virtual1.example.com
How much RAM should be allocated (in megabytes)?
2048
What would you like to use as the disk (file path)?
/var/lib/libvirt/images/virtual1.example.com.img
How large would you like the disk (/var/lib/libvirt/images/virtual1.example.com.img) to be (in gigabytes)?
10
What is the install CD-ROM/ISO or URL?
/var/lib/libvirt/images/rhel-server-6.5-x86_64-dvd.iso
Install Guest Virtual Machine CLI with Kickstart
You can automate the entire installation process of new virtual guest in line, with the help of a kickstart file.
To do this you need to extract the ISO file, for example an FTP server. On the FTP server
$ mkdir /media/rhel6
$ mount -o loop /home/magnus/Downloads/rhel-server-6.5-x86_64-dvd.iso /media/rhel6
$ cp -ar /media/rhel6/. /var/ftp/pub/pub/inst
$ virt-install --name virtual2.example.com --ram 2048 --vcpus 2 --disk path=/var/lib/libvirt/images/virtual2.example.com.img,size=20 --location ftp://192.168.1.3/pub/inst --extra-args "ks=ftp://192.168.1.3/pub/minimal-installation-ks.cfg"
Manage Virtual Machine
List all virtual machines.
$ virsh list --all
Id Name State
----------------------------------------------------
2 virtual2.example.com running
Auto start of virtual machine.
$ virsh autostart virtual2.example.com
Domain virtual2.example.com marked as autostarted
Disable auto start of virtual machine.
$ virsh autostart --disable virtual2.example.com
Domain virtual2.example.com unmarked as autostarted
Stop virtual machine.
$ virsh destroy virtual2.example.com
Domain virtual2.example.com destroyed
Start virtual machine.
$ virsh start virtual2.example.com
Domain virtual2.example.com started
Remove Virtual Machine
$ virsh destroy virtual2.example.com
$ rm -f /var/lib/libvirt/images/virtual2.example.com.img
$ rm -f /etc/libvirt/qemu/virtual2.example.com.xml
No comments:
Post a Comment