I use for this lab, a VMware ESXi 6.0 virtual machine (running CentOS 7.2).

VMware ESXi special settings

In this lab, my KVM machine is hosted on a VMware ESXi server, so I need to change some parameters in order to get “VT-x” Intel processor instructions enabled.

Stop the virtual machine (here : “KVM”), open an SSH session to your ESXi server and find the configuration file :

[root@pc31:~] find / -name KVM.vmx
/vmfs/volumes/562b58a7-87a9978a-aea7-d0bf9c455630/KVM/KVM.vmx

Add ‘vhv.enable=”TRUE”‘ at this end of this configuratiopn file :

[root@pc31:~] tail -1 /vmfs/volumes/562b58a7-87a9978a-aea7-d0bf9c455630/KVM/KVM.vmx
vhv.enable="TRUE"

Reload configuration :

[root@pc31:~] vim-cmd vmsvc/getallvms | grep KVM
40 KVM [datastore1] KVM/KVM.vmx centos64Guest vmx-11
[root@pc31:~] vim-cmd vmsvc/reload 40

Now, start your virtual machine. You will see “VT-x” processor instructions enabled :

[root@kvm ~]# grep vmx /proc/cpuinfo flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave hypervisor lahf_lm arat epb pln pts dtherm tpr_shadow vnmi ept vpid fsgsbase tsc_adjust smep flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave hypervisor lahf_lm arat epb pln pts dtherm tpr_shadow vnmi ept vpid fsgsbase tsc_adjust smep

KVM installation procedure

Temporary annealing security

During this first lab, we stopped the firewall :

[root@kvm ~]# systemctl stop firewalld

And disabled SELinux :

[root@kvm ~]# setenforce 0
setenforce: SELinux is disabled

KVM installation process

Install mandatory packages :

yum -y install qemu-kvm libvirt libvirt-python libguestfs-tools virt-install

Start “libvirtd” service :

[root@kvm ~]# systemctl start libvirtd

And keep it started after reboot :

[root@kvm ~]# systemctl enable libvirtd

“kvm” modules are loaded :

[root@kvm ~]# lsmod | grep kvm
kvm_intel 162153 0
kvm 525409 1 kvm_intel

Network interfaces

Create a new bridge :

[root@kvm ~]# cat /etc/sysconfig/network-scripts/ifcfg-bridge0
DEVICE=bridge0
TYPE=Bridge
BOOTPROTO=none
NM_CONTROLLED=none
IPADDR=172.18.0.1
PREFIX=16
IPV6INIT=yes
IPV6_AUTOCONF=yes
ONBOOT="yes"
DELAY="0"

Restart “network” service :

[root@kvm ~]# systemctl restart network

Now, we have :

[root@kvm ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eno16777984: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:0c:29:82:a0:d6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.111/24 brd 192.168.1.255 scope global eno16777984
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe82:a0d6/64 scope link
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
    link/ether 52:54:00:bc:9b:32 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500
    link/ether 52:54:00:bc:9b:32 brd ff:ff:ff:ff:ff:ff
5: bridge0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
    link/ether be:38:49:4b:64:76 brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 brd 172.18.255.255 scope global bridge0
       valid_lft forever preferred_lft forever
    inet6 fe80::bc38:49ff:fe4b:6476/64 scope link
       valid_lft forever preferred_lft forever

Enable I.P. v4 packet forwarding :

  • Add this line in “/etc/sysctl.conf :
[root@kvm ~]# cat /etc/sysctl.conf
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/.conf file
#
# For more information, see sysctl.conf(5) and sysctl.d(5).

# enable I.P. v4 packet forwarding for KVM :
net.ipv4.ip_forward = 1
  • Reload the configuration :
[root@kvm ~]# sysctl -p /etc/sysctl.conf
net.ipv4.ip_forward = 1

My first virtual machine

Launch this command :

[root@kvm ~]# virt-install --network bridge:bridge0 --name my_vm --ram=1024 --vcpus=1 --disk path=/kvm_images/vm1.img,size=10 --location /ISO/CentOS-7-x86_64-DVD-1511.iso --os-type linux --nographics --accelerate --extra-args="console=ttyS0"

After few minutes, you will see the console screen :

Starting installer, one moment...
anaconda 21.48.22.56-1 for CentOS 7 started.
 * installation log files are stored in /tmp during the installation
 * shell is available on TTY2
 * when reporting a bug add logs from /tmp as separate text/plain attachments
09:30:45 Not asking for VNC because we don't have a network
================================================================================
================================================================================
Installation

 1) [x] Language settings                 2) [!] Timezone settings
        (English (United States))                (Timezone is not set.)
 3) [!] Installation source               4) [!] Software selection
        (Processing...)                          (Processing...)
 5) [!] Installation Destination          6) [x] Kdump
        (No disks selected)                      (Kdump is enabled)
 7) [ ] Network configuration             8) [!] Root password
        (Not connected)                          (Password is not set.)
 9) [!] User creation
        (No user will be created)
  Please make your choice from above ['q' to quit | 'b' to begin installation |
  'r' to refresh]:

[anaconda] 1:main* 2:shell  3:log  4:storage-lo> Switch tab: Alt+Tab | Help: F1

Set your options as you usually proceed with “Anaconda” to continue installation.

After installation, then reboot, I shut down my virtual machine whithin the console :

[root@localhost ~]# shutdown -h 0

To list all virtual machines :

[root@kvm ~]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     my_vm                          shut off

Restart virtual machine :

[root@kvm ~]# virsh start my_vm Domain my_vm started

The virtual machine is now running :

[root@kvm ~]# virsh list
 Id    Name                           State
----------------------------------------------------
 6     my_vm                          running

We can logon to the console :

[root@kvm ~]# virsh console my_vm
Connected to domain my_vm
Escape character is ^]

CentOS Linux 7 (Core)
Kernel 3.10.0-327.el7.x86_64 on an x86_64

localhost login: root
Password:
Last login: Wed Feb 10 15:43:49 on ttyS0
[root@localhost ~]#

To quit this console, I pressed on “Control” and “]”

 

PDF24    Send article as PDF   

Leave a Reply

Your email address will not be published. Required fields are marked *


*