How to use Red Hat (RHEL8) as a Linux VM host

Red Hat Virtualization, building a Linux VM

This is part 5 of the learning Red Hat series on my blog. Did you know you can use Red Hat as a Virtual Machine host? In fact you can use almost all new flavors of Linux to create a Linux VM host straight out of the box.

This works on Centos 7 / 8 as well.

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

Step 1 – Check if Your CPU Supports Linux VM Virtualization

Bash
 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 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 system 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.

Bash
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:

Bash
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 the system boot

Bash
systemctl enable libvirtd
systemctl start libvirtd

Step 5 – Enable IP forwarding

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

Bash
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 snippet will create a centos7 server with 1GB RAM, 1 CPU, and 8GB Hard disk

Type Virt-install command line

Bash
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 Linux VM to Start by Default

It’s 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:

Bash
Virsh autostart servername


root@ip-10-0-0-116 ~]# 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: Linux VM

How do I Create a Linux VM 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 VMs

Install Debian 8

Bash
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

Bash
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 Red Hat 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 Linux VM?

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.

Elsewhere On TurboGeek:  Configure Time with NTP and Chronyd

How do I set up a Linux VM?

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

  • Make Sure your VM Host has the relevant hardware to run a virtual machine.
  • Deploy guest VM using resources only required to do the intended job – it’s 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 MiniSeries 

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

Richard.Bailey

Richard Bailey, a seasoned tech enthusiast, combines a passion for innovation with a knack for simplifying complex concepts. With over a decade in the industry, he's pioneered transformative solutions, blending creativity with technical prowess. An avid writer, Richard's articles resonate with readers, offering insightful perspectives that bridge the gap between technology and everyday life. His commitment to excellence and tireless pursuit of knowledge continues to inspire and shape the tech landscape.

You may also like...

6 Responses

  1. 19/10/2022

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

  2. 19/01/2023

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

  3. 20/03/2023

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

  4. 24/03/2023

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

  5. 21/08/2023

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

  6. 03/02/2024

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

Leave a Reply

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

Translate ยป