RHCSA: How to use Red Hat as a virtual machine host
This is part 5 of the learning Red Hat series on my blog. If you use RHEL 7 or RHEL 8, did you know that you can use it as a virtual machine host – straight out of the box. This works on Centos 7 / 8 as well.
RHEL7/8 can be used as a virtual machine host.
There are a number of prerequistes needed to create a VM host.
First you need to check your CPU supports virtualization
grep -E '(vmx|svm)' /proc/cpuinfo
If this returns a value your CPU is compatable, if this command returns nothing then your CPU doesnt support Virtual Instructions. Note that you may need to enable this feature on your system BIOS – look for VT-x or AMD-V
The following system software is needed – here are the Pre-reqs:
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
Enable Libvertd daemon
Systemctl enable libvirtd
Systemctl start libvirtd
Next you will need to configure the network
echo "net.ipv4.ip_forward = 1" | tee /etc/sysctl.conf# sysctl -p
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.
Type Virt-install command line
--name centos7 \
--ram 1024 \
--vcpus 1 \
--os-type linux \
--network bridge=virbr0 \
--location /path/to/linux.iso \
The above code will create a centos7 server with 1GB ram, 1 CPU and 8GB Hard disk
Running Virt Manager on the command line
You can use the virsh command to manually edit virtual machines.
- Destroy [STOP]
- suspend / resume
- Undefine [DELETE]
Virtual Machines dont start by default
Its important to note that virsh does not start VMs automatically by default.
Here are some useful commands to work around this:
Virsh autostart servername
[email protected] ~]# virsh list –all
Id Name State
– centos7.0 shut off
– centos7.0-3 shut off – generic shut off