Red Hat Enterprise Linux 6.x – small tutorial - part 2 ... Installing and
administering a KVM virtual machine using Kickstart. This time I'll show you as
easy is to ...
Red Hat Enterprise Linux 6.x – small tutorial - part 2
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 I’ll 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) , I’m using a VMware Workstation 8 with Red Hat Enterprise Linux 6.3 installed having 4 GB RAM, 80 HDD and we’re going to need of the RHEL 6.3 DVD. KVM feature asks for hardware virtualization support on processor which it’s 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. Let’s go: Select “REDHAT_63_1” VM menu Settings Processors mark “Virtualize Intel VTx/EPT or AMD-V/RVI” Close
Figure 1 http://alexandreborges.org
Página 1
Red Hat Enterprise Linux 6.x – small tutorial - part 2 Done. You should boot this VMware virtual machine, login as “root” user and open a terminal. It’s recommended you mount RHEL 6.3 DVD into this RHEL VMware virtual machine. It’s 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 Don’t 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 kvm qemu-kvm-0.12.1.2-2.355.el6_4.2.x86_64 [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 http://alexandreborges.org
Página 2
Red Hat Enterprise Linux 6.x – small tutorial - part 2 libvirt-0.10.2-18.el6_4.4.x86_64 virt-viewer-0.5.2-18.el6_4.2.x86_64 virt-what-1.11-1.2.el6.x86_64 libvirt-python-0.10.2-18.el6_4.4.x86_64 Just in case these packages are still not installed in your RHEL host, you should install them from DVD using the following syntax: # rpm –Uvh After packages installation,you must reboot your system, log in it using “root” user, open a terminal and execute the following command: [root@redhat641 ~]# lsmod | grep kvm kvm_intel 53484 0 kvm 316602 1 kvm_intel It’s 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 you’ve installed VM Tools, the task is so quick as dragging and dropping the iso inside the RHEL VM. As I don’t want to enter every single configuration when our KVM virtual machine is being installed, I’ll use a kickstart configuration file and I’ll 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, I’m using a kickstart file at /var/www/html/software/kick.cfg, but I’ll 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 # Let´s configure our system with a fixed IP address network --device eth0 --bootproto static --ip 192.168.1.160 --netmask 255.255.255.0 -gateway 192.168.1.1 --nameserver 8.8.8.8 --hostname test.example.com # Root password will stay the same rootpw --iscrypted $6$aCITKaa7BiLM.6PQ$azGsYKTrg8N5YAzfS/liGr.uAREcjARfl7eEJx.UBRvwRuDSJjYyBSqk WflcasZ4Dtk1qaHxmpsCi4tKauFyG0 # Our firewall will be disabled http://alexandreborges.org
Página 3
Red Hat Enterprise Linux 6.x – small tutorial - part 2 firewall --disabled authconfig --enableshadow --passalgo=sha512 # SELinux is enabled selinux --enforcing timezone --utc America/Sao_Paulo # Our boot loader is installed at mbr bootloader --location=mbr --driveorder=vda --append="crashkernel=auto rhgb quiet" # 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 # It´s 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 #volgroup vg_redhat641 --pesize=4096 pv.008002 #logvol /home --fstype=ext4 --name=lv_home --vgname=vg_redhat641 --grow -size=100 #logvol / --fstype=ext4 --name=lv_root --vgname=vg_redhat641 --grow --size=1024 -maxsize=51200 #logvol swap --name=lv_swap --vgname=vg_redhat641 --grow --size=3968 -maxsize=3968 # Specify our repository #repo --name="blog" --baseurl=http://redhat641.example.com/software
# Reboot after installation be finished reboot firstboot --disabled # A lot of packages were installed %packages @base http://alexandreborges.org
Página 4
Red Hat Enterprise Linux 6.x – small tutorial - part 2 @cifs-file-server @client-mgmt-tools @core @debugging @basic-desktop @desktop-debugging @desktop-platform @directory-client @storage-client-fcoe @ftp-server @fonts @general-desktop @graphical-admin-tools @identity-management-server @input-methods @internet-browser @java-platform @legacy-unix @legacy-x @nfs-file-server @storage-server @network-file-system-client @network-tools @performance @perl-runtime @print-server @print-client @remote-desktop-clients @server-platform @server-policy @virtualization @virtualization-client @virtualization-platform @virtualization-tools @web-server @x11 mtools pax python-dmidecode oddjob wodim sgpio genisoimage device-mapper-persistent-data abrt-gui samba-winbind certmonger openldap-clients pam_krb5 krb5-workstation ldapjdk http://alexandreborges.org
Página 5
Red Hat Enterprise Linux 6.x – small tutorial - part 2 slapi-nis tcp_wrappers libXmu ebtables sg3_utils perl-DBD-SQLite perl-Mozilla-LDAP mod_auth_kerb mod_nss certmonger perl-CGI python-memcached mod_revocator memcached %end
Please, you should pay attention on highlighted pieces of this file. You may have noticed that the hard disk isn’t sda but vda because it’s a virtual disk. Another change is that I’m using cdrom installation method to make simpler our task. A last remember about the file: I’ve named our KVM virtual machine as test.example.com. Let’s create and install our first KVM virtual machine: [root@redhat641 software]# virt-install -n test -r 1024 --disk path=/var/lib/libvirt/images/test.img,size=13 -l /root/Desktop/rhel-server-6.4-x86_64dvd.iso -x "ks=http://192.168.1.150/software/kick.cfg" This whole line appear very difficult, but It’s 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 It’s 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: (power off the virtual machine) [root@redhat641 software]# virsh destroy test (remove virtual machine configuration) [root@redhat641 software]# rm /etc/libvirt/qemu/test.xml (removing the virtual disk image)
http://alexandreborges.org
Página 6
Red Hat Enterprise Linux 6.x – small tutorial - part 2 [root@redhat641 software]# rm /var/lib/libvirt/images/test.img (restarting the virtualization service) [root@redhat641 software]# /etc/init.d/libvirtd restart It’s done. If you want, you’re able to execute the virtual machine creation again. ;) Follow few screens showing the middle of process of virtual machine installation:
Figure 3
Figure 4 http://alexandreborges.org
Página 7
Red Hat Enterprise Linux 6.x – small tutorial - part 2
Figure 5
Figure 6
http://alexandreborges.org
Página 8
Red Hat Enterprise Linux 6.x – small tutorial - part 2 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, let’s open the virtual machine display using virt-viewer: [root@redhat641 Desktop]# virt-viewer test & If you wish, it’s feasible to clone a KVM virtual machine. To execute the cloning job, it’s 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. http://alexandreborges.org
Página 9
Red Hat Enterprise Linux 6.x – small tutorial - part 2 [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 We’ve finished it. I hope you’ve enjoyed it. Have a nice day !!! Alexandre Borges.
http://alexandreborges.org
Página 10