RHCSA: How to use RHEL8 as a VM host

Reading Time: 4 minutes

Red Hat Virtualization

This is part 5 of the learning Red Hat series on my blog. Did you know that you can use Red Hat as a Virtual Machine host straight out of the box?

This works on Centos 7 / 8 as well.

There are a number of prerequisites needed to create a VM on a RedHat host. First, you need to have a processor that supports virtualization, if you are using a CPU manufactured in the last 10 years you will have this feature.

Step 1 – Check if Your CPU Supports Virtualization

 grep -E '(vmx|svm)' /proc/cpuinfo 

If this returns a value your CPU is compatible with Red Hat Virtualization, if this command returns nothing then your CPU doesn’t support Virtual Instructions. Note that you may need to enable this feature on your system BIOS – look for the VT-x or AMD-V setting on your BIOS. To do this :

  • Shutdown your PC or Server
  • Switch on the Server and hold down either DEL, F2 or F10 to enter the BIOS. You should see some text at the bottom of the boot screen that tells you what to press. If you are unsure just check your systemboard manual.
  • Locate the setting and enable VT-X or AMD-V then save and exit the BIOS. This page will help you locate the details.

Step 2 – Update your Server using Yum

It is recommended to up your server using Yum. This process might take some time to complete.

yum update -y

Step 3 – Install the Following System Software

RHCSA RHEL 8 VMS requires the following software packages. All are available from official Red Hat Repositories.

  • qemu-kvm
  • python-virtinst
  • libvirt
  • libvirt-python
  • virt-manager
  • libguestfs-tools
  • virt-install
  • qemu-img
  • Libvirt-client

These can be installed using yum. Here is the command you need:

yum install qemu-kvm python-virtinst libvirt libvirt-python virt-manager libguestfs-tools virt-install qemu-img Libvirt-client -y

Step 4 – Enable the Libvertd Daemon

Enable the Libvirtd service to start at system boot

Systemctl enable libvirtd
Systemctl start libvirtd

Step 5 – Enable IP forwarding

Next, you will need to configure the network for IP Forwarding

echo "net.ipv4.ip_forward = 1" | tee /etc/sysctl.conf# sysctl -p 

Step 6 – Open the Virtual Machine Manager

There are several ways to run a VM on RHEL8. This can be done via a GUI or Command-Line.

Running Virt Manager on the command line

The code snipit will create a centos7 server with 1GB ram, 1 CPU and 8GB Hard disk

Type Virt-install command line

virt-install \
 --name centos7 \
 --ram 1024 \
 --disk
 path=/tmp/disk.qcow2,size=8 \
 --vcpus 1 \
 --os-type linux \
 --network bridge=virbr0 \
 --location /path/to/linux.iso \
 --extra-args 'console=ttyS0’

You can use the virsh command to manually edit virtual machines.

  • help
  • list
  • dumpxml
  • start
  • Destroy    [STOP]
  • reboot
  • suspend / resume
  • Undefine   [DELETE]
  • autostart

Running Virt Manager in the GUI

Virtual Machine Manager is a GUI application, using GNOME is the easiest way to get it working, otherwise, you will need to configure X11 forwarding on your putty session.

Step 7 – Configure the Virtual Machines to Start by Default

Its important to note that virsh does not start VMs automatically by default. If you want to start your VM when the host boots, simply type:

Virsh autostart servername

[email protected] ~]# virsh list –all

 Id    Name                           State

—————————————————-

 –     centos7.0                      shut off

 –     centos7.0-3                    shut off –     generic                        shut off

That’s it, now you can dig deeper into configuring a Virtual Environment on RHEL8.

Want to know more?

Top Q&A for RHCSA Virtualization

How do I Create a Virtual Machine in RHEL 8?

In this guide, you have discovered how to create a Virtual Machine in RHEL 8. It all evolves around the virsh command. Try these virsh one-liners to create a wide range of VM’s

Install Debian 8

virt-install \
--name debian8 \
--ram 1024 \
--disk path=./debian8.qcow2,size=8 \
--vcpus 1 \
--os-type linux \
--os-variant generic \
--network bridge=virbr0 \
--graphics none \
--console pty,target_type=serial \
--location 'http://ftp.nl.debian.org/debian/dists/jessie/main/installer-amd64/' \
--extra-args 'console=ttyS0,115200n8 serial'

Install OpenSUSE 13

virt-install \
--name opensuse13 \
--ram 1024 \
--disk path=./opensuse13.qcow2,size=8 \
--vcpus 1 \
--os-type linux \
--os-variant generic \
--network bridge=virbr0 \
--graphics none \
--console pty,target_type=serial \
--location 'http://download.opensuse.org/distribution/13.2/repo/oss/' \
--extra-args 'console=ttyS0,115200n8 serial'

What is the Difference Between RHEL 7 and RHEL 8?

You could write a book on the differences between RedHat 7 and 8. Check out this table of key differences:

Key FeatureRHEL 8RHEL 7
Kernel Revision4.18 and above3.10 up to 3.xx
Release DateMay 2019June 2014
NTPUses ChronyDDefaults to NTP
Package ManagementUses DNFUses YUM
Max RAM Supported24TB (x64)12TB (x64)
VM ManagementUses CockpitUses Virt-Manager
ContainersUses Podman default
Docker available
Docker available

How do I run Redhat on VirtualBox?

My preference is to run RedHat under Hyper-V, simply because I have a Windows Server license, but RedHat can be run on any virtualization platform including VirtualBox.

  • Download the RedHat Binary DVD from RedHat.com
  • Download and Install VirtualBox
  • Select “create new VM” in VirtualBox with 4GB RAM, 20GB Disk, and 2 vCPU’s
  • Under Settings > Storage mount the RHEL Media to the storage Controller
  • Power Up the VM and wait for RedHat to boot
  • Follow the RedHat setup guide

How do I Create a Virtual Machine in Linux?

The easiest way to do this is to use a desktop distribution of Linux, it doesn’t matter if it’s RedHat, Rocky, Ubuntu, etc. Download and install Virt-Manager for an easy-to-follow GUI experience. If you want to deploy using the command line, just follow the procedure above.

How do I Create a Virtual Machine in RHEL 7?

Virtual machines in RHEL 7 can be deployed by following this procedure.

How do I Setup a Virtual Machine?

The host must be configured to run a virtual server and there are some key considerations:

  • Make Sure your VM Host has the relevent hardware to run a virtual machine.
  • Deploy guest VM using resources only required to do the intended job – its very easy to over-provision a VM and waste resources.
  • Consider the I/O impact of the virtual machine on the host resources.
  • Does the VM need SSD storage to function well?
  • Is the network capable of providing the guests enough bandwidth at a low enough latency?

RHCSA RHEL 8 VMS, part of the RHCSA MiniSeries on Turbogeek.co.uk

Part 1 – How to use Grep and Regular Expressions (RegEx)

Part 2 – How to manipulate files in RedHat

Part 3 – Red Hat Permissions

Part 4 – How to change the root password on Red Hat

Part 5 – How to use Red Hat as a virtual machine host

Part 6 – How to configure local storage

Part 7 – how to manage users and groups in Red Hat Linux

Part 8 – how to configure NTP Network Time Protocol in Red Hat

You may also like...

Leave a Reply

Your email address will not be published.