CentOS – Virtual machine host server

Kernel-based Virtual Machine or in short KVM is a full featured virtualization solution for Linux. KVM is open source software, you don’t have to pay a dime to get your personal Virtual Machine suite. Highly manageable and remarkable performance with no load on your IT budget.

Here is a quick guide to create Virtual Host Server on Linux/CentOS 7.X & 6.X. Not much explanations here just a flow of commands.

CentOS Installation

  1. Root file system size / = Total RAM + 40 GB will be good to start with. If system has 32 GB of physical RAM then total size of the root partition should be minimum 72 GB.
  2. Leave rest of the disk space for virtual machine images folder.
  3. Keep the SWAP size between 8 to 16 GB (No hard and fast rule, check this link for more details http://wiki.centos.org/HowTos/oVirt#head-745a9ecfc4cf39b73880901f56a0d0fc8e755544)
  4. Install CentOS with Minimal Desktop option.
  5. Create sysadmin account during or after the installation.
  6. Reboot the system.

Initial CentOS configuration

  1. After reboot, get on to the system console
  2. Disable selinux
    1. # vi /etc/selinux/config and change SELINUX=enforcing to SELINUX=disabled
  3. Disable firewall only if this system is serving local LAN users, at command prompt as root do the following
    1. #chkconfig iptables off
    2. #service iptables stop
    3. #chkconfig ip6tables off
    4. #service ip6tables stop
  4. update system
    1. yum -y update
  5. Ensure you have bridge-utils installed
    1. yum -y install bridge-utils
  6. Disable graphical desktop on console
    1. vi /etc/inittab
    2. change id:5:initdefault to id:3:initdefault
  7. Reboot system

Network bonding

After reboot enable network card bonding

  1. #echo -e “alias bond0 bonding\noptions bond0 miimon=80 mode=6″ > /etc/modprobe.d/netbond.conf or create netbond.conf file and put “alias bond0 bonding\noptions bond0 miimon=80 mode=6” no quotes
  2. Create bond0 interface
  3. vi /etc/sysconfig/network-scripts/ifcfg-bond0 and add the following lines


Create the bridge device

  1. # vi /etc/sysconfig/network-scripts/ifcfg-br0

2. Log into console and edit etho configuration, as network will shut down while doing these steps
# vi /etc/sysconfig/network-scripts/ifcfg-eth0

3. Do the same configuration for all network cards available in your system

4. Set the /etc/resolv.conf:
# vi /etc/resolv.conf

domain mydomain.com
search mydomain.com

5. Update /etc/hosts file to add hostname and IP address
# vi /etc/hosts,  replace “myname” with hostname and IP address hostname.mydomain.com hostname

6. Disable NetworkManager, enable network
# chkconfig NetworkManager off
# chkconfig network on

7. Reboot for changes to take effect
# shutdown -r now

Add EPEL Repository and other helpful packages

  1. # rpm -Uvh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
  2. Install Graphical Logical Volume Manager, Graphical System Monitor, screen, etc.
  3. # yum -y install system-config-lvm gnome-system-monitor

Install/Test XDesktop over VNC

  1. Ensure XDesktop and Gnome are installed, these are default packages and should be there already
  2. # yum -y install xorg-x11-fonts-Type1 xorg-x11-fonts-misc

Install VNC Server if not working on console

  1. # yum -y install tigervnc-server
  2. Create basic vncdesktop for netadmin created initially
  3. # vi /etc/sysconfig/vncservers
  4. VNCSERVERS=”8:sysadmin”
  5. VNCSERVERARGS[8]=”-geometry 1024×768″ or select whichever resolution suites your needs or fit on your windows desktop
  6. # su – sysadmin
  7. $ vncpasswd
  8. As root, start the vnc service
  9. # service vncserver start
  10. #chkconfig vncserver on only if you like vncserver to start automatically with every reboot.
  11. Try to connect to server with TightVNC or VNC Viewer on Windows: hostname:8

Add Virtualization Suite

  1. Add the Virtualization suite, as root
  2. # yum -y groupinstall “Virtualization”
  3. Add the graphical virt-manager, libvirt and other pkgs
  4. # yum -y install virt-manager libvirt
  5. Start libvirt
  6. # service libvirtd start
  7. # chkconfig libvirtd on

Create partition which we left unused during installation for storing virtual machine images “images”

  1. Create a directory on root
  2. # mkdir /images
  3. From VNC, XDesktop create the partition
  4. # system-config-lvm
  5. Sym-link the libvirtd images with /images deleting the original folder
  6. # rmdir /var/lib/libvirt/images
  7. # ln -s /images /var/lib/libvirt/images

And here we are. By now, using VNC you will be able to launch virtual machine manager as root #virt-manager create and start virtual machines. After creating dedicated partition for virtual machine images now all virtual machines will be stored in /images folder/partition.


Leave a Reply

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