Red Hat Enterprise Linux 6.x small tutorial - part 2 author: Alexandre Borges website: http://alexandreborges.org
Installing and administering a KVM virtual machine using Kickstart
This time Ill show you as easy is to create and administer a KVM virtual machine. Following the same configuration of previous tutorial (http://alexandreborgesbrazil.files.wordpress.com/2013/07/alexandre_blog_first_post_rhel_1 a.pdf) , Im using a VMware Workstation 8 with Red Hat Enterprise Linux 6.3 installed having 4 GB RAM, 80 HDD and were going to need of the RHEL 6.3 DVD.
KVM feature asks for hardware virtualization support on processor which its configured on Red Hat virtual machine properties, then you should enable it. My RHEL VM is named REDHAT_63_1 and VM Tools is installed. Lets go:
Select REDHAT_63_1 VM menu Settings Processors mark Virtualize Intel VT- x/EPT or AMD-V/RVI Close
Figure 1 Red Hat Enterprise Linux 6.x small tutorial - part 2
http://alexandreborges.org Pgina 2
Done. You should boot this VMware virtual machine, login as root user and open a terminal. Its recommended you mount RHEL 6.3 DVD into this RHEL VMware virtual machine. Its could be done like that:
Select REDHAT_63_1 VM menu Setting CD/DVD select Use ISO image file browse the RHEL 6.3 DVD Close
Dont forget to mark Connected after you have logged on RHEL host operating system !!!
Figure 2
Please, you shoud confirm if the following KVM packages are installed:
[root@redhat641 ~]# rpm -qa | grep -i virt virt-who-0.8-5.el6.noarch virt-top-1.0.4-3.15.el6.x86_64 python-virtinst-0.600.0-15.el6.noarch virt-manager-0.9.0-18.el6.x86_64 libvirt-client-0.10.2-18.el6_4.4.x86_64 Red Hat Enterprise Linux 6.x small tutorial - part 2
Its nice. Our KVM module is in use and it means that our job until here has worked.
Now you should copy the Red Hat DVD iso file into the system because it will make our job easier. If youve installed VM Tools, the task is so quick as dragging and dropping the iso inside the RHEL VM. As I dont want to enter every single configuration when our KVM virtual machine is being installed, Ill use a kickstart configuration file and Ill to make it available using an Apache web host like I already have done in the first part of this tutorial (http://alexandreborgesbrazil.files.wordpress.com/2013/07/alexandre_blog_first_post_rhel_1 a.pdf). In my case, Im using a kickstart file at /var/www/html/software/kick.cfg, but Ill need to adapt it to install a KVM virtual machine:
[root@redhat641 ~]# more /var/www/html/software/kick.cfg
# Kickstart file automatically generated by anaconda.
#version=DEVEL install cdrom
lang en_US.UTF-8 keyboard br-abnt2
# Lets configure our system with a fixed IP address
# The following is the partition information you requested # Note that any partitions you deleted are not expressed # here so unless you clear all partitions first, this is # not guaranteed to work
# Its necessary erase everything before starting the installation
zerombr clearpart --all --drives=vda
# Our partitions, in MB, follow below:
part /boot --fstype=ext4 --size=500 part / --fstype=ext4 --size=10000 part swap --size=1500
Please, you should pay attention on highlighted pieces of this file. You may have noticed that the hard disk isnt sda but vda because its a virtual disk. Another change is that Im using cdrom installation method to make simpler our task. A last remember about the file: Ive named our KVM virtual machine as test.example.com.
Lets create and install our first KVM virtual machine:
This whole line appear very difficult, but Its not. Detailing it:
-n virtual machine name -r RAM memory (MB) --disk path where the virtual machine is being installed size virtual disk size (GB) -l location of installation files -x kernel extra arguments
Its sure nobody wants that something goes wrong, but just in case this to happen, you can clean the virtual machine configuration and remove the virtual disk, correct your mistake and run the same previous command. Executing the cleaning task is straight:
Its done. If you want, youre able to execute the virtual machine creation again. ;)
Follow few screens showing the middle of process of virtual machine installation:
Figure 3
Figure 4 Red Hat Enterprise Linux 6.x small tutorial - part 2
http://alexandreborges.org Pgina 8
Figure 5
Figure 6
Red Hat Enterprise Linux 6.x small tutorial - part 2
http://alexandreborges.org Pgina 9
Now that our KVM virtual machine is installed and working, we can execute some administration commands. For example, to list KVM virtual machines in our RHEL VM:
[root@redhat641 Desktop]# virsh list --all Id Name State ---------------------------------------------------- 2 test running - vm1 shut off
Setting the KVM virtual machine to start during the boot process of the host machine is easy:
[root@redhat641 Desktop]# virsh autostart test Domain test marked as autostarted
To disable the KVM virtual machine to start during the boot process of the host machine:
[root@redhat641 Desktop]# virsh autostart --disable test Domain test unmarked as autostarted
To stop the KVM virtual machine:
[root@redhat641 Desktop]# virsh destroy test Domain test destroyed
To start the KVM virtual machine:
[root@redhat641 Desktop]# virsh start test
Now, lets open the virtual machine display using virt-viewer:
[root@redhat641 Desktop]# virt-viewer test &
If you wish, its feasible to clone a KVM virtual machine. To execute the cloning job, its needed that the original virtual machine is powered off:
[root@redhat641 Desktop]# virsh list --all Id Name State ---------------------------------------------------- - test shut off - vm1 shut off
[root@redhat641 Desktop]# virt-clone --prompt What is the name of the original virtual machine? test What is the name for the cloned virtual machine? test2 What would you like to use as the cloned disk (file path) for '/var/lib/libvirt/images/test.img'? /var/lib/libvirt/images/test2.img Allocating 'test2.img' | 13 GB 03:11
Clone 'test2' created successfully. Red Hat Enterprise Linux 6.x small tutorial - part 2
http://alexandreborges.org Pgina 10
[root@redhat641 Desktop]# virsh list --all Id Name State ---------------------------------------------------- - test shut off - test2 shut off - vm1 shut off
Nonetheless, before you can use this virtual machine, you should boot it into runlevel 1, change the network configuration and, afterwards, you could boot it into runlevel 3.
Alternatively, if you wish to remove a virtual machine configuration (and its virtual disk), you can do:
[root@redhat641 Desktop]# virsh undefine test2
Weve finished it. I hope youve enjoyed it. Have a nice day !!!