How to Install KVM CentOS 7 and Manage a Virtualized Environment

Are you looking to install and configure a kernel-based virtual machine (KVM) on a RHEL 7 or CentOS 7 server? If so, this article will help you find out how to set up and manage a virtualized environment using KVM in RHEL 7 or CentOS 7.

Installing the KVM on the CentOS 7

  • Install the KVM

First of all, you need to install KVM by typing the ‘yum command’ with the syntax ‘# yum install qemu-kvm libvirt libvirt-python libguestfs-tools virt-install’.

Then, start the libvirtd service with the following commands:

  • # systemctl enable libvirtd
  • # systemctl start libvirtd
  • Verify the KVM installation

Ensure that the KVM module is loaded with the ‘lsmod’ command and ‘grep’ command. Use this syntax to verify the installation ‘# lsmod | grep -i kvm’.

  • Configure bridged networking

A dhcpd-based network bridge is configured by libvirtd by default. You can verify this using the following commands:

  • # brctl show
  • # virsh net-list

All virtual machines only have network access to other VMs that exist on the same server. If you want your VMs to be made available on other servers on your LAN, you need to set up a network bridge on the server connected to the LAN.

You have to update your nic config file as em1 or ifcfg-enp3s0 using the command ‘# vi /etc/sysconfig/network-scripts/enp3s0’. Add the line ‘BRIDGE=br0’.

Save and exit the file in vi, edit /etc/sysconfig/network-scripts/ifcfg-br0, and add the command ‘# vi /etc/sysconfig/network-scripts/ifcfg-br0’.

Restart the networking service with the command ‘# systemctl restart NetworkManager’. Then, verify using the brctl command ‘# brctl show’.

  • Create your first VM

First thing to do is to get the latest ISO image version of CentOS 7 using the wget command. In this case, you can use the commands:

The, verify the ISO images with the following commands:

Using only 2 CPU core, 2GB RAM, 1 nic, and 40GB disk space, you can create a CentOS 7.x VM. Simply type the following commands in proper order.

  • # virt-install \
  • –virt-type=kvm \
  • –name centos7 \
  • –ram 2048 \
  • –vcpus=1 \
  • –os-variant=centos7.0 \
  • –cdrom=/var/lib/libvirit/boot/CentOS-7-x86_64-Minimal-1708.iso \
  • –netwrk=bridge=br0, model=virtio \
  • –graphics vnc \
  • –disk path=/var/lib/libvirt/images/centos7.qcow2,size=40,bus=virtio, format=qcow2

Configure the VNC login from another terminal over ssh using the command ‘# virsh dumpxml centos7 | grep vnc <graphics type=’vnc’ port=’5901’ autoport=’yes’ listen=’’>

Note that the port value is 5901 for this instance. You have to use an SSH client to set up tunnel and a VNC client so that you can access the remote VNC server. From your desktop/client/macbook pro system, you can type the SSH port forwarding command ‘$ ssh [email protected] -L 5901:’.

After establishing an SSH tunnel, you can point your VNC client using your own local host at address and port value at 5901. You will then be able to see in the guest installation screen on the CentOS Linux 7.

You only have to follow the on-screen instructions and install CentOS 7. After installation, click the reboot button and the remote server will close the connection to the VNC client. Reconnect through the KVM client to configure the rest of the server, including the SSH-based session or firewall.

Leave a Reply

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

Previous Post

Second-Generation Cloud Computing – IaaS Services

Next Post

What Makes Linux Computers Different?

Related Posts