Search for:
How to Create Virtual Machines in Linux Using KVM (Kernel-based Virtual Machine) – Part 1

How to Create Virtual Machines in Linux Using KVM (Kernel-based Virtual Machine) &-8211; Part 1 &-8211; this Article or News was published on this date:2019-05-28 18:53:24 kindly share it with friends if you find it helpful

Install and Configure KVM in CentOSInstall and Configure KVM in CentOS

Create Virtual Machines in Linux Using KVM – Part 1

This tutorial discusses KVM introduction, deployment and how to use it to create virtual machines under RedHat based-distributions such as RHEL/CentOS7 and Fedora 21.

What is KVM?

KVM or (Kernel-based Virtual Machine) is a full virtualization solution for Linux on Intel 64 and AMD 64 hardware that is included in the mainline Linux kernel since 2.6.20 and is stable and fast for most workloads.

KVM Feautres

There are many useful features and advantages which you will gain when you use KVM to deploy your virtual platform. KVM hypervisor supports following features:

  1. Over-committing : Which means allocating more virtualized CPUs or memory than the available resources on the system.
  2. Thin provisioning : Which allows the allocation of flexible storage and optimizes the available space for every guest virtual machine.
  3. Disk I/O throttling : Provides the ability to set a limit on disk I/O requests sent from virtual machines to the host machine.
  4. Automatic NUMA balancing : Improves the performance of applications running on NUMA hardware systems.
  5. Virtual CPU hot add capability : Provides the ability to increase processing power as needed on running virtual machines, without downtime.

This is our first on-going KVM (Kernel-based Virtual Machine) series, here we will going to cover following articles in part wise fashion.

Part 1: How to Create Virtual Machines in Linux Using KVM (Kernel-based Virtual Machine)

Prerequisites

Make sure that your system has the hardware virtualization extensions: For Intel-based hosts, verify the CPU virtualization extension [vmx] are available using following command.

[[email protected] ~]- grep -e 'vmx' /proc/cpuinfo
Install and Configure KVM in CentOSCheck Virtualization Support

Check Virtualization Support

For AMD-based hosts, verify the CPU virtualization extension [svm] are available.

[[email protected] ~]- grep -e 'svm' /proc/cpuinfo
Install and Configure KVM in CentOSCheck CPU Virtualization Support

Check CPU Virtualization Support

If there is no output make sure that virtualization extensions is enabled in BIOS. Verify that KVM modules are loaded in the kernel “it should be loaded by default”.

[[email protected] ~]- lsmod | grep kvm

The output should contains kvm_intel for intel-based hosts or kvm_amd for amd-based hosts.

Install and Configure KVM in CentOSCheck KVM Kernel Module Support

Check KVM Kernel Module

Before starting , you will need the root account or non-root user with sudo privileges configured on your system and also make sure that your system is up-to-date.

[[email protected] ~]- yum update

Make sure that Selinux be in Permissive mode.

[[email protected] ~]- setenforce 0

Step 1: KVM Installation and Deployment

1. We will install qemu-kvm and qemu-img packages at first. These packages provide the user-level KVM and disk image manager.

[[email protected] ~]- yum install qemu-kvm qemu-img

2. Now, you have the minimum requirement to deploy virtual platform on your host, but we also still have useful tools to administrate our platform such as:

  1. virt-manager provides a GUI tool to administrate your virtual machines.
  2. libvirt-client provides a CL tool to administrate your virtual environment this tool called virsh.
  3. virt-install provides the command “virt-install” to create your virtual machines from CLI.
  4. libvirt provides the server and host side libraries for interacting with hypervisors and host systems.

Let’s install these above tools using the following command.

[[email protected] ~]- yum install virt-manager libvirt libvirt-python libvirt-client 

3. For RHEL/CentOS7 users, also still having additional package groups such as: Virtualization Client, Virtualization Platform and Virtualization Tools to install.

[[email protected] ~]-yum groupinstall virtualization-client virtualization-platform virtualization-tools	

4. The virtualization daemon which manage all of the platform is “libvirtd”. lets restart it.

[[email protected] ~]-systemctl restart libvirtd

5. After restarting the daemon, then check its status by running following command.

[[email protected] ~]-systemctl status libvirtd  
Sample Output
libvirtd.service - Virtualization daemon 
   Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled) 
   Active: active (running) since Mon 2014-12-29 15:48:46 EET; 14s ago 
 Main PID: 25701 (libvirtd) 
Install and Configure KVM in CentOSCheck Libvirtd Status

Check Libvirtd Status

Now, lets switch to the next section to create our virtual machines.

Step 2: Create VMs using KVM

As we mentioned early, we have some useful tools to manage our virtual platform and creating virtual machines. One of this tools called [virt-manager] which we use in the next section.

6. Although virt-manager is a GUI based tool, we also could launch/start it from terminal as well as from GUI.

[[email protected] ~]-virt-manager
Using GNOME
Install and Configure KVM in CentOSStart Virtual Manager in GNOME

Start Virtual Manager in GNOME

Using GNOME Classic
Install and Configure KVM in CentOSStart Virtual Manager in GNOME Classic

Start Virtual Manager in GNOME Classic

7. After starting the tool, this window will appear.

Install and Configure KVM in CentOSStart Virtual Manager Window

Start Virtual Manager Window

8. By default you will find manager is connected directly to localhost, fortunately you could use the same tool to mange another host remotely. From “File” tab, just select “Add Connection” and this window will appear.

Install and Configure KVM in CentOSAdd Connection

Add Connection

Check “Connect to remote host” option then provide Hostname/IP of the remote server. If you need establishing connection to the remote host at every time the manager starting, just check “Auto Connect” option.

9. Let’s return to our localhost, before creating new virtual machine you should decide where will the files be stored?! in other words, you should create the Volume Disk (Virtual disk / Disk image ) for your virtual machine.

By Right clicking on localhost and selecting “Details” and then select “Storage” tab.

Install and Configure KVM in CentOSVM Storage Details

VM Storage Details

Install and Configure KVM in CentOSVM Storage Volume

VM Storage Volume

10. Next, press “New Volume” button, then enter the name of your new virtual disk (Volume Disk) and enter the size which you want/need in the “Max Capacity” section.

Install and Configure KVM in CentOSCreate KVM VM Storage Disk

Create VM Storage Disk

The allocation size is the actual size for your disk which will be allocated immediately from your physical disk after finishing the steps.

Note: This is an important technology in storage administration field which called “thin provision”. It used to allocate the used storage size only, NOT all of available size.

For example, you created virtual disk with size 60G, but you have used actually only 20G, using this technology the allocated size from your physical hard disk will be 20G not 60G.

In another words the allocated physical size will by dynamically allocated depending on the actual used size. You could find more information in details at VMWare vStorage Thin Provisioning.

11. You will note that a label of the new Volume Disk has been appeared in the list.

Install and Configure KVM in CentOSVM Storage Label

VM Storage Label

You should also notice the path of the new disk image (Volume Disk), by default it will be under /var/lib/libvirt/images, you can verify it using the following command.

[[email protected] Downloads]- ls -l /var/lib/libvirt/images
-rw-------. 1 root root 10737418240 Jan  3 16:47 vm1Storage.img

12. Now, we’re ready to create our virtual machine. Let’s hit the button “VM” in the main window, this wizard window will be appear.

Install and Configure KVM in CentOSCreate New Virtual Machine in KVM

Create New Virtual Machine

Select the installation method which you will use to create the virtual machine. For now we will use Local install media, later we will discuss the remaining methods.

13. Now its time to specify which Local install media to be used, we have two options:

  1. From physical [CDROM/DVD].
  2. From ISO image.

For our tutorial, lets use ISO image method, so you should provide the path of your ISO image.

Install and Configure KVM in CentOSSelect Installation Media

Select Installation Media

Important: Unfortunately there’s a really silly bug for whom use RHEL/CentOS7. This bug prevents you from installation using physical [CDROM/DVD], you will find the option is grayed like this.

Install and Configure KVM in CentOSDisabled CD DVD Rom in KVM

Disabled CD DVD Rom in KVM

And if you hold your cursor on it, this error message will appear.

Install and Configure KVM in CentOSCD DVD Not Supported in KVM

CD DVD Not Supported in KVM

Until now there is no official/direct solution for this bug, you could find more information about this but here.

14. The storage has return back, we will use the virtual disk which we have created early to install virtual machine on it. It will be as shown.

Install and Configure KVM in CentOSEnable KVM Storage for Virtual Machine

Enable Storage for Virtual Machine

15. The final step which ask you about the name of your virtual machine and another advanced options lets talk about it later.

Install and Configure KVM in CentOSEnter Name of Virtual Machine

Enter Name of Virtual Machine

If you like to change some configuration or doing some customization just check “Customize configuration before install” option. Then click finish and wait seconds, control console will appear for your Guest OS to manage it

Install and Configure KVM in CentOSKVM Virtual Machine Installation

Virtual Machine Installation

Conclusion

Now you have learned what is is KVM, How to manage your virtual platform using GUI tools, How to deploy virtual machine using it and another awesome things.

Although this isn’t end of the article, in our up-coming articles, we will discuss another important topics which related to KVM. Make your hands dirty using the previous knowledge and be ready for the next part…..

How to Deploy Multiple Virtual Machines using Network Install (HTTP, FTP and NFS) under KVM Environment – Part 2

How to Deploy Multiple Virtual Machines using Network Install (HTTP, FTP and NFS) under KVM Environment &-8211; Part 2 &-8211; this Article or News was published on this date:2019-05-28 18:52:55 kindly share it with friends if you find it helpful

This is the Part 2 of KVM series, here we will discuss how to deploy Linux virtual machines using network installation under KVM environment. We will discuss three types of network installation (FTP, NFS and HTTP), each one of them has its special prerequisites.

Network Install of Virtual Machines in KVMNetwork Install of Virtual Machines in KVM

Deploy VM’s using Network Install in KVM

Before beginning, make sure that you have the prerequisites which we have mentioned in the first part of this series.

  1. Setup Virtual Machines in Linux Using KVM (Kernel-based Virtual Machine) – Part 1

Network Installation using FTP

1. Before beginning we should install the ftp service package.

- yum install vsftpd

2. After vsftpd has been installed, then lets start and make it service permanently enabled.

- systemctl start vsftpd
- systemctl enable vsftpd

3. For security issues, you may need to add FTP service to the Firewall.

- firewall-cmd --permanent --add-service=ftp
- firewall-cmd –reload

4. Now it’s time to choose your prefer Linux ISO which you want to work on, in this part we use RHEL7 ISO. Let’s mount the ISO image under mount point (i.e. /mnt location). You also can create your custom mount point.

- mount -t iso9660 -o ro /path-to-iso/rhel-server-7.0-x86_64-dvd.iso  /mnt/iso-mp/

5. Until now, we haven’t share anything under FTP server yet. The FTP default data path is /var/ftp/pub/ lets create new directory under it.

- mkdir /var/ftp/pub/RHEL7

6. Then Copy the mounted ISO contained files to it. You also can add ‘v’ option for verbose details while copying.

- cp -r /mnt/iso-mp/* /var/ftp/pub/RHEL7/

7. Finally lets restart vsftpd service and check the status of the service.

- systemctl restart vsftpd
- systemctl enable vsftpd
- systemctl status vsftpd
Sample Output
 vsftpd.service - Vsftpd ftp daemon
 Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled)
 Active: active (running) 
 Main PID: 27275 (vsftpd)

8. Now its time for starting our GUI tool virt-manager.

- virt-manager

9. After starting ‘virt-manager‘, create new virtual machine then select Network install from this window.

Network Install of Virtual Machines in KVMKVM Network Install

KVM Network Install

10. When you have installed KVM packages at the first time, virtual bridge has been created to connect the virtual machine with the physical host. You could display its configuration using ifconfig command.

- ifconfig virbr0
Sample Output
virbr0: flags=4099UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.124.1  netmask 255.255.255.0  broadcast 192.168.124.255
        inet6 fe80::5054:ff:fe03:d8b9  prefixlen 64  scopeid 0x20
        ether 52:54:00:03:d8:b9  txqueuelen 0  (Ethernet)
        RX packets 21603  bytes 1144064 (1.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 214834  bytes 1108937131 (1.0 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

You will notice that IP: 192.168.124.1 is allocated to the virtual bridge vibr0.Virtual machines uses this IP to connect with the physical host. So, we could say that this IP is represent the physical host in the virtual network environment.

We will use this IP to provide the URL path to our FTP directory which contains the files of our ISO. If you have deploy your FTP server on another/remote host, just enter the IP of the other server instead of the previous IP.

Network Install of Virtual Machines in KVMKVM FTP Network Install

KVM FTP Network Install

11. Then you will be asked about resources and storage as same as the previous part of our tutorial. After all there you will reach to this window or something like this.

Network Install of Virtual Machines in KVMKVM Create New VM

KVM Create New VM

Press Finish , and enjoy with your new virtual machine.

Network Install of Virtual Machines in KVMKVM FTP VM Installation

KVM VM Installation

Network Installation using NFS

1. We have almost the same steps here, install the nfs service package.

- yum install nfs-utils

2. Next, start the nfs service and add the service to firewall permanently.

- systemctl start nfs
- systemctl enable nfs
- firewall-cmd --permanent --add-service=nfs
- firewall-cmd –reload

3. Mount the Linux ISO.

- mount -t iso9660 -o ro /path-to-iso/rhel-server-7.0-x86_64-dvd.iso  /mnt/iso-mp/

4. We could share this mount point using NFS share by editing /etc/exports.

-echo /mnt/iso-mp *(ro) > /etc/exports

5. Restart NFS service and check the service’s status.

- systemctl restart nfs
- systemctl status nfs
Sample Output
   nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled)
   Active: active (exited)

8. Start GUI tool ‘virt-manager‘.

- virt-manager

9. After starting ‘virt-manager‘, create new virtual machine then select Network install and then enter the URL path of NFS directory which contains the files of ISO. If you have deployed your NFS server on other remote machine, just enter the IP of that machine.

Network Install of Virtual Machines in KVMKVM NFS VM Install

KVM NFS Install

10. Then it will be asked you to enter resources and storage as same as discussed in the previous part of this series.. Just fill all these details and hit on ‘Finish’ button.

Network Installation Using HTTP

1. We also have almost the same steps here too, install the http service package, start it and enable it permanently on firewall.

- yum install httpd
- systemctl start httpd
- systemctl enable httpd
- firewall-cmd --permanent --add-service=httpd
- firewall-cmd –reload

2. Next, mount the ISO image under ‘/mnt/iso-mp‘ location.

- mount -t iso9660 -o ro /path-to-iso/rhel-server-7.0-x86_64-dvd.iso  /mnt/iso-mp/

3. Until now we haven’t shared anything under HTTP server yet. The HTTP default data path is ‘/var/www/html‘, lets create a new directory under it.

- mkdir /var/www/html/RHEL7

4. Then Copy mounted ISO’s files to this directory.

- cp -r /mnt/iso-mp/* /var/www/html/RHEL7/

5. Restart httpd service and check the service’s status.

- systemctl restart httpd
- systemctl status httpd
Sample Output
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
   Active: active (running)
 Main PID: 3650 (httpd)

6. Next start the ‘virt-manager‘, create a new virtual machine then select Network install and enter HTTP directory path url, which contains the files of ISO image and follow the procedure as discussed above..

Network Install of Virtual Machines in KVMKVM HTTP VM Install

KVM HTTP Install

Conclusion

We have discussed how to deploy Linux virtual machine using network installation. Network install is very preferred over local installation due to centralization which help you to deploy one central installation source, all servers/machine use it to deploy their operating system. This really reduced the wasted installation time in the huge environments.

How to Manage KVM Storage Volumes and Pools for Virtual Machines – Part 3

How to Manage KVM Storage Volumes and Pools for Virtual Machines &-8211; Part 3 &-8211; this Article or News was published on this date:2019-05-28 18:52:34 kindly share it with friends if you find it helpful

In this part 3 of our tutorial, we are discussing how to create and manage KVM Storage volumes and Pools using virt-manager GUI tool.

In general, we use storage devices with different file systems everyday. We have also some storage technologies/techniques like ISCSI, SAN, NAS and so on.

There is no huge different in the basic concepts for our virtual environment, we just use the basic concept to deploy awesome and scale-able virtual storage platform.

With KVM environment , you can use block devices or files as local storage devices within guest operating systems.

We use the physical storage devices to create virtual machine’s volumes. We could describe volumes as a virtual machine’s virtual disk. Volumes cloud be block devices or files as we have mentioned previously.

Create KVM Stroage Volumes and PoolsCreate KVM Stroage Volumes and Pools

Create KVM Storage Volumes and Pools

As a performance consideration, the block devices have the higher hand. Also block files still have the higher hand in the areas of system management and storage capacity use. At any way for scenarios where disk performance from the guest operating system is not critical, its prefer to use disk image files.

Storage volumes also is a part of Storage Pool, actually you can’t create storage volumes before having at least one storage pool.

There is no new prerequisite, just the same one we have discussed in previous parts. If something new I will mention it. So, let’s dive on.

Stage One: Creating Storage Pools in KVM

1. Firstly, let’s display the available pools in our environment by the way we did it before from Details section after right clicking on (localhost) in the main window. This window will appear

Create KVM Stroage Volumes and PoolsCheck Available KVM Pools

Check Available KVM Pools

As a default, there is one storage pool which called “Default” uses the rootfs partition to store vm’s volumes under /var/lib/libvirt/images path.

In many cases, its not recommended to use this pool, just to make this free space for your system. At any way let’s create our first storage pool by clicking on ‘+‘ button from the same window.

Create KVM Stroage Volumes and PoolsCreate KVM Storage Pool

Create KVM Storage Pool

Next, you may provide the name of your new storage pool and select the type of the storage which will be used to deploy the storage pools. KVM supports nine types:

    1. -dir – Uses Filesystem Directory to store storage volumes.
    2. -disk – Uses Physical Hard Disks to store storage volumes.
    3. -fs – Uses Pre-Formatted Partitions to store storage volumes.
    4. -netfs – Uses Network-shared storage like NFS to store storage volumes.
    5. -gluster – Depends on Gluster filesystems storage.
    6. -iscsi – Uses Network-shared ISCSI storage to store storage volumes.
    7. -scsi – Uses local SCSI storage to store storage volumes.
    8. -lvm – Depends on LVM Volume groups to store storage volumes.
    9. -mpath

At the moment, multipathing Volume creation is not supported.

You may be familiar with a lot of them, but we will discuss one or two of them for this tutorial. Lets start with the popular one, (dir) type.

(Dir) type is very popular used as it doesn’t require many modification in current storage schema you have.

Create KVM Stroage Volumes and PoolsName KVM Storage Pool

Name Storage Pool

3. There is no restriction where the storage pool will be created, but it is very recommended to create ‘SPool1‘ directory on separate partition. One important thing also is to give the right permissions and ownership for this directory.

I will use /dev/sda3 as my partition, you may have a different one. Make sure you have mounted it properly.

- mount -t ext4 /dev/sda3 /mnt/personal-data/

4. After mounting the partition under ‘/mnt/personal-data/‘ directory, then provide the path of mount point to that storage directory (i.e. /mnt/personal-data/SPool1).

Create KVM Stroage Volumes and PoolsKVM Storage Pool Location

Storage Pool Location

5. After finishing, you will find new storage pool “SPool1” appeared in the list.

Create KVM Stroage Volumes and PoolsAdd KVM Storage Pool

New Storage Pool

Before going to the stage two to create volumes, Let’s discuss another type of our Storage Pool called fs.

The (FS) type is depends on Preformatted partitions and it is useful for whom want to specify complete partition for virtual machine disks/storage.

6. We will create another storage pool using per-formatted partition that is the ((fs) Pre-Formatted Block Device) type. You need to prepare another new partition with desired file system.

You could use “fdisk” or “parted” to create new partition and use “mkfs” for formatting with new file-system. For this section, (sda6) will be our new partition.

- mkfs.ext4 /dev/sda6

Also create a new directory (i.e. SPool2), it acts as a mount point for the selected partition.

7. After selecting (fs) type from the drop-menu, next provide the name of the new pool as shown

Create KVM Stroage Volumes and PoolsAdd Second Storage Pool to KVM

Add Second Storage Pool to KVM

8. In the next window, you need to provide the path of your partition ‘/dev/sda6‘ in our case – in the “Source Path” field and the path of the directory which acts as a mount point /mnt/personal-data/SPool2 in the “Target Path” field.

Create KVM Stroage Volumes and PoolsAdd Second Storage Path

Add Second Storage Path

9. Finally, there is a third storage pool added in the main storage list.

Create KVM Stroage Volumes and PoolsSecond Storage Details

Second Storage Details

So, we will discuss deploying another storage types in our next part using CLI tools, for now let’s move to create volumes.

Stage Two: Create Storage Volumes

As we discussed before, you could consider the storage volumes as a virtual disks for virtual machines. We also still have many formats for this volumes.

In general, this formats allow you to use your volumes with QEMU, VMware, Oracle VirtualBox and Hyper-V.

10. Select the storage pool which you want to storage volume be part of ‘New Volume‘. Press on ‘New Volume’ button to start.

11. Next, provide the name of the new volume and select the format of it. Don’t forget to set proper size also.

Create KVM Stroage Volumes and PoolsCreate New Volumes in KVM

Create New Volumes in KVM

12. Now your volume is ready to attached with virtual machines

Create KVM Stroage Volumes and PoolsAdd Volume to KVM Virtual Machine

Add Volume to KVM Virtual Machine

Conclusion

Now you’ve learned the difference between Storage Pools and Volumes and how to create and manage them under KVM environment using virt-manager GUI tool. Also we discussed the types of Pools and the importance of volume’s formats. It’s your turn to make your hands more dirty.

Reference Links

KVM HomePage
KVM Documentation

How to Manage KVM Virtual Environment using Commandline Tools in Linux

How to Manage KVM Virtual Environment using Commandline Tools in Linux &-8211; this Article or News was published on this date:2019-05-28 18:51:09 kindly share it with friends if you find it helpful

In this 4th part of our KVM series, we are discussing KVM environment management using CLI. We use ‘virt-install’ CL tool to create and configure virtual machines, virsh CL tool to create and configure storage pools and qemu-img CL tool to create and manage disk images.

KVM Management in LinuxKVM Management in Linux

KVM Management in Linux

There is nothing new concepts in this article, we just do the previous tasks using command line tools. There is no new prerequisite, just the same procedure, we have discussed in previous parts.

Step 1: Configure Storage Pool

Virsh CLI tool is a management user interface for managing virsh guest domains. The virsh program can be used either to run one command by giving the command and its arguments on the shell command line.

In this section, we will use it to create storage pool for our KVM environment. For more information about the tool, use the following command.

- man virsh

1. Using the command pool-define-as with virsh to define new storage pool, you need also to specify name, type and type’s arguments.

In our case, name will be Spool1, type will be dir. By default you could provide five arguments for the type:

  1. source-host
  2. source-path
  3. source-dev
  4. source-name
  5. target

For (Dir) type, we need the last argumet “target” to specify the path of storage pool, for the other arguments we could use “” to unspecific them.

- virsh pool-define-as Spool1 dir - - - - "/mnt/personal-data/SPool1/"
KVM Management in LinuxCreate New Storage Pool

Create New Storage Pool

2. To check the all storage pools you have in the environment, use the following command.

- virsh pool-list --all
KVM Management in LinuxList All Storage Pools

List All Storage Pools

3. Now it’s time to build the storage pool, which we have defined above with the following command.

- virsh pool-build Spool1
KVM Management in LinuxBuild KVM Storage Pool

Build Storage Pool

4. Using the virsh command pool-start to active/enable the storage pool we have just created/built above.

- virsh pool-start Spool1
KVM Management in LinuxEnable KVM Storage Pool

Active Storage Pool

5. Check the status of environment storage pools using the following command.

- virsh pool-list --all
KVM Management in LinuxCheck KVM Storage Pool Status

Check Storage Pool Status

You will notice that the status of Spool1 converted to active.

6. Configure Spool1 to start by libvirtd service every time automaticlly.

- virsh pool-autostart Spool1
KVM Management in LinuxConfigure KVM Storage Pool

Configure KVM Storage Pool

7. Finally lets display information about our new storage pool.

- virsh pool-info Spool1
KVM Management in LinuxCheck KVM Storage Pool Information

Check KVM Storage Pool Information

Congratulations, Spool1 is ready to be used lets try to create storage volumes using it.

Step 2: Configure Storage Volumes/Disk Images

Now it is disk image’s turn, using qemu-img to create new disk image from Spool1. For more details about qemy-img, use the man page.

- man qemu-img

8. We should specify the qemu-img command “create, check,….etc”, disk image format, the path of disk image you want to create and the size.

- qemu-img create -f raw /mnt/personal-data/SPool1/SVol1.img 10G
KVM Management in LinuxCreate KVM Storage Volumes

Create Storage Volume

9. By using qemu-img command info, you could get information about your new disk image.

KVM Management in LinuxCheck KVM Storage Volume Information

Check Storage Volume Information

Warning: Never use qemu-img to modify images in use by a running virtual machine or any other process; this may destroy the image.

Now its time to create virtual machines in the next step.

Step 3: Create Virtual Machines

10. Now with the last and latest part, we will create virtual machines using virt-istall. The virt-install is a command line tool for creating new KVM virtual machines using the “libvirt” hypervisor management library. For more details about it, use:

- man virt-install

To create new KVM virtual machine, you need to use the following command with all the details like shown in the below.

  1. Name: Virtual Machine’s name.
  2. Disk Location: Location of disk image.
  3. Graphics : How to connect to VM “Usually be SPICE”.
  4. vcpu : Number of virtual CPU’s.
  5. ram : Amount of allocated memory in megabytes.
  6. Location : Specify the installation source path.
  7. Network : Specify the virtual network “Usually be vibr00 bridge”.
- virt-install --name=rhel7 --disk path=/mnt/personal-data/SPool1/SVol1.img --graphics spice --vcpu=1 --ram=1024 --location=/run/media/dos/9e6f605a-f502-4e98-826e-e6376caea288/rhel-server-7.0-x86_64-dvd.iso --network bridge=virbr0
KVM Management in LinuxCreate KVM Virtual Machine

Create New Virtual Machine

11. You will find also a pop-up virt-vierwer window appears to communicate with virtual machine through it.

KVM Management in LinuxBooting Virtual Machine

Booting Virtual Machine

KVM Management in LinuxInstallation of Virtual Machine

Installation of Virtual Machine

Conclusion

This is the latest part of our KVM tutorial, we haven’t covered everything of course. It a shot to scratch the KVM environment so its your turn to search and keep hands dirty using this nice resources.

KVM Getting Started Guide
KVM Virtualization Deployment and Administration Guide