Explore information related to kvm networking centos 7

Create CentOS Fedora RHEL VM Template on KVM - How to do it

This article covers how to create CentOS/Fedora/RHEL VM Templates on KVM. VM Templates are more useful when deploying high numbers of similar VMs that require consistency across deployments. If something goes wrong in an instance created from the Template, you can clone a fresh VM from the template with minimal effort.

To install KVM in your Linux system:

The KVM service (libvirtd) should be running and enabled to start at boot.

$ sudo systemctl start libvirtd

$ sudo systemctl enable libvirtd

Enable vhost-net kernel module on Ubuntu/Debian.

$ sudo modprobe vhost_net

# echo vhost_net | sudo tee -a /etc/modules

How to Prepare CentOS / Fedora / RHEL VM template ?

1. Update system

After you finish VM installation, login to the instance and update all system packages to the latest versions.

$ sudo yum -y update

2. Install standard basic packages missing:

$ sudo yum install -y epel-release vim bash-completion wget curl telnet net-tools unzip lvm2 

3. Install acpid and cloud-init packages.

$ sudo yum -y install acpid cloud-init cloud-utils-growpart

$ sudo sudo systemctl enable --now acpid

4. Disable the zeroconf route

$ echo "NOZEROCONF=yes" | sudo tee -a /etc/sysconfig/network

5. Configure GRUB_CMDLINE_LINUX – For Openstack usage.

If you plan on exporting template to Openstack Glance image service, edit the /etc/default/grub file and configure the GRUB_CMDLINE_LINUX option. Your line should look like below – remove rhgb quiet and add console=tty0 console=ttyS0,115200n8.

GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap console=tty0 console=ttyS0,115200n8"

Generate grub configuration.

$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg

6. Install other packages you need on your baseline template.

7. When done, power off the virtual machine.

How to Clean VM template ?

You need virt-sysprep tool for cleaning the instance.

$ sudo virt-sysprep -d centos7

Read More