How to Open Multiple Virtual Machine in KVM

To Open Multiple VM using Network Install (FTP, HTTP, NFS) in KVM

KVM is a virtualisation tool which allows to deploy virtual machines. In this article we will learn, how to install virtual machines using network installation from FTP, NFS and HTTP server.

Mount the centos 7 installation dvd to your machine.

[root@linuxhelp ~]# blkid
/dev/sda1: UUID=" d60ac2f0-b83e-4cb2-9258-b36698044a98"  TYPE=" xfs" 
/dev/sda2: UUID=" 56594f7e-e6be-49fd-b0b3-2230651f1c3e"  TYPE=" swap" 
/dev/sda3: UUID=" 7345257f-cb24-4b27-a16c-0cfa1878df8e"  TYPE=" xfs" 
/dev/sr0: UUID=" 2014-07-06-17-32-07-00"  LABEL=" CentOS 7 x86_64"  TYPE=" iso9660"  PTTYPE=" dos" 
[root@linuxhelp ~]# mount /dev/sr0 /mnt/dvd
mount: /dev/sr0 is write-protected, mounting read-only
[root@linuxhelp ~]# ls /mnt/dvd
CentOS_BuildTag  EULA  images    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7
EFI              GPL   isolinux  Packages  RPM-GPG-KEY-CentOS-7  TRANS.TBL


Network Installation using FTP Server

To set up FTP server we need to install the following package.

[root@linuxhelp ~]# yum install vsftpd -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
-->  Running transaction check
--->  Package vsftpd.x86_64 0:3.0.2-9.el7 will be installed
-->  Finished Dependency Resolution
.
.
.
Installed:
  vsftpd.x86_64 0:3.0.2-9.el7                                                                                                               

Complete!

Create a new directory in /var/ftp/pub to share the files for the installation via ftp server, and copy the contents from the dvd to the newly created directory.

[root@linuxhelp ~]# mkdir /var/ftp/pub/centos7
[root@linuxhelp ~]# cp -r /mnt/dvd/* /var/ftp/pub/centos7/

Next start and enable the ftp services.

[root@linuxhelp ~]# systemctl start vsftpd
[root@linuxhelp ~]# systemctl enable vsftpd
ln -s ' /usr/lib/systemd/system/vsftpd.service'  ' /etc/systemd/system/multi-user.target.wants/vsftpd.service' 

Allow the firewall rule as follows.

[root@linuxhelp ~]# firewall-cmd --permanent --add-service=ftp
success
[root@linuxhelp ~]# firewall-cmd --reload
success

Now we have successfully configured the ftp server.

Click “ Applications” in the menu bar and choose System tools &rarr Virtual machine manager. Or run “ virt-manager” command on your terminal.

Click the icon to create New Virtual Machine.

Enter a Name for the virtual machine and choose network install to install it from network resource.

Enter URL for the installation packages located in ftp path and click “ Forward” .

Now choose your hardware requirement for the virtual machine like RAM, CPU and Hard Drive.


Start the normal installation of Operating Systems as follows.



After Reboot, your virtual machine is ready to use.


Network Installation using NFS Server

To set up NFS server, we need to install the following packages.

[root@linuxhelp ~]# yum install nfs* -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
-->  Running transaction check
--->  Package nfs-utils.x86_64 1:1.3.0-0.el7 will be installed
--->  Package nfs4-acl-tools.x86_64 0:0.3.3-13.el7 will be installed
.
.
.
python-paste.noarch 0:1.7.5.1-9.20111221hg1498.el7               
  python-tempita.noarch 0:0.5.1-6.el7                                     t1lib.x86_64 0:5.1.2-14.el7                                      
  texlive-base.noarch 2:2012-32.20130427_r30134.el7                       texlive-dvipng.noarch 2:svn26689.1.14-32.el7                     
  texlive-dvipng-bin.x86_64 2:svn26509.0-32.20130427_r30134.el7           texlive-kpathsea.noarch 2:svn28792.0-32.el7                      
  texlive-kpathsea-bin.x86_64 2:svn27347.0-32.20130427_r30134.el7         texlive-kpathsea-lib.x86_64 2:2012-32.20130427_r30134.el7        

Complete!

Create a New directory to share NFS server for the installation of centos 7 in KVM and then copy the DVD contents into the nfs share directory.

[root@linuxhelp ~]# mkdir /centos7
[root@linuxhelp ~]# cp -r /mnt/dvd/* /centos7

Change the ownership and set permission for the nfs share directory.

[root@linuxhelp ~]# chown nfsnobody: /centos7
[root@linuxhelp ~]# chmod 755 /centos7

Export the NFS share by creating entry in /etc/exports file as follows.

[root@linuxhelp ~]# vim /etc/exports

Add the following Entry.

/centos7    *(ro,insecure,no_root_squash)

To update the NFS share to kernel, run the following command.

[root@linuxhelp ~]# exportfs -arv
exporting *:/centos7

Start and enable the nfs services.

[root@linuxhelp ~]# systemctl start nfs-server
[root@linuxhelp ~]# systemctl enable nfs-server
ln -s ' /usr/lib/systemd/system/nfs-server.service'  ' /etc/systemd/system/nfs.target.wants/nfs-server.service' 

Allow the firewall rule for nfs as follows.

[root@linuxhelp ~]# firewall-cmd --permanent --add-service=nfs
success
[root@linuxhelp ~]# firewall-cmd --reload
success

Now we successfully configured the NFS server.

Open the Virtual machine manager and Click the icon to create New Virtual Machine.

Type a Name for the virtual machine and choose network install to install it from the network resource.

Enter URL for the installation packages located in NFS path and click “ Forward” .

Choose your hardware requirement for your virtual machine like RAM, CPU and Hard Drive.

Then click Finish.

Continue with the standard installation for Operating Systems as follows.

After Reboot, the virtual machine is ready to use.


Network Installation using HTTP Server

To set up HTTP server we need to install the following package.

[root@linuxhelp ~]# yum install httpd -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
-->  Running transaction check
--->  Package httpd.x86_64 0:2.4.6-17.el7.centos.1 will be installed
-->  Finished Dependency Resolution
.
.
.
Installed:
  httpd.x86_64 0:2.4.6-17.el7.centos.1                                                                                                      

Complete!

Create a new directory under the default document root and copy the files for the installation of VM in KVM

[root@linuxhelp ~]# mkdir /var/www/html/centos
[root@linuxhelp ~]# cp -r /mnt/dvd/* /var/www/html/centos/

Now start and enable the service for http server.

[root@linuxhelp ~]# systemctl start httpd
[root@linuxhelp ~]# systemctl enable httpd
ln -s ' /usr/lib/systemd/system/httpd.service'  ' /etc/systemd/system/multi-user.target.wants/httpd.service' 

And allow the firewall rule for http as follows.

[root@linuxhelp ~]# firewall-cmd --permanent --add-service=http
success
[root@linuxhelp ~]# firewall-cmd --reload
success

Now we have successfully configured the HTTP server.

Open the Virtual machine manager and Click the create New Virtual Machine.

Enter the Name for the virtual machine and choose network install to install it from network resource.

Enter URL for the installation packages located in HTTP path and click “ Forward” .

Choose your hardware requirement for your virtual machine like RAM, CPU and Hard Drive.

And finally click Finish

Continue the standard installation for Operating Systems as follows.



After Reboot your virtual machine is ready to use.

FAQ
Q
What do I need to use KVM?
A
You will need an x86 machine running a recent Linux kernel on an Intel processor with VT (virtualization technology) extensions, or an AMD processor with SVM extensions (also called AMD-V).
Q
Where do I get my KVM kernel modules from?
A
Under their official site do refer "https://www.linux-kvm.org/page/Getting_the_kvm_kernel_modules"
Q
What is the difference between KVM and Xen?
A
Xen is an external hypervisor; it assumes control of the machine and divides resources among guests. On the other hand, KVM is part of Linux and uses the regular Linux scheduler and memory management.
Q
What kernel version does it work with?
A
It depends on what version of KVM you are using. The last release of KVM should work with any recent kernel (2.6.17 and above), older releases even older kernels.
Q
How to check NFS statistics?
A
Try using nfsstat -m from NFS client it will display as per your needs.