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
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.
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 the 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 snippet 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 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:
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
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 Red Hat 7 and 8. Check out this table of key differences:
Key Feature | RHEL 8 | RHEL 7 |
Kernel Revision | 4.18 and above | 3.10 up to 3.xx |
Release Date | May 2019 | June 2014 |
NTP | Uses ChronyD | Defaults to NTP |
Package Management | Uses DNF | Uses YUM |
Max RAM Supported | 24TB (x64) | 12TB (x64) |
VM Management | Uses Cockpit | Uses Virt-Manager |
Containers | Uses 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.
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 a guest VM using only the resources required to do the intended job—it’s very easy to overprovision 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
6 Responses
[…] Part 5 – How to use Red Hat as a virtual machine host […]
[…] Part 5 – How to use Red Hat as a virtual machine host […]
[…] Part 5 – How to use Red Hat as a virtual machine host […]
[…] Part 5 – How to use Red Hat as a virtual machine host […]
[…] Part 5 – How to use Red Hat as a virtual machine host […]
[…] Part 5 – How to use Red Hat as a virtual machine host […]