Install CentOS8 on KVM

Install CentOS8 on KVM

In today’s tutorial, we will install CentOS8 on KVM. The install process is fairly straightforward and we will cover it here step-by-step. We will follow a similar format to the “Install RHEL7 or CentOS7 on a PC” article. The difference is, our CentOS8 instance will run in our KVM virtual environment.

Table of Contents

Introduction

It is important to note that we will install CentOS8 on a qcow2 formatted disk. This will allow us certain advantages that are not available with raw formatted disk images. For example, we can create snapshots using a qcow2 image. Or, apply AES encryption to our image for data security. Both of these features are not possible with a raw disk image.

Install CentOS on KVM - Computer Motherboard

Image by Miguel A. Padrinan from Pexels

Pre-Installation Checks

Before we begin, this tutorial assumes that you have KVM installed and configured properly. Also, it assumes you have root privileges or sudo privileges to become root. Now, let’s proceed with the installation.

Download the latest CentOS8 ISO

First things first, we’re using the wget utility to download the latest copy of the CentOS8 iso. If the following command (below) does not work for you, simply install wget using yum (RHEL7/CentOS7), dnf (RHEL8/CentOS8/Fedora35), or apt-get (Ubuntu), depending on your Linux distribution:

In addition, we have created an isos directory under /var/tmp to store our CentOS8 iso. Also, the latest CentOS8 iso is 11GB in size. Therefore, your chosen location for download, needs to accommodate this file.

				
					admin@kvm-host1:/var/tmp/isos $ sudo wget http://mirror.umd.edu/centos/8-stream/isos/x86_64/CentOS-Stream-8-x86_64-20220223-dvd1.iso
				
			

Create a qcow2 disk image

Secondly, we’re using the qemu-img utility to create the qcow2 disk image that will serve as storage for our CentOS8 virtual machine (below). Also, we will allocate 75GB to our new disk image named dev-infotechys-5.img. It will reside under the /var/lib/libvirt/images directory (default image store for KVM).

				
					admin@kvm-host1:/var/lib/libvirt/images $ sudo qemu-img create -f qcow2 dev-infotechys-5.img 75G
Formatting 'dev-infotechys-5.img', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=80530636800 lazy_refcounts=off refcount_bits=16
				
			

CentOS8 Installation Step-by-Step (virt-manager)

Now that we’ve downloaded the CentOS8 iso and created a qcow2 disk image, we can now proceed with the installation.

Launch virt-manager

First, launch the virt-manager on your KVM host as the root user.

				
					root@kvm-host1:~ # virt-manager
				
			

Create a new virtual machine

Next, click the computer monitor icon (circled in red below) to continue.

Install CentOS8 on KVM - Create a new VM

Photo by admingeek from Infotechys

Next, you will be prompted to choose how you would like to install the operating system. Since we downloaded the ISO locally, we’ll go with the first option highlighted: Local install media (ISO image or CDROM). Then, click the [Forward] button to continue.

Choose an ISO

Then, you will be prompted to choose the ISO you would like to use for the install. Click the [Browse] button and select the path to your ISO file. Or, enter it in the text box. For this tutorial, the CentOS8 ISO is located under /var/tmp/isos. Click the [Forward] button to continue.

Choose ISO option window

Photo by admingeek from Infotechys

Choose memory and CPU settings

In step 3 of 5, you will be prompted to choose the memory and CPU settings for your CentOS8 instance. For this demonstration, we entered 4096 MB or 4GB for the RAM and 2 CPUs or cores. Click the [Forward] button to continue.

Choose Memory and CPU settings window

Photo by admingeek from Infotechys

Choose a disk image

In step 4 of 5, you will be prompted to decide how you want to set up a disk image for your CentOS8 virtual machine. You’ll notice that the “Create a disk image” option is selected by default. We are not going to select this option because we created a qcow2 disk image (dev-infotechys-5.img) earlier–that we’d like to use. 

Instead, choose the “Select or create custom option” below it and click the [Manage] button to continue. You will be presented with another window listing the contents of /var/lib/libvirt/images. Select your qcow2 image and click the [Choose Volume] button to continue.

Install CentOS8 on KVM - Choose Disk Image Option

Photo by admingeek from Infotechys

Finalize and Review Settings

In step 5 of 5, we are about ready to begin the installation. There are just a few remaining housekeeping details we need to attend to.

First, enter a name for your CentOS8 instance. We decided to go with vm5-dev-infotechys.com…naturally. Choose a name that suits you. Next, click the checkbox to select the “Customize configuration before Install” option. It will allow us to ensure everything checks out before we proceed with install.

Finally, select the “Bridge device” option from the dropdown menu and enter in your bridge interface. For our KVM host, the bridge interface is br03. Your interface will likely be different. Click the [Finish] button to continue.

Finalize virt-manager portion of the install

Photo by admingeek from Infotechys

As you can see (above), everything looks good. We’ve even added a brief note in the description textbox, stating the type of VM we are building. We are now ready to proceed with the CentOS8 Installer portion. Click the [Begin Installation – Green Check mark] button to continue.

CentOS8 Installation Step-by-Step (CentOS8 Installer)

At the initial CentOS8 installer screen, you will be presented with the option to either Install CentOS Linux 8 or Test this Media & Install CentOS Linux 8. Press the [UP] arrow to highlight the first option (Install CentOS Linux 8) and the [Enter] key to continue.

Initial CentOS8 Installer Screen

Photo by admingeek from Infotechys

Welcome to CentOS Linux 8

Next, you will arrive at the Welcome to CentOS Linux 8 screen.  Select the language and region that suits you or click the [Continue] button to proceed with the default options.

Welcome to CentOS8

Photo by admingeek from Infotechys

Installation Summary

At the CentOS installation summary window, you will be presented with a few options. First, let’s address the options highlighted in red text.

CentOS8 Installation Summary

Photo by admingeek from Infotechys

Disk Partitioning

Click the Installation Destination option under the SYSTEM category to continue. Next, click the disk icon (under Local Standard Disks) to select it with a check mark. Then, click the Custom radio button (under Storage Configuration) and the blue [Done] button to continue.

Installation Destination Window

Photo by admingeek from Infotechys

Partition specifications

The manual disk partitioning procedure will include the following changes:

  1. Change the volume group name from cl to vg00
  2. Allocate 15GB of storage space to the /root partition
  3. 20GB to the /home partition
  4. 2GB to the /boot partition
  5. 4GB to the swap partition
  6. Allocate the remaining available space (roughly 24GB) to the /extras partition. We can use this partition for extending or creating logical volumes as we see fit in the future.

Changing the volume group name

Changing the volume group name is a fairly easy procedure but, first, we need to ensure that all existing partitions are wiped from the disk as (seen in the image below).

Manual Partitioning

Photo by admingeek from Infotechys

Click the plus (“+”) sign to proceed with creating a partition. We will change the volume group name as part of this process.

The root partition

Photo by admingeek from Infotechys

Click the down arrow next to the text box labeled “Mount point:” and select the “/” for the root partition (as shown above). Then, enter the size you want allocated to root in the “Desired Capacity:” text box.

volume group name change

Photo by admingeek from Infotechys

Referring to the “Partition Specifications” section, we’ll assign 15GiB to root and click the [Add mount point] button to continue.

vg00 entry

Photo by admingeek from Infotechys

To Change the volume group name (above), click the down arrow next to the Volume Group and click the “Create a new volume group” option. Then, enter the new name (vg00) in the text box labeled Name: and click the “Save” button to continue.

The boot partition

Photo by admingeek from Infotechys

Next, repeat the same steps for creating the remaining partitions: Allocate 2GB to /boot4GB to swap, and the remaining storage to /extras. When provisioning the /extras partition, enter /extras into the text box labeled “Mount point:” as it is not listed in the drop down menu.

Accept Partition Changes

Photo by admingeek from Infotechys

Click the “Done” button and the “Accept Changes” button to continue.

CentOS8 on KVM: Software

This part of the installation is going to be the easiest as we are not going to make any changes. We will leave the default “Server with GUI” option selected.

Server with GUI Selected

Photo by admingeek from Infotechys

CentOS8 on KVM: Network

Now that we’ve completed the disk partitioning, we can proceed with configuring the hostname and network settings. For the purposes of this demonstration, we’ll keep things simple and go with DHCP for the network setting. Also, in the hostname text box at the bottom of the page, enter the hostname you’d like to use and click the “Apply” button to confirm the change.

Next, click the switch at the top right-hand corner of the screen (circled in red) to “ON”. This will activate DHCP. As a result, the IP address, subnet mask, default route, and DNS address for your machine will populate automatically.

Click the “Done” button to continue.

Network and hostname configurations

Photo by admingeek from Infotechys

CentOS8 on KVM: User Settings

This part of the installation process is self-explanatory. Set a root password for your CentOS8 instance and create an administrative user account (for sudo access to root).

Root Password Change

Photo by admingeek from Infotechys

Both options are located under the USER SETTINGS category. The CentOS8 on KVM Installation is 95% complete at this point.

Create administrative user

Photo by admingeek from Infotechys

Upon completion of the USER SETTINGS portion, the [Begin Installation] button should highlighted in blue. This indicates we are cleared to begin the CentOS8 package installation and system configuration process.

Finalizing the Installation process

Photo by admingeek from Infotechys

CentOS8 on KVM: Installation in Progress

From this point onward, the CentOS package installer will begin to install all the necessary packages required for a CentOS8 Server with GUI Instance. This is a good place to take a break and walk away from your terminal as this process can take several minutes to complete.

Post-Install Procedure

Once the installation is complete, your will be prompted to reboot your machine. Click the [Reboot System] button to continue.

Reboot your Machine

Photo by admingeek from Infotechys

License Agreement

Upon reboot, your will be prompted once more to accept the End User License Agreement or EULA. Click the icon next to the License Information to continue. Then, click the checkbox to agree with the terms and the blue [Done] button to continue.

License Agreement

Photo by admingeek from Infotechys

Then, click the checkbox to agree with the terms and the blue [Done] button to continue.

License agreement - EULA

Photo by admingeek from Infotechys

License Acceptance Window

Photo by admingeek from Infotechys

Finally, click the [FINISH CONFIGURATION] button to continue. Your machine should boot to a login screen and thus, bring us to the end of this tutorial.

CentOS8 Login Screen

Photo by admingeek from Infotechys

Conclusion

Congratulations! You’ve just completed a successful install of a CentOS8 virtual machine on KVM. As part of this process we reviewed some system configuration and administration topics like network and hostname configuration, logical volume manager (LVM), and custom disk partitioning. Was this article helpful to you? If so, leave us some feedback in the comments section. We’d love to hear from you.

Related Posts

Leave a Reply

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