Skip to main content

KVM Virtualization on Linux

Course

Intro Video

Photo of Tom Dean

Tom Dean

Linux Training Architect II

Tom hails from Chicago, near the home of the South Side Irish Parade. He loves of ALL the seasons (which can happen at any moment in Chicago) and it was one of the things that brought him back to the area over ten years ago. When Tom is away from the keyboard he loves to tinker with vintage electronics, make music and occasionally hang out on his boat.

Length

05:00:00

Difficulty

Intermediate

Videos

38

Course Details

Did you know that, for a long time, Linux has had its own built-in virtualization technology, KVM? In this course, you will gain a better understanding of KVM Virtualization on Linux through interactive, hands-on lessons. We will explore four scenarios: workstation virtualization using the GUI utilities, web-based management using Cockpit, managing virtualization using the Linux CLI, and managing virtual workloads using oVirt on CentOS. When you have finished this course, you will have the skills necessary to design, deploy, and manage virtual workloads using KVM on Linux.

Due to the course requirement for nested virtualization, there are no hands-on labs, as there is no support for nested virtualization in hands-on labs. For the same reason, this will not work in the Cloud Playground. Therefore, all lessons are follow-along, using your computer (optional, but recommended).

Course Prerequisites Student must be experienced / proficient with: Linux Command line GUI Networking Storage Exposure to RHEL distributions a plus 'dnf' / ‘yum’ - package management Hardware Intel (VT-x) AMD (AMD-V) Intermediate Networking Skills Intermediate Storage Skills Virtualization Experience is a plus

Syllabus

Getting Started

About the Course

00:02:39

Lesson Description:

In this lesson, we are going to preview the KVM Virtualization on Linux course. We will talk about the scope of the course and what skills and experience you should bring. When you finish this lesson, you should have a good understanding of the course. Ratings and Feedback Throughout the course, the lessons, and labs, as well as for the entire course itself, there are opportunities to provide feedback (thumbs up, thumbs down). I appreciate your feedback as it helps me make this course better, as well as future courses. If you liked a lesson/lab/course and would like to make a suggestion, but want to also give it a "thumbs up", you can do that as well! Flash Cards Feel free to check out the Flash Cards for the course to test your knowledge! They are accessible from the main course page as well as in the upper right-hand corner of the lesson pages. Community Another resource to assist you in your learning adventure is the Community. You can access the Community via the upper navigation bar. About the Course In this course, we're going to explore KVM Virtualization on Linux from four perspectives:Workstation Virtualization Using CentOS 8 Virtual Machine Manager (virt-manager)Web-based Virtualization Using CentOS 8 Cockpit / Web ConsoleCLI Administration Using CentOS 8 Exploring oVirt on CentOS 7Due to the course requirement for nested virtualization, there are no hands-on labs, as there is no support for nested virtualization in hands-on labs. For the same reason, this will not work in the Cloud Playground. Therefore, all lessons are follow-along, using your computer(s) (optional, but recommended). Course Prerequisites Student must be experienced / proficient with:Linux: Command line GUI Networking StorageExposure to RHEL distributions a plus: 'dnf' / ‘yum’ - package managementHardware: Intel (VT-x) AMD (AMD-V)Intermediate Networking Skills Intermediate Storage Skills Virtualization Experience is a plusHardware/software requirements to follow along:Computer(s):Intel CPU with VT-x AMD CPU with AMD-V Plenty of RAM The more cores, the merrier Reasonable disk spaceAlternative Hypervisor:Nested virtualization support Self-supported: Lessons to assist with setupI'm using:Two Dell Precision T3500 workstations: Single 6-core Xeon 24GB RAM RAID-1 1TB HDD Two network connections: "Public" Network "Private" NetworkStudents will need to be patientVirtualization can mean installs take time: Get up and stretch Get a snack Bio breaks Review past lessons Get refreshed for when the action resumesIn this course, I've aspired to provide an interesting journey through four scenarios that utilize KVM Virtualization on Linux. I hope you enjoy the course!

About the Training Architect

00:02:56

Lesson Description:

Description In this lesson, you will get to know your Training Architect, Tom Dean. Get to know your Training Architect, Tom Dean. Reference Links Tom Dean on LinkedIn Tom Dean - Linux Training Architect Interests:Boating Obsolete electronics Music Household projectsStarted on Apple IIs in the early 1980s:Programming in BASIC Hacking in generalPurdue University graduate:First exposure to UNIX on Sequent 386-based systems First exposure to the Internet (just before WWW was widespread)25 years experience in Information TechnologyFocus on Linux / UNIX Traditional and virtualized infrastructure Managed teams and projects Exposure to many industries/environments Have worked with Linux since 1997 Main focus has been on RedHat distributions Passion for Linux and Open SourceThank you for allowing me to assist you with your journey!

Virtualization Concepts

What Is Virtualization?

00:10:27

Lesson Description:

In this lesson, we will cover, at a high level, what virtualization is. We will cover the history of virtualization, what virtualization is and how it works, and talk about a few ways virtualization can be used. Reference Links What is virtualization? | Red Hat What is virtualization? | Opensource.com What is virtualization technology & virtual machine? | VMware Virtualization - Wikipedia x86 virtualization - Wikipedia Hardware-assisted virtualization - Wikipedia A Brief History of Cloud Computing | IBM History of Virtualization Network function virtualization - Wikipedia What is Virtualization? Red Hat: "Virtualization is technology that lets you create useful IT services using resources that are traditionally bound to hardware. It allows you to use a physical machine’s full capacity by distributing its capabilities among many users or environments." Virtualization allows you to decouple your services and applications from the physical (server) layer, and deploy it in a more efficient and reliable manner than the traditional 1:1 service/application to physical server relationship. History of Virtualization Mainframes - the 1960sMIT announces Project MAC (Mathematics and Computation / Multiple Access Computer) $2 Million grant from DARPA IBM passes GE becomes vendor of choiceBell Labs also has a need for multi-user system IBM designs CP-40 mainframe Evolves into CP-67 CP/CMS (Control Program / Console Monitor System) 1968 - first release 1972 - first stable release CP runs on the mainframe Creates the VMs VMs run the CMS User interacts with these Each user gets their own operating system More stable and secureHardware Virtualization - late 80s and beyondInsignia Solutions SoftPC UNIX - 1987 Run DOS applications on UNIX WorkstationMac - 1989 Could run DOS and Windows applicationsApple / Connectix Virtual PC - 1997 Run Windows on MacVMWare VMWare Workstation - 1999 Initially ran on WindowsESX/GSX Server - 2001 ESX Server type-1 hypervisorGSX Server type-2 hypervisorJava Virtual Machine - the early 1990sSun Microsystems begins Project Stealth in 1990 Also known as Oak and Web Runner In 1995, project officially becomes Java Targeted toward WWW Write application once, run anywhere Java Run-time Environment (JRE) Complies application, just in time (JIT) Developer doesn't have to worry about the operating system, just write the codeJava Virtual Machine Small operating system, a "virtual machine" Runs the Java applicationHardware-assisted Virtualization - 2005/2006 *"In computing, hardware-assisted virtualization is a platform virtualization approach that enables efficient full virtualization using help from hardware capabilities, primarily from the host processors. A full virtualization is used to simulate a complete hardware environment, or virtual machine, in which an unmodified guest operating system (using the same instruction set as the host machine) effectively executes in complete isolation. Hardware-assisted virtualization was added to x86 processors (Intel VT-x or AMD-V) in 2005 and 2006 (respectively)." --Wikipedia* In short, hardware virtualization is where we add features to the CPU that assist and accelerate virtualization by moving these functions from the software (hypervisor) to the hardware (CPU).Intel Virtualization (VT-x) CPU flag for VT-x capability is "vmx" grep -i vmx /proc/cpuinfo"VMX" stands for Virtual Machine Extensions Adds 13 new instructions Guest OS perceives itself as running with full privilege Host os remains protectedExtended Page Tables (EPT) Intel technology for the memory management unit (MMU)AMD Virtualization (AMD-V) CPU flag for AMD-V capability is "svm" AMD Secure Virtual Machine, later AMD-V grep -i svm /proc/cpuinfoRapid Virtualization Indexing (RVI) AMD technology for the processor memory management unit (MMU)How Does Virtualization Work? Virtualization creates a "virtual machine" for the guest operating system to live within, with virtual resources instead of physical resources. Physical resources can also be mapped to a guest where necessary. What is a Hypervisor? A hypervisor is software that sits between the guest (virtual machine) operating system and either the hardware itself or another operating system (host) The hypervisor provides the resources that the guest operating system requiresVirtual CPU(s) Virtual Memory Virtual Disk(s) Virtual Networking Other resources Virtual media CD/DVD/ISO images USB SoundVideoMapped physical resources Networking IP StorageGPU(s)Type-1 vs Type-2 HypervisorsType-1 Hypervisor Sits directly on the hardware It is the host "operating system" Example: VMWare ESXType-2 Hypervisor Runs on top of a host operating system Example: VirtualBoxTypes of Virtualization Server / Operating System VirtualizationRun multiple operating systems on one or more physical server(s) More efficient hardware utilization Consolidate workloads for efficiencyVirtual machine is independent of the hardware Virtual machines can be moved around for hardware maintenance, with minimal disruption Virtual machines can be replicated to remote datacenters or the cloud Disaster recovery Capacity needsSingle means of managing servers Automation Deployment Lifecycle managementDesktop VirtualizationVirtual Desktop Infrastructure (VDI) Separate the desktop environment from physical hardware Provide access to desktop environment Client software Web browserMany users on one physical machine Consolidate compute and storage More efficient use of hardware and storage Valuable company data lives in the data center Redundancy Backup OwnershipSimilar to server virtualization, but different management tools and methodology Popular solutions include VMWare Horizon Citrix Virtual Apps and Desktops Formerly XenApp and XenDesktopMicrosoft Hyper-V VDI Windows Virtual Desktop (Azure)Application VirtualizationContainers Lightweight version of virtualization Multiple isolated user-space instancesOnly provide the bare minimum needed, not a full OS install Looks like "real", full operating systems Certain parts of host operating system are shared Examples Docker LXC Solaris Containers FreeBSD jail(s) chroot jail(s)Network (Function) VirtualizationVirtual representation of physical networking components Logical ports Switches Routers VPN(s) Firewalls Load Balancers(s)Fast and easy to deploy Can be deployed alongside virtual servers Deploy an entire unit of virtual infrastructure at the same time Automation ScalingIn this lesson, we covered:What virtualization is A brief history of virtualization How virtualization works What a hypervisor is Type-1 vs Type-2 hypervisorsDifferent types of virtualization

Why Virtualize?

00:06:12

Lesson Description:

In this lesson, we will cover some of the common reasons we virtualize our workloads. Reference Links Why We Virtualize Every Server - StorageCraft Technology Corporation Why Virtualize? There are many reasons to consider virtualizing some or all of your physical infrastructure. Here are some of the more prominent ones. Reduce Your Hardware Costs Generally, most traditional physically deployed server footprints average 5-15% utilization. It's inefficient. By virtualizing, you can:Retire older servers, which are more expensive to operate and cost more to support Standardize on a single (or minimal number of) hardware configuration(s) Keep spares on-site for quick repair turnaround Reduces complexity of the hardware layer design Reduces maintenance complexity Use commodity, "bang for the buck" hardwareReduce Your Energy Costs With the consolidation of servers into a reduced hardware footprint comes a reduction in energy consumption, as well as cooling costs. With fewer physical servers, you will also require less physical networking hardware (IP and storage), less cabling, and less support equipment. Reduce Your Footprint Fewer physical servers means less rack space. If you're in a hosted facility and are paying by the rack, this can mean big savings. If you own your datacenter, you can use the floor space for other things. Workload Management / Fault Tolerance / Maintenance In an enterprise-level virtualization solution, you can move virtual machines between hosts with no (or minimal interruption). This facilitates moving guests around to balance workloads across hosts. In a properly-designed virtual infrastructure, there will be enough virtualization hosts so one or more can be taken offline for maintenance while all the guests can continue to run on the remaining hypervisor(s). In addition, most enterprise-level virtualization solutions, using shared storage, will support moving guests to another hypervisor in the event of an issue or outage. The ability to take snapshots of guests prior to patching, application upgrades, or other potentially dangerous processes provides a safety net and a quick mechanism to back out changes that might have been less than successful. Disaster Recovery / Migrations An enormous benefit of virtualization is the ease with which guests can be moved between hosts. This is not only possible within a single datacenter, but across datacenters and in the cloud. Many enterprise-level solutions offer disaster recovery solutions so you don't have to reinvent the wheel. This same concept applies when it comes to migrating guests to new hardware. Backups With the ability to take snapshots of virtual disks comes the ability to back up these snapshots. Since this happens outside of the guest operating system, we can use a system-agnostic backup methodology. We can also leverage advanced backup and recovery options, where available, that were not available or were difficult to implement with traditional hardware-based infrastructures. Standardization / Automation In addition to moving to a homogeneous hardware platform, virtualization provides a clean, predicable environment for guests. This standardization reduces complexity in the datacenter stack. A good virtualization platform gives you the tools and automation to ease management. In this lesson, we covered a number of good reasons to virtualize all or part of your physical workloads.Reduce Your Hardware Costs Reduce Your Energy Costs Reduce Your Footprint Workload Management / Fault Tolerance / Maintenance Disaster Recovery / Migrations Standardization / Automation

Introduction to KVM

KVM - Overview

00:02:32

Lesson Description:

In this lesson, we will take a look at KVM, the technology that enables Linux to serve as a type-1 hypervisor for your guest operating systems. Reference Links KVM Kernel-based Virtual Machine - Wikipedia Guest Support Status - KVM Management Tools - KVM KVM - Overview What is KVM? KVMKVM: Linux kernel module Allows the kernel to function as a type-1 hypervisor Was merged into the kernel mainline as of 2.6.20 (2/2007) Provides the /dev/kvm interface Requires hardware virtualization extensions Intel VT-x "vmx" extensionAMD-V "svm" extensionHow Does It Work? KVM allows the Linux kernel to function as a type-1 hypervisor “KVM (for Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V). It consists of a loadable kernel module, kvm.ko, that provides the core virtualization infrastructure and a processor specific module, kvm-intel.ko or kvm-amd.ko. Using KVM, one can run multiple virtual machines running unmodified Linux or Windows images. Each virtual machine has private virtualized hardware: a network card, disk, graphics adapter, etc. KVM is open source software. The kernel component of KVM is included in mainline Linux, as of 2.6.20. The userspace component of KVM is included in mainline QEMU, as of 1.3.” --KVM Project KVM itself does not have tools to manage virtual machines. It only provides access to the hardware acceleration. The /dev/kvm Device The KVM kernel module exposes the /dev/kvm device file, which QEMU uses to *"talk to"* KVM. This allows QEMU access to hardware acceleration. How do I know if my system supports KVM virtualization? A quick test is to check for the existence of /dev/kvm/:

ls -al /dev/kvm
You should see the /dev/kvm device: crw-rw-rw-. 1 root kvm 10, 232 Apr 25 17:57 /dev/kvm You can also check for Intel VT-x (vmx) or AMD-V support (svm):
egrep -c "vmx|svm" /proc/cpuinfo
You should see a number of one or greater. If this returns a result of zero, then you do not have hardware virtualization support. You can also check for the existence of the kvm kernel modules:
lsmod | grep kvm
On an Intel system, you would see kvm_intel and kvm. In this lesson, we covered:What KVM is How QEMU / KVM works The /dev/kvm device How to determine if a system supports KVM virtualization

QEMU - Overview

00:03:40

Lesson Description:

In this lesson, we will take a look at QEMU, a type-2 hypervisor that can leverage KVM for acceleration to create a robust, feature-rich type-1 hypervisor. Reference Links QEMU QEMU documentation - QEMU QEMU System Emulation User’s Guide — QEMU Understanding QEMU devices - QEMU QEMU - Overview What is QEMU? From qemu.org: "QEMU is a generic and open source machine emulator and virtualizer." QEMU is a type-2 hypervisor that runs in user space. When used with KVM, it accelerates the performance of a QEMU guest and the combination becomes a type-1 hypervisor. How does QEMU do this? QEMU is a user space program that has two modes:Emulation (software) Slower as software must perform hardware emulation Type-2 HypervisorVirtualization (software+hardware) Hardware acceleration using KVM Type-1 HypervisorQEMU creates one process for every VM, and a thread for each vCPU. These run in the Linux scheduler. A virtual machine is a collection of processes running on the host. QEMU interacts with KVM in two ways:Memory mapped pages The /dev/kvm device file System Level: Whole KVM subsystem VM Level: One specific VM vCPU Level: One specific vCPUQEMU - Devices QEMU and the /dev/kvm interface combine to provide the resources the guest operating system requires: Key hardware:Virtual CPU(s) Virtual Memory Virtual Disk(s) Virtual NetworkingMapped physical resources:Networking: IP StorageGPU(s)Other resources:Virtual media: CD/DVD/ISO imagesUSB Sound VideoQEMU - Paravirtualization QEMU/KVM provides paravirtualization support Two parts:Provides a software interface that looks like hardware VirtIO drivers for the guest operating systemOffloads some “challenging” processes from the guest to the host: Uses the VirtIO APIEthernet Storage Memory balloon device DisplayDisk Image Formats Read-WriteQEMU - Copy-On-Write (.qcow2, .qed, .qcow, .cow) VirtualBox Virtual Disk Image (.vdi) Virtual PC Virtual Hard Disk (.vhd) Virtual VFAT A virtual drive with a FAT filesystem Quick way to share files between guest and hostVMware Virtual Machine Disk (.vmdk) Raw images (.img) These contain sector-by-sector disk contentsBootable CD/DVD Images (.iso)Read-OnlymacOS Universal Disk Image Format (.dmg) Bochs Linux cloop Compressed image formatParallels disk image (.hdd, .hds)QEMU Emulation SupportIA-32 (x86) PCs x86-64 PCs MIPS64 Release 6 and earlier variants Sun's SPARC sun4m Sun's SPARC sun4u ARM development boards (Integrator/CP and Versatile/PB) SH4 SHIX board PowerPC (PReP and Power Macintosh) ETRAX CRIS MicroBlaze RISC-VIn this lesson, we covered:What QEMU is How QEMU works Devices under QEMU Paravirtualization QEMU support for virtual disk formats QEMU emulation support

What Is libvirt?

00:02:37

Lesson Description:

In this lesson, we will learn about libvirt and its role in the QEMU/KVM virtualization stack. Reference Links libvirt: The virtualization API libvirt: KVM/QEMU hypervisor driver libvirt: Internal drivers libvirt: Supported host platforms libvirt: Applications using libvirt Libvirt Wiki libvirt: Downloads libvirt: Documents FAQ - Libvirt Wiki Cockpit - Virtual Machines Management Tools - KVM What is libvirt? From the libvirt project: libvirt:is a toolkit to manage virtualization platforms is accessible from C, Python, Perl, Java and more is licensed under open source licenses supports KVM, QEMU, Xen, Virtuozzo, VMWare ESX, LXC, BHyve and more targets Linux, FreeBSD, Windows and OS-X is used by many applicationsHow does libvirt work? From the libvirt project: "Libvirt is collection of software that provides a convenient way to manage virtual machines and other virtualization functionality, such as storage and network interface management. These software pieces include an API library, a daemon (libvirtd), and a command line utility (virsh). An primary goal of libvirt is to provide a single way to manage multiple different virtualization providers/hypervisors. For example, the command 'virsh list --all' can be used to list the existing virtual machines for any supported hypervisor (KVM, Xen, VMWare ESX, etc.) No need to learn the hypervisor specific tools!" libvirt - Virtualization Platform SupportLinux Windows macOS FreeBSDlibvirt - Hypervisor Support The hypervisor drivers currently supported by libvirt are:LXC Linux ContainersOpenVZ QEMU Test Used for testingVirtualBox VMware ESX VMware Workstation/Player Xen Microsoft Hyper-V Virtuozzo Bhyve - The BSD HypervisorWe will take a look at these end-user management tools supported by libvirt on Linux:Virtual Machine Manager - 'virt-manager' Cockpit / Web Console Via pluginCLI - 'virsh' oVirt / RHEVIn this lesson, we covered:What libvirt is What function libvirt plays in QEMU/KVM virtualization Which virtualization platforms libvirt supports Which hypervisor drivers are supported by libvirt

Configuring the Workstation Lesson Environment

How to Create the CentOS 8 Workstation Lesson Environment From Scratch

00:09:56

Lesson Description:

You will need to install CentOS 8 on your computer if you want to follow along with the lessons. In this lesson, I will walk through the installation of CentOS 8 and, optionally, 'xrdp', for remote desktop connections. You can use this guide to either install on physical hardware or set up an "alternate" environment, should you choose. Reference Links Download CentOS 8: CentOS Mirrors List Create USB Key: Making Installation USB Media on Linux :: CentOS Docs Site Making Installation USB Media on Windows :: CentOS Docs Site Making Installation USB Media on Mac OS X :: CentOS Docs Site How to Create the CentOS 8 Workstation Lesson Environment From Scratch We will need a CentOS 8 Boot ISO for installation Download the latest CentOS 8 Boot ISO (...-boot.iso) from the mirror list above. We will need to create a USB or optical installation media if we are installing on physical hardwareCreate either a CentOS USB installation key or a CD/DVD installation disc. Boot your computer from your installation media.On the way up, check your BIOS to make sure that virtualization is enabled:Intel VT-x AMD-VFor more information configuring these on your computer, reference the appropriate documentation for your particular system. Install CentOS 8. Choose the 'Workstation' option. Set the 'root' password and create the 'cloud_user' account. Reboot.Log in as 'cloud_user'.Before we install anything, we'll confirm we have virtualization support:

lscpu | grep Virtualization
Optional - Install the xrdp service to provide RDP access, if you'd like.Set up the epel-release repository:
sudo dnf -y install epel-release
Install the xrdp service
sudo dnf -y install xrdp
Configure the xrdp service to start at boot, and start it:
sudo systemctl enable xrdp --now
sudo systemctl status xrdp
Configure the firewall to allow traffic for the xrdp serviceLet's check the firewall status:
sudo firewall-cmd --list-all
Add a rule to allow traffic on port 3389:
sudo firewall-cmd --zone=public --add-port=3389/tcp --permanent
Activate the new firewall configuration:
sudo firewall-cmd --reload
Once more, check the firewall status:
sudo firewall-cmd --list-all
Now you can test a connection with your RDP client of choice.Our CentOS 8 Workstation installation is complete!

Using 'virt-manager' in a CentOS 8 GUI Environment

Introduction to 'virt-manager'

00:02:37

Lesson Description:

In this lesson, we will take a look at the Virtual Machine Manager (virt-manager), which is a graphical utility that we can use to manage guest virtual machines that run on QEMU/KVM hypervisors. Reference LinksVirtual Machine Manager Home Virtual Machine Manager - Wikipedia How to run virtual machines with virt-manager - Fedora Magazine Getting Started with Virtual Machine Manager Red Hat Enterprise Linux 7 | Red HatIntroduction to 'virt-manager' What is 'virt-manager'? From the Virtual Machine Manager website: "The virt-manager application is a desktop user interface for managing virtual machines through libvirt. It primarily targets KVM VMs, but also manages Xen and LXC (Linux Containers). It presents a summary view of running domains, their live performance, and resource utilization statistics. Wizards enable the creation of new domains, and configuration and adjustment of a domain’s resource allocation and virtual hardware. An embedded VNC and SPICE client viewer presents a full graphical console to the guest domain." Virtual Machine Manager (virt-manager) functionality:Creates, edits, starts, and stops guest VMs Provides console access for guest VMs Provides operating metrics for guest VMs Displays the current status of virtualization hosts and guest VMs Provides a choice of hypervisors Supports LXC containersHow does 'virt-manager' work? Virtual Machine Manager runs in a user space and leverages libvirt to access the underlying hypervisor(s). Because of this, virt-manager doesn't have to know how to *"talk to"* each particular hypervisor, it only has to communicate with libvirt via the libvirtd service on each host. Linux Distribution Support The virt-manager package is available for:Arch Linux CentOS Debian Fedora FreeBSD via Ports collectionFrugalware Gentoo Mandriva Linux NetBSD via pkgsrcOpenBSD via Ports collectionopenSUSE Red Hat Enterprise Linux Deprecated in 8, but still around Web Console / Cockpit will be the replacement Still can't do everything yetScientific Linux Trisquel TrueOS Ubuntu Void LinuxIn this lesson, we covered:What the Virtual Machine Manager (virt-manager) is The functionality of virt-manager How virt-manager works Linux distribution support for virt-manager

Installing and Configuring 'virt-manager' on CentOS 8

00:08:29

Lesson Description:

The Virtual Machine Manager (virt-manager) is a desktop virtual machine manager that gives users a graphical user interface to manage virtual machines. In this lesson, we will walk through installing and configuring virt-manager on CentOS 8. Installing and Configuring 'virt-manager' on CentOS 8 Install 'virt-manager' and associated components:First, let's become root:

sudo su -
Show installation information:
dnf groupinfo Virtualization Client
Observe the packages in the group:Mandatory / Default / OptionalInstall the 'Virtualization Client' group:
dnf -y group install --with-optional Virtualization Client
Configure the cloud_user user and libvirtd to allow non-root access:Let's edit /etc/libvirt/libvirtd.conf:
vi /etc/libvirt/libvirtd.conf
Assign the domain socket group ownership:unix_sock_group = "libvirt"Let's give the libvirt group R/W access to the socket:unix_sock_rw_perms = "0770"Now, let's add cloud_user to the libvirt group:
usermod -a -G libvirt cloud_user
We need to log out and log back in now to pick up the changes.Validate the installationConfirm libvirtd is enabled and running:
systemctl status libvirtd
Confirm KVM kernel modules are loaded:
lsmod | grep -i kvm
Confirm KVM supportConfirm that the /dev/kvm device exists:
ls -la /dev/kvm
Check for Intel VT-x / AMD-V support in the processor:
egrep "svm|vmx" /proc/cpuinfo
Let's take a quick tour!In this lesson, we covered:Installation of virt-manager and associated packages Validating the installation and KVM support A quick tour of virt-manager

Creating a Virtual Machine Using 'virt-manager'

00:10:27

Lesson Description:

The Virtual Machine Manager (virt-manager) is a desktop virtual machine manager that gives users a graphical user interface to manage virtual machines. In this lesson, we will walk through creating a new virtual machine using 'virt-manager'. Reference Links CentOS Mirrors List Creating a Virtual Machine Using 'virt-manager'The first thing we need to do is download the CentOS 8 Boot ISO for installation:Open Firefox, and paste the link for the CentOS Mirrors List found above into the URL location and go there. Choose a mirror, then Download the Boot ISO (should be about 600M). Save the file. This will be in the cloud_user Downloads directory (/home/cloud_user/Downloads).Next, let's use the ISO to create a new virtual machine:Open Virtual Machine Manager. Click on the Create a new virtual machine icon in the upper left-hand corner, under the File menu. Virtual Machine Manager will open the "New VM" wizard. Select Local install media and click Forward. We need to select the Boot ISO file we downloaded. Click on the Browse button. This will open the Choose Storage Volume window. Click on the Browse Local button. This will open the Locate ISO media window. Select Downloads from the left-hand column, where the directories are located. You should see the CentOS 8 Boot ISO. Make sure it is selected. Click on the Open button in the top right-hand corner of the window. Uncheck Automatically detect from the installation media/source. Type "Generic" in the search box. Select Generic default. Click on the Forward button. Set the memory setting to what you can spare - 1G or more should be good. Set CPUs to a minimum of 1. Click on the Forward button. Next, we'll create a disk image. Set this to 10Gib. Click on the Forward button. Set the name to centos-8-vm. Check the Customize configuration before install box. Click the arrow next to Network selection*. Use the *Virtual network 'default' option. Click the Finish button. You will be presented with the overall hardware configuration. We will walk through all the options. We'll keep the virtual machine as configured, with the following exceptions: Set the disk controller for the virtual disk "IDE Disk 1" to "VirtIO" Advanced options --> Disk bus:Set the virtual network adapter to 'virtio': Network sourceStart the installation. Click the Begin Installation button in the upper left-hand corner of the window. Set the virtual console to fullscreen. Skip installation media testingIt might take a while to boot. Be patient.Walk through the installation. Make sure you select the following:Time & Date Time zone (same as the parent server)Network & Host Name Turn on network Set the hostname to centos-8-vmSoftware Selection Select Minimal InstallInstallation Destination Use defaults. Click on the 10GiB disk you created.Once these have been selected, the Begin Installation button in the lower right-hand corner should be blue. Click it.During the installation, configure the following:Set the root password to the same as the parent VM, or whatever you want Create the cloud_user user: Full name: Cloud User User name: cloud_user Check Make this user administrator Check Require a password to use this account Set a password for the account: You can either use the same password as the cloud_user account on the parent server or set your ownOnce the installation is complete, reboot the VM. Once the VM is back up, log in as the cloud_user user with the password you created and power down the VM:

sudo systemctl poweroff
Close the VM console window.In this lesson, we covered:Using virt-manager to create a new guest VM A minimal installation of CentOS 8

Managing a Virtual Machine Using 'virt-manager'

00:08:27

Lesson Description:

The Virtual Machine Manager (virt-manager) is a desktop virtual machine manager that gives users a graphical user interface to manage virtual machines. In this lesson, we will walk through some common tasks we might want to perform on a virtual machine, using Virtual Machine Manager. Managing a Virtual Machine Using 'virt-manager' Changing the system stateNow that we have a fresh installation of CentOS 8 (minimal), let's patch it before we use it. Start the virtual machine: Log in as 'cloud_user'Patch the virtual machine.

sudo dnf -y update
Shut the virtual machine down. Use the Virtual Machine --> Shut Down --> Shut Down option.Clone VM Our Web Developer has requested a new server for development on a new project. Let's clone a new server for them.In the GUI, right-click on the centos-8-vm VM and select Clone. Set the Name to 'centos-8-webserver' and leave the rest as defaults.VM Snapshot Bring the clone up. Our Web Developer asked us for the NGINX web server on this cloned server. We're going to install NGINX. First, though, let's take a snapshot of this cloned server, just in case.Click on Manage VM Snapshots, then in the lower left-hand corner, click on the + button.Give the snapshot the name of Safety_Net and leave the rest as defaults. We have a point in time snapshot now, just in case. Go back to the console.Confirm that NGINX IS NOT installed:
dnf list installed | grep -i nginx
Install NGINX:
sudo dnf -y install nginx
Confirm that NGINX IS installed:
dnf list installed | grep -i nginx
Fantastic! We're good! At least, until after lunch, when we get an e-mail from our Web Developer, asking for Apache Web Server, instead. Not a problem, we took a snapshot. Roll back.Click on Manage VM Snapshots, then in the lower left-hand corner, click on the play button. Go back to the console.Confirm that NGINX IS NOT installed:
dnf list installed | grep -i nginx
Now we're good to install Apache Web Server.
sudo dnf -y install httpd
sudo systemctl enable httpd
sudo systemctl start httpd
sudo systemctl status httpd
curl http://127.0.0.1
Now we have a fresh and functional installation of Apache!Modify Virtual Hardware As part of this deployment of the new web server, we have been asked to increase the RAM from 4GB to 8GB.Shut down the server, then click on the button that looks like a light bulb, the 'Show virtual hardware details' button), and select 'Memory'. Adjust this from 4096 to 8192. Bring the server back up.When the server is up, log in as 'cloud_user' and check the memory:
more /proc/meminfo
We should see 8GB RAM.We now have a happy Web Developer! Almost. In this lesson, we covered:Using virt-manager to change the state of a guest VM. Cloning a virtual machine with virt-manager. Managing VM snapshots with virt-manager. Modifying virtual hardware settings with virt-manager.

Managing Networking Using 'virt-manager'

00:06:28

Lesson Description:

The Virtual Machine Manager (virt-manager) is a desktop virtual machine manager that gives users a graphical user interface to manage virtual machines. In this lesson, we will walk through configuring an additional network interface and will add a new virtual network and connect to it. Managing Networking Using 'virt-manager' Adding a virtual network interface Our webserver virtual machine has a network connection to the 'default' NAT network. This allows the server to access the outside world. Our Web Developer needs to be able to access the web server via the public internal network. Let's add a network interface that connects directly to the 'public' internal network.Show the available networks on the host:

ip addr
Display the network configuration files:
ls -al /etc/sysconfig/network-scripts
Go to 'Virtual Hardware Details'. In the bottom left-hand corner, click on the Add Hardware button. On the left-hand side of the Add New Virtual Hardware window, click on Network. We're going to add a 'macvtap' device on the physical adapter we want to use: Source mode: Bridge Leave MAC address as-is Device model: virtioClick on Finish. Show the available networks on the host:
ip addr
If you have another host on the network, try to SSH as 'cloud_user' to the new IP:
ssh cloud_user@IP_ADDRESS
If you have another host on the network, try to connect to it with a web browser at the new IP. We need to add a firewall rule to allow HTTP traffic:
sudo firewall-cmd --zone=public --add-service=http --permanent
sudo firewall-cmd --reload
Now that our firewall is configured to allow HTTP traffic, try to connect to the new IP address again from a web browser.Adding / connecting to a virtual network As we start to add new virtual servers, we want to monitor them, and as part of that, we want to create a management network on our host. Let's create a new virtual network and connect our VM to it.Close the window for the centos-8-webserver VM. Click on the QEMU/KVM hypervisor. Right-click on this, select Details. Choose Virtual Networks. You will see the default network Click on the + button in the lower left-hand corner. In the 'Create a new virtual network' wizard, set the following: Name: Management_NetMode: Isolated IPv4 configuration: KEEP DEFAULTS IPv6 configuration: LEAVE DISABLED DNS domain name: KEEP DEFAULTSClick on Finish. Open the VM console window. Show the available networks on the host:
ip addr
Let's add a new interface to connect to the new 'Management_Net' network. Go to 'Virtual Hardware Details'. In the bottom left-hand corner, click on the Add Hardware button. On the left-hand side of the Add New Virtual Hardware window, click on Network. We're going to add a macvtap device on the physical adapter we want to use: Network source: Virtual network 'Management_Net' : Isolated network Leave MAC address as-is Device model: virtioClick on Finish. Go back to the console window. Show the available networks on the host.:
ip addr
We now have a connection to the isolated Management_Net network!In this lesson, we covered:Using virt-manager to add a virtual network interface. Creating a new virtual network with virt-manager. Connecting the VM to the new virtual network.

Managing Storage Using 'virt-manager'

00:06:22

Lesson Description:

The Virtual Machine Manager (virt-manager) is a desktop virtual machine manager that gives users a graphical user interface to manage virtual machines. In this lesson, we walk through two common storage operations: adding a virtual disk and attaching and mounting an ISO image. Managing Storage Using virt-manager Adding a virtual disk to a virtual machine Our web developer has requested a dedicated directory for his content. We don't want to rob from the operating system, so we're going to add a new virtual disk.Take a look at the LVM configuration:

sudo pvs
sudo lvs
sudo vgs
ls -al /dev/vd*
Add a new virtual disk to the VM. Check for the new virtual disk:
ls -al /dev/vd*
Take a look at the partition table of the new virtual disk:
sudo fdisk -l /dev/vdb
Create a new physical volume:
sudo pvcreate /dev/vdb
Add the new virtual disk to a new volume group, web-vg:
sudo vgcreate web-vg /dev/vdb
Create a new logical volume, web-content:
sudo lvcreate -L 5G -n web-content web-vg
Take another look at the LVM configuration:
sudo pvs
sudo lvs
sudo vgs
Format the new logical volume:
sudo mkfs.xfs /dev/mapper/web--vg-web--content
Create the new mountpoint, /web:
sudo mkdir /web
Edit /etc/fstab, add a mount for the web-content LV at /web:
sudo vi /etc/fstab
Mount the new LV:
sudo mount -a
Confirm that the /web filesystem is mounted:
df -h
Attach an ISO disk image to a virtual machineAttach the ISO to the virtual machine. Check for the CDROM device:
ls -la /dev/sr0
Confirm that the /mnt directory is empty:
ls -la /mnt
Mount the ISO on /mnt:
sudo mount /dev/sr0 /mnt
Show the contents of the ISO:
ls -al /mnt
Unmount the ISO from /mnt:
sudo umount /mnt
Remove the ISO from the VM via virt-manager.Now, we have a happy Web Developer! In this lesson, we covered:Using virt-manager to add a virtual disk. Configuring the new virtual disk using LVM. Formatting and mounting the new logical volume. Connecting an ISO file to the virtual media drive and mounting it.

Managing Virtual Machines Using Cockpit/Web Console

Introduction to Cockpit/Web Console

00:02:36

Lesson Description:

In this lesson, we will take a look at Cockpit/Web Console, which is a web application that we can use to manage not only the host but the guest virtual machines that run on QEMU/KVM hypervisors. Reference LinksCockpit Project Cockpit Guide Cockpit - Virtual Machines Cockpit - Multiple Hypervisors Is Cockpit Secure? — Cockpit ProjectIntroduction to Cockpit / Web Console What is Cockpit/Web Console? From the Cockpit Project website: "The easy-to-use, integrated, glanceable, and open web-based interface for your servers." Cockpit and Web Console are the same thing. Cockpit is the upstream project that feeds Web Console in the RHEL offering. Cockpit Functionality Cockpit/Web Console can:Create, edit, start and stop guest VMs Provide console access for guest VMs Provide basic operating metrics for guest VMs Display the current status of guest VMs Provide a choice of hypervisors: SSH connection/keys Manual configurationSupport LXC containers: CentOS 7, no 8 yetFor RHEL distributions, Cockpit is the way forward. Virtual Machine Manager is deprecated. How Does it Work? How does Cockpit work? Cockpit runs in the user space and leverages a plugin to use libvirt to access the underlying hypervisor. Because of this, Cockpit doesn't have to know how to "talk to" the hypervisor, it only has to communicate with libvirt via the libvirtd service. From the Cockpit Project website: "Cockpit can manage virtual machines running on the host. These can be accessed from menu via Virtual Machines. Primary datasource is QEMU / Libvirt, access to Libvirtd is wrapped either by the virsh tool or libvirt D-Bus API bindings, depending on if the latter is installed on the system." Cockpit is a web application. Cockpit can be accessed via a web browser on port 9090 on the host machine. Recommended browsers include Mozilla Firefox, Google Chrome, and Microsoft Edge. Linux Distribution Support The Cockpit package is available for:Fedora RHEL Web ConsoleCoreOS Atomic CentOS Debian Ubuntu Clear Linux Arch LinuxIn this lesson, we covered:What Cockpit/Web Console is The functionality of Cockpit How Cockpit works Linux distribution support for Cockpit

Installing and Configuring Cockpit on CentOS 8

00:12:19

Lesson Description:

Description Cockpit is a web-based management utility that gives users a web interface to manage their server. Using the 'cockpit-machines' plugin, you can use Cockpit to manage virtual machines as well. In this lesson, we will walk through installing and configuring Cockpit on CentOS 8 and will take a quick tour of Cockpit, focusing on the 'Virtual Machines' pane. Reference Links Cockpit:Running Cockpit - Cockpit Project Virtual Machines - Cockpit Project Multiple Machines - Cockpit ProjectCentOS:CentOS Mirrors List Preparing for your installation :: CentOS Docs Site HowTos/InstallFromUSBkey - CentOS WikiInstalling and Configuring Cockpit on CentOS 8 We're going with a leaner, more "server-like" version of CentOS 8 for the Cockpit and CLI sections. Start with a fresh CentOS 8 'minimal' installation on your computer, then proceed with the lesson. If you need a refresher, see the "How to Create the CentOS 8 Workstation Lesson Environment From Scratch" lesson. Install 'cockpit' and the 'cockpit-machines' plugin By default, Cockpit is installed on many Redhat distributions. You can check to see if it is installed by running:

sudo dnf list installed | egrep -i "cockpit|virt"
This will also check for virtualization packages.We will need to install libvirt, the cockpit, and cockpit-machines packages and any dependencies:
sudo dnf -y install libvirt cockpit cockpit-machines
Now would also be a good time to check for updates:
sudo dnf -y update
Confirm that the firewall is configured to allow Cockpit traffic to pass:
sudo firewall-cmd --list-all
You should see cockpit listed in services. If it is not, execute the following to allow communication:
sudo firewall-cmd --zone=public --add-service=cockpit --permanent
sudo firewall-cmd --reload
Configuring Permissions for Non-root Users We need to do some work to make Cockpit work for non-root users:Let's add cloud_user to the libvirt group:
sudo usermod -a -G libvirt `id -un`
Add cloud_user to the libvirtdbus group:
sudo usermod -a -G libvirtdbus `id -un`
Add the libvirtdbus user to the libvirt group:
sudo usermod -a -G libvirt libvirtdbus
Add the qemu user to the libvirt group:
sudo usermod -a -G libvirt qemu
Start Everything! Now, let's start the cockpit.socket and libvirtd services:Enable and start Cockpit:
sudo systemctl enable cockpit.socket --now
Check the status of cockpit.socket:
sudo systemctl status cockpit.socket
Enable and start libvirtd:
sudo systemctl enable libvirtd --now
Check the status of libvirtd:
sudo systemctl status libvirtd
Virtual Disk Storage Location By default, virtual disks are stored in /var/lib/libvirt/images. This is in the root (/) filesystem. We don't want to fill this filesystem up, so we're going to create a directory on the /home filesystem to store virtual disks. Create a dedicated directory for our virtual disks:Create the directory:
sudo mkdir /home/Virtual_Machines
Set the proper ownership:
sudo chown -R qemu:libvirt /home/Virtual_Machines
Set the proper permissions:
sudo chmod 0770 /home/Virtual_Machines
Confirm we have what we want:
sudo ls -la /home
Launch Firefox and connect to Cockpit from another computer on your network on port 9090. Use Firefox if you can, as Chrome will not accept the SSL certificate.Tour the Cockpit web interfaceLog in to the Cockpit web interface using the cloud_user account and take a look around. On the left-hand side, click on the Virtual Machines pane.In this lesson, we covered:Installing cockpit, cockpit-machines, and associated packages Connecting to the Cockpit web interface A quick tour of Cockpit

Creating a Virtual Machine Using Cockpit

00:09:51

Lesson Description:

Description Cockpit is a web-based management utility that gives users a web interface to manage their servers. Using the cockpit-machines plugin, you can use Cockpit to manage virtual machines as well. In this lesson, we will walk through creating a new virtual machine with Cockpit, including installing a 'minimal' CentOS 8 instance. Reference Links CentOS Mirrors List Creating a Virtual Machine Using Cockpit Get the CentOS 8 Boot ISO We will need a CentOS 8 Boot ISO for installationDownload the latest CentOS 8 Boot ISO (...-boot.iso) from the mirror list above. Save or copy it to /tmp on your system.Log in to Cockpit Log in to the Cockpit web interface at http://<YOUR_HOST_IP>:9090 Add the /home/Virtual_Machines directory to the Storage PoolsIn the upper-right hand corner of the 'Virtual Machines' pane, you will see the link to the Storage Pools. Click on this link.In the upper right-hand corner of the 'Storage Pools' pane, you will see a button labeled Create Storage Pool. Click it.Settings:Connection: QEMU/KVM System connection Name: Virtual_Machines Type: Filesystem Directory Target Path: /home/Virtual_Machines Startup: CHECKEDClick Create. You should see your new Virtual_Machines storage pool. Click on the Virtual Machines link in the upper left-hand corner of the pane to go back to the Virtual Machines pane.Create a New Virtual MachineIn the upper right-hand corner of the Virtual Machines pane, click on the Create VM button.We're going to use the following values for the new VM:Connection: QEMU/KVM System connection Name: centos-8-cockpit-vm Installation Source Type: Local Install Media Installation Source: /tmp/CentOS... (exact file name will depend on your download) Storage: No Storage (we will add this later as we are not using the default location) Memory: Set this to an appropriate value for your system OS Vendor: CentOS Operating System: CentOS 7.0 Immediately Start VM: UNCHECKEDClick on the Create button. The Create New Virtual Machine window will disappear, and you will be back in the Virtual Machines pane.Add a Virtual DiskClick on the entry for the new centos-8-cockpit-vm. Click on the Disks tab. Click on the Add Disk button on the right.Set the Add Disk` Settings:Source: Create New Pool: Virtual_Machines Name: centos-8-cockpit-vm Size: Set this to an appropriate value for your system Format: qcow2 Show Performance Options: LEAVE DEFAULT(S)Click on Add.Launch the CentOS 8 InstallationClick on the Consoles tab, then click on the Install button on the right-hand side. This will launch the installation. Click in the console window to enable input.We're going to perform a 'Minimal' CentOS 8 installation. Once the installation is complete, click on the Reboot button in the installer. This will shut down the VM.Start the New VMNow that installation is complete, and the VM is shut down, we can click on Run on the right-hand side and start the new VM.Once the VM is up and running, click on the console window and log in as cloud_user. Let's patch the system if required:

sudo dnf -y update
Shut down the VM:
sudo systemctl poweroff
Congratulations on creating your first VM with Cockpit! In this lesson, we covered:Logging in to Cockpit Adding the Virtual_Machines directory to the storage pools Creating a new virtual machine Installing CentOS 8 “Minimal” Patching the new VM

Managing Virtual Machines Using Cockpit

00:04:46

Lesson Description:

Cockpit is a web-based management utility that gives users a web interface to manage their servers. Using the cockpit-machines plugin, you can use Cockpit to manage virtual machines as well. In this lesson, we will walk through managing our new virtual machine. Managing Virtual Machines Using Cockpit Now that we have our new VM, we'd like to make some changes. We'd like to add CPU cores, memory, and a second disk. If you're not already logged into Cockpit, do so now, and go to the 'Virtual Machines' pane. Add CPU Cores / Memory to the VM Our initial CPU and memory configuration was just fine for installing CentOS, but we'd like to give this virtual machine more resources.Click on centos-8-cockpit-vm. In the Overview tab, click on the value for Memory and adjust the Current Allocation and Maximum Allocation (up if you can spare it, down if not). Click the Save button.Next, click on the value for vCPUs. Adjust the vCPU Count and vCPU Maximum values (up if you can spare it, down if not). Click the Apply button.Click on the Consoles tab and start the VM. Once the server is up, log in as 'cloud_user'.Verify that the memory size is what we adjusted it to:

grep MemTotal /proc/meminfo
Verify that we now have the proper number of vCPUs:
grep -i processor /proc/cpuinfo | wc -l
Looking great so far!Add a Disk to the VM Adding a disk is pretty straightforward. Let's take a look. Before we add our new disk, let's take a look at what we have on the system already:
- List of disks, using `fdisk`:
    ```
    sudo fdisk -l
    ```
- List of virtual disk devices:
    ```
    ls -la /dev/vd*
    ```
In the Disks tab, click on Add Disk.Set the Values:Source: Create New Pool: Virtual_Machines Name: centos-8-cockpit-vm-disk2 Size: BASED ON RESOURCES Format: qcow2 Performance Options: LEAVE AS DEFAULTClick on Add. Click on the Console tab.Let's take a look at what we have now:List of disks, using fdisk:
sudo fdisk -l
List of virtual disk devices:
ls -la /dev/vd*
Pretty cool, eh?Shut down the virtual machine:
sudo systemctl poweroff
That was our quick tour of Cockpit. I hope you enjoyed it!In this lesson, we covered:Adding CPU cores/memory to the virtual machine Adding a disk to the virtual machine

Using the Linux CLI to Manage Virtual Machines

Introduction to Linux CLI Utilities

00:03:22

Lesson Description:

We've looked at two ways we can use libvirt to administer virtual machines via QEMU/KVM, Virtual Machine Manager (virt-manager) and Cockpit. While these were easy to use, sometimes we need the granularity and power that command-line tools provide. Fortunately for us, libvirt has a set of command-line tools to round out our toolkit. In this lesson, we will take a look at the CLI options provided by libvirt. Reference Links libvirt: virsh Introduction to Linux CLI Utilities What is 'virsh'? From the 'libvirt' website: “The virsh program is the main interface for managing virsh guest domains.” 'virsh' Functionality 'virsh' can:Create, edit, start, and stop guest VMs Provide console access for guest VMs Provide basic operating metrics for guest VMs Display the current status of guest VMs Manage virtual networks Manage virtual storage And moreAdditional CLI utilities:virt-install virt-sysprep virt-clone virt-v2vWhy use CLI utilities?More control than other methods Enable scripting/automation No GUI/web browser required: Less overhead Easier to access the CLIMany management utilities leverage 'virsh': Easier to troubleshoot issuesHow does it work? virsh runs in user space and leverages libvirt to access the underlying hypervisor. Because of this, virsh doesn’t have to know how to “talk to” the hypervisor — it only has to communicate with libvirt via the libvirtd service. Interacting with virsh: You can use virsh in one of two ways:From the Linux shell As its own interactive shell: The virsh shellHow does the Cockpit plugin work? “Access to Libvirtd is wrapped either by the virsh tool or libvirt D-Bus API bindings, depending if the latter is installed on the system.” — Cockpit Project Let's get to working with 'virsh'! In this lesson, we covered:What virsh is Companion utilities to virsh The functionality of virsh How virsh works

Installing the CLI Utilities on CentOS 8

00:04:20

Lesson Description:

We've looked at two ways we can use libvirt to administer virtual machines via QEMU/KVM, Virtual Machine Manager (virt-manager) and Cockpit. While these were easy to use, sometimes we need the granularity and power that command-line tools provide. Fortunately for us, libvirt has a set of command-line tools to round out our toolkit. In this lesson, we will take a look at installing the libvirt CLI utilities. Reference Links libvirt: virsh Installing the CLI Utilities on CentOS 8 We've been asked by the DBA team to set up a barebones virtualization environment so they can do some test database migrations away from CentOS 7. We've settled on a minimal CentOS 8 server with Cockpit to provide easy access for the DBA team. We will work "under the hood" with virsh to do the heavy lifting. Since we already have a minimal CentOS 8 server with Cockpit installed and configured, we're good to go. Now, we're going to install the packages we need for CLI administration and will test the installation to make sure it is working. Install packages using dnf/yumInstall the libvirt utilities and dependencies:

sudo dnf -y install qemu-kvm libvirt libguestfs-tools virt-install virt-v2v
These may already be installed from our earlier work on the server.Confirm libvirtd is Enabled and Running Check the status of the libvirtd service:
sudo systemctl status libvirtd
Check the Version of virsh Execute the following:
virsh version
Validate the Host Let's check our host and make sure it meets the requirement for virtualization:
virt-host-validate
Check Bridged NetworkingWe need to confirm that we have one or more bridged networks in place:
sudo virsh net-list
We should see the default network.For more information on the default network, we can look at the XML:
sudo virsh net-dumpxml default
List existing virtual machines Let's take a look at our list of existing virtual machines:
sudo virsh list --all
List existing storage poolsLet's take a look at our list of existing storage pools:
sudo virsh pool-list
Let's take a look at a list of volumes in the Virtual_Machines storage pool:
sudo virsh vol-list Virtual_Machines
The 'libvirt' CLI utilities are now installed! In this lesson, we covered:Installing libvirt, virt-install, and other associated packages Validating the installation

Introduction to the 'virsh' Shell

00:08:50

Lesson Description:

We've looked at two ways we can use libvirt to administer virtual machines via QEMU/KVM, Virtual Machine Manager (virt-manager), and Cockpit. While these were easy to use, sometimes we need the granularity and power that command-line tools provide. Fortunately for us, libvirt has a set of command-line tools to round out our toolkit. In this lesson, we will take a look at the virsh shell, the core utility for managing virtual machines from the CLI using libvirt. Reference Links libvirt: virsh libvirt: Domain XML format Introduction to the 'virsh' Shell Before we start working with virtual machines, let's take a look at the virsh shell and our virtualization environment. Using the 'virsh' shell The virsh commands can either be executed from within the virsh shell or independently from the Linux shell. We're going to take a look at executing commands from within the virsh shell. Basic 'virsh' commandsFirst, enter the virsh shell:

sudo virsh
Demonstrate basic virsh commands within the virsh shell**Help information - 'help' Version information - 'version' List guest domains - 'list --all' start / shutdown / reboot / suspend / resume Show CPU information - 'vcpuinfo centos-8-cockpit-vm' / 'vcpucount centos-8-cockpit-vm' Show VNC information - 'vncdisplay centos-8-cockpit-vm' 'exit' / 'quit'Domain monitoring commands Information:Get basic domain information — dominfo centos-8-cockpit-vm Get state information on a guest domain —domstate centos-8-cockpit-vm Get block device size — domblkinfo centos-8-cockpit-vm --all Get network interface list — domiflist centos-8-cockpit-vm Convert a domain name or UUID to domain id — domid centos-8-cockpit-vm Convert a guest domain id or UUID to a guest domain name — domname ID Convert a guest domain name or id to guest domain UUID — domuuid ID Output guest domain information as XML — dumpxml IDStatistics:Get block device stats — domblkstat centos-8-cockpit-vm Get network interface stats — domifstat --domain centos-8-cockpit-vm vnet0 Get memory statistics — dommemstat centos-8-cockpit-vmHost and hypervisor commandsDisplay the capabilities of a hypervisor — capabilities Display the hostname of the hypervisor host — hostname Display basic information about the node — nodeinfo Display the hypervisor URI — uriThat's it! Pretty easy to use, huh? In this lesson, we covered:Using the virsh shell Basic virsh commands Domain monitoring commands Host and hypervisor commands

Using 'virt-install' to Create a Virtual Machine

00:05:59

Lesson Description:

We've looked at two ways we can use libvirt to administer virtual machines via QEMU/KVM, Virtual Machine Manager (virt-manager), and Cockpit. While these were easy to use, sometimes we need the granularity and power that command-line tools provide. Fortunately for us, libvirt has a set of command-line tools to round out our toolkit. In this lesson, we will use the virt-install command to create a new CentOS 7 virtual machine. Reference Links libvirt: virsh CentOS 7 Mirror Using virt-install to Create a Virtual Machine Our DBA team has put in a request for a new CentOS 7 virtual machine. We want to create a CentOS 7 template to deploy this virtual machine, so we can deploy more VMs later if we need to. We're going to install using a serial console and a text-based installer, installing directly from the CentOS 7 mirror.Let's launch a CentOS 7 installation using virt-install:

sudo virt-install --name=centos-7-cli-vm --vcpus=1 --memory=2048 --location http://mirror.centos.org/centos/7/os/x86_64/ --disk pool=Virtual_Machines,size=10,bus=virtio --os-type linux --os-variant=centos7.0 --network network='default',model=virtio --extra-args='console=ttyS0,115200n8 serial' --nographics
Set the values for vcpus and memory based on your system's resources. The ones above are more than adequate for a Minimal CentOS 7 installation:When we get to the VNC menu, choose 'Use text mode', choice number 2. When you get to the 'Installation' menu, complete the sections with a [!] next to them. You can leave the ones with an [x] next to them as-is if you wantStart the installation. Once the installation is complete, press return to exit. The virtual machine will reboot.When the VM comes back up, log in as cloud_user. Patch the VM:
sudo yum -y update
When patching is complete, log out of the system. Use CTRL+] to exit the virsh console.Check out the New Virtual Machine using 'virsh'Let's take a look for our new virtual machine in our list of existing virtual machines:
sudo virsh list --all
Let's take a look for our new virtual disk in the Virtual_Machines storage pool:
sudo virsh vol-list Virtual_Machines
Check out the new virtual machine using Cockpit Log in to the Cockpit web console at http://YOUR_COMPUTER_IP:9090 as cloud_user. On the left-hand side, click on Virtual Machines to go to that pane. Click on your new virtual machine and check out the details. Check out the text console. Congratulations on your new virtual machine, created with virsh! In this lesson, we covered:Using virt-install to create a new virtual machine Launching a text-mode OS install in the virsh serial console Installing CentOS 7 Minimal Checking out the new VM: virsh Cockpit

Using 'virsh' to Manage Virtual Devices

00:10:37

Lesson Description:

We've looked at two ways we can use libvirt to administer virtual machines via QEMU/KVM, Virtual Machine Manager (virt-manager), and Cockpit. While these were easy to use, sometimes we need the granularity and power that command-line tools provide. Fortunately for us, libvirt has a set of command-line tools to round out our toolkit. In this lesson, we will take a look at using virsh to manage virtual devices. Reference Links libvirt: virsh Using virsh to Manage Virtual Devices As part of the preparation of our new CentOS 7 virtual machine template for the DBA team, we need to modify the virtual machine's configuration. Connecting to the 'virsh' serial console We used a serial console when we installed CentOS 7. Let's take a look at how to connect and disconnect from the serial console, in case we need a console connection to our virtual machine. Connect to the console:If the virtual machine isn't started, start the virtual machine:

sudo virsh list --all
sudo virsh start centos-7-cli-vm
Let's connect to the virsh console:
sudo virsh console centos-7-cli-vm
Log in as cloud_user.Disconnect from the console: Use CTRL + ] to exit the virsh console. Attaching an ISO file to a virtual machine Sometimes we need to attach a disk image file to the virtual cdrom drive. We can do that from the command line using virsh. Let's attach our CentOS 8 Boot media in /tmp to our 'centos-8-cockpit-vm' domain.Start the centos-8-cockpit-vm domain, if it's not already running:
sudo virsh list --all
sudo virsh start centos-8-cockpit-vm
Confirm the virtual media drive device name:
sudo virsh domblklist centos-8-cockpit-vm
Attach the ISO file:
sudo virsh change-media centos-8-cockpit-vm sda /tmp/CentOS-8.1.1911-x86_64-boot.iso --insert --live
This will attach the CentOS 8 Boot ISO. If your ISO has a different name, substitute it.Log into the centos-8-cockpit-vm virtual machine via SSH as 'cloud_user'. We will need to get the IP address of the VM:
sudo virsh net-dhcp-leases default
Let's confirm that we can mount the ISO. First, check for the virtual disk drive:
ls -la /dev/sr0
Confirm that the device exists. Let's check that the /mnt directory is empty so we can use it as a mount point:
ls -la /mnt
If it is empty, go ahead and mount the ISO to /mnt:
sudo mount /dev/sr0 /mnt
Confirm that the ISO file is mounted:
df -h | grep mnt
ls -al /mnt
We're not going to install any software at this point; this was just practice.Unmount the ISO file:
sudo umount /mnt
Log out of the virtual machine.Detach the ISO file from the virtual media drive:
sudo virsh change-media centos-8-cockpit-vm sda --eject
Confirm it was ejected:
sudo virsh domblklist centos-8-cockpit-vm
Shut down the centos-8-cockpit-vm domain:
sudo virsh shutdown centos-8-cockpit-vm
sudo virsh list --all
Edit guest domain XML file A virtual machine's configuration is stored in an XML file in /etc/libvirt/qemu/. We can edit it directly using the virsh edit command. We gave our virtual machine plenty of memory for installation, but it's going to require more memory and CPUs to serve as a database server.Before we make any edits, we will need to shut down the guest:
sudo virsh shutdown centos-7-cli-vm
We can adjust these by editing the XML configuration file for our virtual machine:
sudo virsh edit centos-7-cli-vm
Change the virtual memory size Adjust the virtual memory to 8GB (or whatever your system can spare) Adjust the number of vCPUs Adjust the number of vCPUs to 4 (or whatever your system can spare) Apply the changes Save the new configuration.Start the domain:
sudo virsh start centos-7-cli-vm
Connect to the virsh console:
sudo virsh console centos-7-cli-vm
Log in as 'cloud_user'.Confirm the memory and CPU count via the operating system:
grep -i processor /proc/cpuinfo | wc -l
grep MemTotal /proc/meminfo
Log out and disconnect from the console. Use CTRL+] to exit the virsh console.Confirm the changes via virsh:
sudo virsh dominfo centos-7-cli-vm
Congratulations, you're one step closer to handing over the virtual machine to the DBA team! In this lesson, we covered:Connecting to the virsh serial console Attaching an ISO file to a virtual machine Editing a guest domain XML file: Changing the virtual memory size Adjusting the number of vCPUs

Managing Virtual Storage Using 'virsh'

00:16:29

Lesson Description:

We've looked at two ways we can use libvirt to administer virtual machines via QEMU/KVM, Virtual Machine Manager (virt-manager), and Cockpit. While these were easy to use, sometimes we need the granularity and power that command-line tools provide. Fortunately for us, libvirt has a set of command-line tools to round out our toolkit. In this lesson, we will take a look at managing virtual storage using virsh. Reference Links libvirt: Storage Management libvirt: virsh Managing Virtual Storage Using virsh The virsh command enables us to manipulate storage pools, volumes, and snapshots. Our DBA team has requested five additional storage volumes for the new CentOS 7 database VM. We want to create these in a new storage pool so we can manage and track the DBA team's storage resources in one place. We will also take a snapshot of our virtual machine after we add the storage, in case we need to roll back. Managing Storage Pools Using virsh We are going to create a new storage pool for the DBA team.Let's take a look at our current inventory of storage pools:

sudo virsh pool-list --all
Let's create a new storage pool for the DBA team:
sudo virsh pool-define-as DBA_Team dir - - - - "/home/DB_Virtual_Machines"
Let's take a look at our current inventory of storage pools:
sudo virsh pool-list --all
Use virsh pool-build to build the storage pool:
sudo virsh pool-build DBA_Team
Confirm we have what we want in /home:
sudo ls -la /home
Let's set our new storage pool to autostart:
sudo virsh pool-autostart DBA_Team
We will need to start the storage pool:
sudo virsh pool-start DBA_Team
Now, let's take a look at our current inventory of storage pools:List storage pools:
sudo virsh pool-list --all
Get pool information for 'DBA_Team':
sudo virsh pool-info DBA_Team
Now the DBA team has a place to keep their VMs and storage volumes.Managing Volumes Using 'virsh' Next, we will need to create five new storage volumes, attach them to the virtual machine, and confirm they are accessible to the operating system.Use virsh to create five 10G volumes, named as follows:
sudo virsh vol-create-as DBA_Team centos-7-db1.qcow2 10G --format qcow2
sudo virsh vol-create-as DBA_Team centos-7-db2.qcow2 10G --format qcow2
sudo virsh vol-create-as DBA_Team centos-7-db3.qcow2 10G --format qcow2
sudo virsh vol-create-as DBA_Team centos-7-db4.qcow2 10G --format qcow2
sudo virsh vol-create-as DBA_Team centos-7-db5.qcow2 10G --format qcow2
Let's take a look at our new volumes:
sudo virsh vol-list DBA_Team
Let's take a look at the files backing them:
ls -la /home/DB_Virtual_Machines
Let's take a look at the list of virtual disk devices on our virtual machine:
sudo virsh domblkinfo centos-7-cli-vm --all
Get the next virtual device name. It should be /dev/vdb.Before we make any edits, we will need to shut down the guest:
sudo virsh shutdown centos-7-cli-vm
Now, let's attach these volumes to the virtual machine:
sudo virsh attach-disk centos-7-cli-vm --source /home/DB_Virtual_Machines/centos-7-db1.qcow2 --target vdb --cache none --driver qemu --subdriver qcow2 --config
sudo virsh attach-disk centos-7-cli-vm --source /home/DB_Virtual_Machines/centos-7-db2.qcow2 --target vdc --cache none --driver qemu --subdriver qcow2 --config
sudo virsh attach-disk centos-7-cli-vm --source /home/DB_Virtual_Machines/centos-7-db3.qcow2 --target vdd --cache none --driver qemu --subdriver qcow2 --config
sudo virsh attach-disk centos-7-cli-vm --source /home/DB_Virtual_Machines/centos-7-db4.qcow2 --target vde --cache none --driver qemu --subdriver qcow2 --config
sudo virsh attach-disk centos-7-cli-vm --source /home/DB_Virtual_Machines/centos-7-db5.qcow2 --target vdf --cache none --driver qemu --subdriver qcow2 --config
Let's take a look at the list of virtual disk devices on our virtual machine:
sudo virsh domblkinfo centos-7-cli-vm --all
Start the domain:
sudo virsh start centos-7-cli-vm
Log in to the virtual machine using virsh console as 'cloud_user':
sudo virsh console centos-7-cli-vm
Confirm that the devices are available to the operating system:
ls -la /dev/vd*
sudo fdisk -l | more
Use CTRL + ] to exit the virsh console. The DBA team hasn't decided exactly how they want the storage configured from here, so we're going to leave it as-is for now.We now have the additional database storage configured! Managing Snapshots Using virsh The DBA team has requested that we install mariadb before we continue. We've done a lot of work at this point, so we'd like to take a snapshot before we install mariadb, just in case.Let's take a look at the list of snapshots for our virtual machine:
sudo virsh snapshot-list centos-7-cli-vm
Now, take a snapshot of the virtual machine:
sudo virsh snapshot-create-as centos-7-cli-vm pre-mariadb
Let's take a look at the list of snapshots for our virtual machine:
sudo virsh snapshot-list centos-7-cli-vm
Now, let's install mariadb on our virtual machine. Connect to the console again:
sudo virsh console centos-7-cli-vm
Install mariadb:
sudo yum -y install mariadb
Let's confirm that mariadb is installed:
sudo yum list installed | grep -i mariadb
Fantastic! We're done here. Use CTRL + ] to exit the virsh console.Well, until the DBA team sends us an e-mail letting us know that they wanted postgresql, not mariadb. Have no fear; we have our snapshot to bail us out!Let's take a look at information about our snapshots:
sudo virsh snapshot-info centos-7-cli-vm --current
Let's roll back our snapshot:
sudo virsh snapshot-revert centos-7-cli-vm --current
Connect to the console again:
sudo virsh console centos-7-cli-vm
Let's confirm that mariadb is NOT installed:
sudo yum list installed | grep -i mariadb
Install postgresql:
sudo yum -y install postgresql
Let's confirm that postgresql is installed:
sudo yum list installed | grep -i postgresql
Fantastic! We're done here. Log out. Use CTRL + ] to exit the virsh console.That snapshot really saved us! We're even closer now to having our database server template! In this lesson, we covered:Managing storage pools using virsh Managing volumes using virsh Managing snapshots using virsh

Managing Virtual Networks Using 'virsh'

00:04:59

Lesson Description:

We've looked at two ways we can use libvirt to administer virtual machines via QEMU/KVM, Virtual Machine Manager (virt-manager), and Cockpit. While these were easy to use, sometimes we need the granularity and power that command-line tools provide. Fortunately for us, libvirt has a set of command-line tools to round out our toolkit. In this lesson, we will take a look at managing virtual networks using virsh. Reference Links libvirt: Network XML format libvirt: virsh Managing Virtual Networks Using 'virsh' The 'virsh' command enables us to manipulate virtual networks and interfaces. Our DBA team has requested a private virtual network to handle private database traffic. They would like every new VM to have a connection to this network. We will create a new network and attach our first virtual machine to it. Creating a Virtual Network Using 'virsh' Create a new file called dba_network.xml with the following contents:

<network>
  <name>private</name>
  <bridge name="virbr2"/>
  <ip address="192.168.11.1" netmask="255.255.255.0">
    <dhcp>
      <range start="192.168.11.2" end="192.168.11.254"/>
    </dhcp>
  </ip>
  <ip family="ipv6" address="2002:c0a8:0b01::c0a8:0b01" prefix="64"/>
</network>
Save and exit. Next, we're going to use virsh net-define to create a new virtual network using our network configuration:
sudo virsh net-define --file dba_network.xml
Let's check our work:
sudo virsh net-list --all
Finally, let's set our network to autostart and start our new network so we can use it: Set network to autostart:
sudo virsh net-autostart private
Start the network:
sudo virsh net-start private
Let's check our work, once more: List networks:
sudo virsh net-list --all
Get information on private:
sudo virsh net-info private
Take a look at the XML configuration for private:
sudo virsh net-dumpxml private
Display DHCP leases on private:
sudo virsh net-dhcp-leases private
If you'd like to get all of the interfaces' addresses for our virtual machine:
sudo virsh domifaddr centos-7-cli-vm
Managing Interfaces Using 'virsh' Now that we have our new 'private' virtual network available let's attach our virtual machine to it. Let's take a look at the currently assigned network interfaces:
sudo virsh domiflist centos-7-cli-vm
Let's attach an interface from our new network to our virtual machine:
sudo virsh attach-interface --domain centos-7-cli-vm --type network --source private --model virtio --config --live
Let's take a look at the currently assigned network interfaces again:
sudo virsh domiflist centos-7-cli-vm
Let's check the operating system for our new interface: Log in to the virtual machine using virsh console as 'cloud_user':
sudo virsh console centos-7-cli-vm
Take a look at the networks on the VM:
ip addr
You should see the new network (192.168.11.0). Let's try to ping the virtual network:
ping 192.168.11.1
You should get a response. Log out. Use CTRL + ] to exit the virsh console. Congratulations! You've completed setting up the new DBA network and connection using virsh! In this lesson, we covered:Managing interfaces using virsh Managing virtual networks using virsh

Using 'virt-clone' to Clone a Virtual Machine

00:02:44

Lesson Description:

We've looked at two ways we can use libvirt to administer virtual machines via QEMU/KVM, Virtual Machine Manager (virt-manager), and Cockpit. While these were easy to use, sometimes we need the granularity and power that command-line tools provide. Fortunately for us, libvirt has a set of command-line tools to round out our toolkit. In this lesson, we will take a look at how to use the virt-clone command to clone a virtual machine. Reference Links virt-clone(1) - Linux man page Using 'virt-clone' to Clone a Virtual Machine In this lesson, we're going to clone our centos-7-cli-vm and patch it so we can turn it into a template to for new CentOS 7 VMs for our DBA team. Clone a virtual machine Before we clone our virtual machine, we need to shut it down.Check the status of the centos-7-cli-vm guest:

sudo virsh list --all
Shut the centos-7-cli-vm virtual machine down (if it is running):
sudo virsh shutdown centos-7-cli-vm
Confirm that the virtual machine is shut down:
sudo virsh list --all
Start the clone We're going to clone our virtual machine so we can turn the clone into a template. This preserves our original VM in case something goes wrong during the template phase of our work. Clone our centos-7-cli-vm guest, with the clone name of centos-7-db-template, including all the virtual disks:
sudo virt-clone --original=centos-7-cli-vm --name=centos-7-db-template --auto-clone
Patch the cloned virtual machineStart the new clone:
sudo virsh start centos-7-db-template
Log in to the virtual machine using virsh console as cloud_user:
sudo virsh console centos-7-db-template
Patch the VM:
sudo yum -y update
When the patching is complete, log out. Use CTRL + ] to exit the virsh console.Shut down the cloned virtual machineShut the centos-7-db-template virtual machine down:
sudo virsh shutdown centos-7-db-template
Check the status of all guests:
sudo virsh list --all
We now have a patched virtual machine that we can create a template from! In this lesson, we covered:Cloning a virtual machine using virt-clone Preparing the clone to be made into a template: Starting the clone Patching the clone Shutting the clone down

Using 'virt-sysprep' to Create a Virtual Machine Template

00:05:34

Lesson Description:

We've looked at two ways we can use libvirt to administer virtual machines via QEMU/KVM, Virtual Machine Manager (virt-manager), and Cockpit. While these were easy to use, sometimes we need the granularity and power that command-line tools provide. Fortunately for us, libvirt has a set of command-line tools to round out our toolkit. In this lesson, we will take a look at how to use the virt-sysprep utility to turn our clone of our CentOS 7 virtual machine into a template that we can clone database servers from. We will then clone our first database server from the template! Reference Links virt-sysprep virt-clone(1) - Linux man page Using 'virt-sysprep' to Create a Virtual Machine Template In this lesson, we will use the virt-sysprep command to turn the 'centos-7-db-template' clone into a virtual machine template. Create a virtual machine template using virt-sysprepBefore we proceed, we want to make sure the centos-7-db-template guest is shut down:

sudo virsh list --all
Confirm the guest shuts down.Let's take a look at the operations that we will perform by default:
sudo virt-sysprep --list-operations | more
Execute the virt-sysprep operation:
sudo virt-sysprep -d centos-7-db-template --enable user-account --keep-user-accounts cloud_user --update
We are keeping the cloud_user account and will check for updates when we execute and apply them if necessary. We just patched the template, so we probably won't have any updates, but if we execute this operation in the future, we probably will.Clone the virtual machine template to a new guest using virt-clone Now, let's clone our new centos-7-vm-template to centos-7-db1-vm. This will give us our new database server. Clone our centos-7-db-template guest, with the clone name of centos-7-db1-vm, including all the virtual disks:
sudo virt-clone --original=centos-7-db-template --name=centos-7-db1-vm --auto-clone
Take a look at our cloned machine Now that we have our new database VM, let's take a look at it.Start the new clone:
sudo virsh start centos-7-db1-vm
Let's get information on the domain:
sudo virsh dominfo centos-7-db1-vm
List the network interfaces:
sudo virsh domiflist centos-db1-vm
List the block devices:
sudo virsh domblklist centos-db1-vm
Log in to the virtual machine using virsh console as cloud_user:
sudo virsh console centos-7-db1-vm
Look around and check out the network, storage, hostname, etc. When you're done, log out. Use CTRL + ] to exit the virsh console.Congratulations! You now have a database virtual machine template and a new database server from your template. You can now deploy fresh database servers as quickly as you can clone and configure them! In this lesson, we covered:Creating a virtual machine template using virt-sysprep Cloning the virtual machine template to a new guest using virt-clone

Creating a Virtual Machine from a RAW Disk File

00:08:12

Lesson Description:

We've looked at two ways we can use libvirt to administer virtual machines via QEMU/KVM, Virtual Machine Manager (virt-manager), and Cockpit. While these were easy to use, sometimes we need the granularity and power that command-line tools provide. Fortunately for us, libvirt has a set of command-line tools to round out our toolkit. In this lesson, we will take a look at the virt-v2v utility, which allows us to create a new virtual machine from a variety of source disk image files. Reference Links Importing VMs to KVM with virt-v2v CentOS 7 Generic Cloud Image Creating a Virtual Machine from a RAW Disk File Sometimes you don't want to install a virtual machine from scratch. Fortunately, you don't have to! We're going to use a CentOS 7 Generic Cloud image file to stand up a new VM. Download the CentOS 7 Generic Cloud Image FileFirst, we need to download the CentOS 7 Generic Cloud image file. This file is in RAW disk format:

curl -kL https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.raw.tar.gz -o /tmp/CentOS-7-x86_64-GenericCloud.raw.tar.gz
Next, we need to uncompress the file:
cd /tmp
tar xvzf CentOS-7-x86_64-GenericCloud.raw.tar.gz
cd ; clear
Edit the CentOS 7 Generic Cloud Image File By default, we can't log directly in to the Generic Cloud server with a username and password.We need to generate a new encrypted root password. In this example, I'm using clouduser as my password.
openssl passwd -1 clouduser
Next, we need to edit some files on the RAW disk file. We will change the root password and enable SSH login as root. Execute the guestfish utility against the RAW disk file:
sudo guestfish --format=raw -a /tmp/CentOS-7-x86_64-GenericCloud-2003.raw
Your filename could be different, adjust as necessary.Once we're inside the guestfish utility, execute:
><fs> run
><fs> list-filesystems
><fs> mount /dev/sda1 /
><fs> vi /etc/shadow
Replace the current root password with the encrypted password you generated above. It's the second field in the line for root. Save and quit.
><fs> vi /etc/ssh/sshd_config
Uncomment PermitRootLogin Yes. Save and quit.Exit guestfish:
><fs> quit
Import the CentOS 7 Generic Cloud Image FileList the current guests:
sudo virsh list --all
Import the RAW disk file using virt-v2v:
sudo virt-v2v -i disk /tmp/CentOS-7-x86_64-GenericCloud-2003.raw -o libvirt -of qcow2 -os Virtual_Machines -n default -on centos-7-generic-cloud-vm
Now, let's take a look at the list of guests:
sudo virsh list --all
Next, start the virtual machine:
sudo virsh start centos-7-generic-cloud-vm
Connect to the ConsoleHead on over to your web browser and log in to Cockpit. Navigate to the Virtual Machines pane, click on your new centos-7-generic-cloud-vm VM, and click on the Console tab. Log in to the VM as root. Let's patch the VM:
yum -y update
When patching is complete, go ahead and shut the VM down.Congratulations! You just imported a new virtual machine from a RAW disk file! In this lesson, we covered:Downloading the CentOS 7 Generic Cloud RAW disk image Editing the disk image using guestfish: Changing ‘root’ password Enabling SSH login as rootUsing virt-v2v to import the RAW disk image Connecting to the console using Cockpit: Patching the new VM

Using oVirt to Manage Virtual Machines

Introduction to oVirt

00:03:50

Lesson Description:

In this lesson, we're going to take a look at oVirt, an enterprise-class virtualization platform based on KVM/QEMU/libvirt. Reference Links oVirt | Home oVirt | System Requirements oVirt | Documentation oVirt | Admin Guide oVirt | oVirt Installation Guide Introduction to oVirt What is oVirt? From the oVirt website: “oVirt is an open-source distributed virtualization solution, designed to manage your entire enterprise infrastructure. oVirt uses the trusted KVM hypervisor and is built upon several other community projects, including libvirt, Gluster, PatternFly, and Ansible.” What's included?Rich web-based user interfaces for both admin and non-admin users Integrated management of hosts, storage, and network configuration Live migration of virtual machines and disks between hosts and storage High availability of virtual machines in the event of a host failureoVirt is:Built on libvirt/QEMU/KVM The upstream project of RHEVoVirt Functionality ovirt can:Create, edit, start, and stop guest VMs Move guest VMs between hosts Provide console access for guest VMs Provide operating metrics for guest VMs Display the current status of guest VMs Manage virtual networks Manage virtual storage Provide disaster recovery MoreHow Does oVirt Work? oVirt is made up of two components: oVirt engine:Standalone or self-hosted Java backend GWT web toolkit frontend WildFly (JBoss) application server PostgreSQL databaseoVirt node:RHEL/CentOS (predominantly) QEMU/KVM/libvirt VDSM: Node management APIGluster/PatternFly/Ansible Nodes can be clusteredoVirt supports many storage solutions: NFS iSCSI GlusterFS POSIX-compliant filesystem Fibre Channel Next, we’re going to stand up an oVirt environment on CentOS 7. In this lesson, we covered:What oVirt is The functionality of oVirt How oVirt works

Configuring the CentOS 7 Lesson Environment

00:11:48

Lesson Description:

Before we can dive in and start working with oVirt, we will need to configure a CentOS 7 environment. In this lesson, we will walk through setting up a 'Minimal' installation of CentOS 7. Reference Links Download CentOS 7: CentOS 7 | Mirrors List Downloading CentOS :: CentOS Docs Site Create USB Key: Making Installation USB Media on Linux :: CentOS Docs Site Making Installation USB Media on Windows :: CentOS Docs Site Making Installation USB Media on Mac OS X :: CentOS Docs Site Configuring the CentOS 7 Lesson Environment For this section, I will use a bare-metal environment on two Dell Precision T3500 workstations Specifications:Intel Xeon (6 core) 24GB RAM 1TB RAID-1 Storage 3TB additional hard drive Two-gigabit network interfaces with second (private) network configured CentOS 7 (Minimal Installation)These are approximately ten-year-old machines, and they work fine for this exercise. First, you will need to download CentOS 7 and create installation mediaDownload the CentOS 7 Minimal ISO. We're going to work relative to this, so it's important you start with the Minimal installer.Next, you will need to decide what kind of installation media you are going to use and create it. I usually use a USB installation as it is easier and more environmentally-friendly. If you need to create a CD or DVD from the ISO file, you can do that as well.Start the installationEither plug in your USB installer key or insert your CD/DVD into the drive and boot your computer.On the way up, we want to enter the BIOS to confirm that hardware-assisted virtualization is enabled. I'm not going to go into detail on how you do that as there are numerous ways, depending on your particular computer. Go get a copy of the hardware manual and read up. It will tell you what you need to enable.Once you exit the BIOS (save your changes!) you will want to select a boot menu —if your computer has that option— and boot from your installation media.When the CentOS installer starts, you can skip the media check if you wish.Installing CentOS 7With this CentOS 7 installer, the only package choice is Minimum. The installer is similar to the installer we used to install CentOS 8, so setup will be the same.Set a root password and create the cloud_user user during installation.Post-installation tasksAfter the system has rebooted, log in as 'cloud_user'. We need to patch the system:

sudo yum -y update
After patching is complete, reboot the system:
sudo systemctl reboot
Configure Storage and NFS Server After the system has rebooted, log in as cloud_user. We're going to configure four storage locations, one for the virtual machine images, one for the hosted engine, one for the export domain, and one for the ISO store. I'm going to create new logical volumes and file systems, but you can just create directories to use if you'd like. Configure the storage:Let's create the mount points:
sudo mkdir /media/ISO
sudo mkdir /media/VM_Store
sudo mkdir /media/HE_Store
sudo mkdir /media/Export_Store
Next, I'm going to create some new logical volumes using an additional 3TB disk that is in the system. This disk is /dev/sdc.Clean this disk:
sudo wipefs -a /dev/sdc
Add this disk to LVM:
sudo pvcreate -ff /dev/sdc
Let's check our work:
sudo pvs
6, Next, let's add /dev/sdc to a new volume group, 'ovirt':
sudo vgcreate ovirt /dev/sdc
Let's check our work:
sudo vgs
Create our logical volumes:
sudo lvcreate -L 200g -n ISO ovirt
sudo lvcreate -L 1T -n VM_Store ovirt
sudo lvcreate -L 200g -n HE_Store ovirt
sudo lvcreate -L 200g -n Export_Store ovirt
Let's check our work:
sudo lvs
Next, let's format the new logical volumes:
sudo mkfs.xfs /dev/mapper/ovirt-ISO
sudo mkfs.xfs /dev/mapper/ovirt-VM_Store
sudo mkfs.xfs /dev/mapper/ovirt-HE_Store
sudo mkfs.xfs /dev/mapper/ovirt-Export_Store
Now we will need to edit /etc/fstab in order to add the mounts for our new logical volumes.
sudo vi /etc/fstab
Add the entries for the new mount, then save and exit.Now, let's mount our new filesystems:
sudo mount -a
Let's check our work:
df -h | grep media
Configure the NFS exports:First, we will need to install the packages required for the NFS server:
sudo yum -y install nfs-utils
Enable and start the NFS services:
sudo systemctl enable rpcbind --now
sudo systemctl enable nfs-server --now
sudo systemctl enable nfs-lock --now
sudo systemctl enable nfs-idmap --now
We will need to configure the firewall to allow NFS:
sudo firewall-cmd --permanent --zone=public --add-service=nfs
sudo firewall-cmd --permanent --zone=public --add-service=mountd
sudo firewall-cmd --permanent --zone=public --add-service=rpc-bind
sudo firewall-cmd --reload
Let's check our work:
sudo firewall-cmd --list-all
Next, we need to create /etc/exports and add our new filesystems:
sudo vi /etc/exports
Add the following lines:
/media/ISO    192.168.10.0/24(rw,sync,no_root_squash,no_all_squash)
/media/VM_Store    192.168.10.0/24(rw,sync,no_root_squash,no_all_squash)
/media/HE_Store    192.168.10.0/24(rw,sync,no_root_squash,no_all_squash)
/media/Export_Store    192.168.10.0/24(rw,sync,no_root_squash,no_all_squash)
Save, and exit.Restart the NFS server:
sudo systemctl restart nfs-server
Let's check our work:
showmount -e
We should see the four exports we just configured. We're good to proceed!In this Lesson We covered installing and configuring the CentOS 7 lesson environment. Let's get to installing and configuring oVirt!

Installing and Configuring oVirt on CentOS 7

00:10:49

Lesson Description:

Now that we have a CentOS 7 server up and running, we can get to setting up oVirt! In this lesson, we are going to install oVirt on CentOS 7, using the command line installer. Reference Links oVirt: Installing oVirt as a self-hosted engine using the command line | oVirt oVirt Installation Guide | oVirt DNS: Chapter 15. DNS Servers Red Hat Enterprise Linux 7 | Red Hat Customer Portal configure dns server redhat linux 7 - Google Search Installing and Configuring oVirt on CentOS 7 NOTE: Installation requires that you have both forward and reverse DNS properly configured for both your hosted engine appliance and your host! If you would like to set up a DNS server on your CentOS 7 server, you can. Configuring a DNS server is outside the scope of this course, but it is not difficult, and I have provided some resources in the Reference Links above to get you started. It is possible you can "fake" DNS using the /etc/hosts file on any machines, virtual or real, you are using in your test environment as well. This is going to be a bit more work to maintain than a centralized DNS. I am utilizing my pre-existing DNS and DHCP set up in my home lab environment, which runs on Linux, outside of the CentOS 7 servers I am using for these lessons. I have forward and reverse DNS configured for the servers and the hosted engine, as well as a DHCP reservation for the hosted engine. Virtualizing with oVirt and NFS We work for a large retail/e-commerce company that is deploying a new warehouse management system. The company wants to minimize the amount of on-site equipment in the warehouses, and the decision has been made to virtualize the warehouse management systems, using oVirt, in a centralized hosting facility. We will be using NFS storage for this deployment, on our first host, for now. Let's deploy our first oVirt host! NFS Storage ConfigurationCreate the kvm group:

sudo groupadd kvm -g 36
Create the vdsm user and assign it to the group kvm:
sudo useradd vdsm -u 36 -g 36
Change ownership of the NFS storage directories:
sudo chown -R 36:36 /media/ISO
sudo chown -R 36:36 /media/VM_Store
sudo chown -R 36:36 /media/HE_Store
sudo chown -R 36:36 /media/Export_Store
Change the NFS storage directory permissions to 0755:
sudo chmod 0755 /media/ISO
sudo chmod 0755 /media/VM_Store
sudo chmod 0755 /media/HE_Store
sudo chmod 0755 /media/Export_Store
Install and Deploy the oVirt Hosted Engine Reminder: Installation requires that you have both forward and reverse DNS properly configured for both your hosted engine appliance and your host!Enable the oVirt repository:
sudo yum -y install https://resources.ovirt.org/pub/yum-repo/ovirt-release43.rpm
Check for updates:
sudo yum -y update
Reboot if you have any updates.Install the self-hosted engine setup package:
sudo yum -y install ovirt-hosted-engine-setup
Execute the deployment script:
sudo hosted-engine --deploy
You will need to provide answers in your configuration script. Most of these will be the default, but some will depend on your environment. Note that the self-hosted engine installation is automated using Ansible.Connect to the oVirt Engine Web Interface In a web browser, navigate to https://manager-fqdn, replacing manager-fqdn with the FQDN for your oVirt hosted engine. We now have a working oVirt installation! In this lesson, we covered:Configuring the NFS storage Installing and deploying the oVirt hosted engine Connecting to the oVirt hosted engine appliance web interface

Exploring the oVirt Management Interface

00:06:38

Lesson Description:

Now that we've stood up our instance of oVirt, let's take a look at the management interface. We'll cover basic navigation and will authenticate and examine some commonly used items. Reference Links Using the Administration Portal | oVirt Exploring the oVirt Management Interface Connect to the oVirt Engine Web Interface In a web browser, navigate to https://manager-fqdn, replacing manager-fqdn with the FQDN for your oVirt hosted engine. The Main Page When you first connect to the web interface, you will be presented with a number of resources.Portals: Administration Portal VM PortalDownloads: Console Client Resources CA Certificate moVirt for AndroidTechnical Reference: REST API GuideIf you're not already logged in, log in with the admin user and the password you set when you configured the hosted engine. Click on the User icon in the upper-right hand corner and select login.VM Portal The VM Portal provides a streamlined interface for monitoring and managing virtual machines. We're going to go a little deeper into the VM Portal when we create virtual machines. The Administration Portal Let's return to the main page, and enter the Administration Portal. This is where we will do most of our work. The oVirt Dashboard Header BarBookmarks Tags Tasks Events and Alerts Notification Guide/About UserDashboardRefresh button Summary of resource utilization and other metricsThe Main Navigation Menu The Main Navigation Menu allows you to view and configure various resources in oVirt. You can minimize the menu by clicking on the icon (with the three lines) in the upper left-hand corner. Commonly used items:Compute --> Virtual Machines Compute --> Hosts Storage --> Domains Storage --> Volumes Administration --> User Sessions Administration --> Users EventsNow that you know your way around the oVirt Management Interface, let's perform a few configuration tasks. In this lesson, we covered:Connecting to the oVirt web interface Explore the main page: VM Portal Administration Portal

Configuring the oVirt Environment

00:12:37

Lesson Description:

Now that we know our way around the oVirt interface, we're going to configure some resources that we did not get configured when we set up the hosted engine. We will add a private virtual network, some storage domains, and a second (hypervisor) host. Reference Links Adding Networks: Logical Networks | oVirt Adding Storage Domains: Storage | oVirt Adding Hosts: Hosts | oVirt Configuring the oVirt Environment Before our oVirt environment is ready to use, we will need to configure some additional resources. Connect to the oVirt Engine Web Interface In a web browser, navigate to https://manager-fqdn, replacing manager-fqdn with the FQDN for your oVirt hosted engine. If you're not already logged in, log in with the admin user and the password you set when you configured the hosted engine. Enter the Administration Portal. Adding a Private Virtual Network Our WMS team has asked us to create a 'private' network for the warehouse management systems to communicate on the backend. We will attach our virtual machines to this network when we create them. Navigate to the Network tab, and select Networks. Click on the New button in the upper right-hand corner. You will be presented with the New Logical Network wizard.Let's fill in some information:General: Name: WMS-Private Description: WMS Private Network Comment: WMS Private NetworkLeave the defaults on Network Parameters.Cluster: Use defaults. vNIC Profiles: Use defaults.Click OK.We need to attach our WMS-Private network to our second physical interface on the private physical network. This will allow us to "extend" the WMS-Private network to other hosts as we add them.Navigate to Compute, then to Hosts. Click on your host, then select the Network Interfaces tab. Click on the Setup Host Networks in the upper right-hand corner, then drag the WMS-Private network to a physical interface. In my case, I have a second physical network, but if you don't, just skip the second network for now, and don't use it.We now have our WMS-Private network and can attach virtual machines to it. Adding Storage Domains When we configured the hosted engine, we created the HE_Store storage domain to store the hosted engine image.We are now going to configure three more storage pools:VM_Store Domain: A Data domain that provides storage for our virtual machine images.Export_Store Domain: Temporary storage repositories that are used to copy and move images between data centers and oVirt environments.ISO Domain: Stores install images, disk images for import, etc. Only one ISO domain can be added to a data center.Navigate to the Storage tab and select Domains.Click on New Domain.Let's add the Export_Store domain first. Select a Domain Function of Export.Name it Export_Store.Set the Export Path to your NFS share (in my case, it is curly.dean33.com:/media/Export_Store). Leave everything else as default.Click OK.We now have the VM_Store data domain configured for our VM storage. Now configure your ISO and Export domains. Adding a Second Host This is optional, but if you have another capable computer and would like to try it, go ahead! The second computer will need a fresh CentOS 7 Minimal installation, like on the first host. Use the same media you used for the first host. You can skip configuring any of the NFS storage, as we already have them on the first host. Just install CentOS 7 Minimal and patch it.Make sure that the system is up-to-date:

sudo yum -y update
Reboot if you had any updates.Make an SSH connection to your new host.Create and exchange root SSH keys.On each host:Generate an SSH key:
ssk-keygen
Copy the key to the other host:
ssh-copy-id root@YOUR_OTHER_HOSTNAME_OR_IP
Enable the oVirt repository on the new host:
sudo yum -y install https://resources.ovirt.org/pub/yum-repo/ovirt-release43.rpm
The installation won't work if the oVirt repository is not configured on the new host.Back in the oVirt Administration Portal, navigate to the Compute tab and click on Hosts. Click on the New button in the upper right-hand corner.Walk through the New Host wizard, then click OK. You can ignore any power management warnings. If the SSH keys approach doesn't work, fall back on providing root credentials in the wizard.Let the installation progress. You can monitor the installation via the Alerts and Events icon in the upper right-hand corner of the window.Once the installation is complete, navigate to the Dashboard.Review Dashboard Changes Check and see if the dashboard changed. You should now see two hosts (if you added a second host) and the additional NFS Data Store we added. In this lesson, we covered:Adding a Private Virtual Network Adding NFS Storage Domains: LocalAdding a Second Host

Managing the oVirt Environment

00:10:30

Lesson Description:

Now that we've finished configuring our oVirt environment let's take a look at some common management tasks. We're going to add a local internal user, take a look at Events, create a template from the oVirt Image Repository, and take a look at how we perform maintenance on oVirt hosts. Reference Links Adding Users: Users and Roles | oVirt AAA JDBC | oVirt Managing the oVirt Environment Connect to the oVirt Engine Web Interface In a web browser, navigate to https://manager-fqdn, replacing manager-fqdn with the FQDN for your oVirt hosted engine. If you're not already logged in, log in with the admin user and the password you set when you configured the hosted engine. Enter the Administration Portal. Adding a New Internal User Most of the time, we will manage oVirt users in an external directory service, such as Active Directory or LDAP. Since standing up and populating an external directory server is outside of this course's scope, let's take a look at managing internal users in oVirt.Our WMS team needs a user to manage their virtual machines via the VM Portal. We will create a new Internal user named cloud_user for them to use, for now, using the ovirt-aaa-jdbc-tool.In order to use the command-line utility ovirt-aaa-jdbc-tool, we will need to make an SSH connection as root to the hosted engine. Log in with the password you created for the root user when you configured the hosted engine.Now we can create a new cloud_user user:

ovirt-aaa-jdbc-tool user add cloud_user --attribute=firstName=Cloud --attribute=lastName=User --attribute=email=cloud_user@testdomain.com
We need to set a password for the cloud_user user:
ovirt-aaa-jdbc-tool user password-reset cloud_user --password-valid-to="2025-08-15 10:30:00Z"
Let's check our work:
ovirt-aaa-jdbc-tool user show cloud_user
Go ahead and log out of your SSH connection:
exit
You should be logged in to the oVirt web interface as admin. If you are not, log out and log back in as admin.Navigate to Administration, then Users, and click on cloud_user. Click on the Permissions tab. Click on the Add System Permissions button on the right-hand side. Assign the UserRole and SuperUser roles, then click OK.Log out as the admin user and log back in with cloud_user.Managing Events Events:Alert us when issues occur Provide a running log of activity Are searchableIn order to access Events, click on it on the left-hand side:Take a look around Search for events Sort events Bookmark a searchCreate a Template from the oVirt Image Repository One resource that is available to us with the default installation of oVirt is the ovirt-image-repository. From ovirt.org: "OpenStack Image Service provides a catalog of virtual machine images. In oVirt, these images can be imported into the oVirt Engine and used as floating disks or attached to virtual machines and converted into templates."Navigate to Storage and then select Domains. Click on the ovirt-image-repository.Choose the CentOS 7 Generic Cloud Image (the latest), highlight it and click on the Import button in the upper right-hand corner.Select Import as Template and give your template a name. We will use the template later.Import Images:Data Center: Default Domain name: VM_Storage Import as Template: CheckedClick OK.Navigate to Compute and then to Templates.After the import process is complete, you will see your new template. Performing Maintenance on the Second Host Sometimes you will need to take a host out of the rotation to perform maintenance or deal with an outage. We're going to perform some maintenance on our second host.Navigate to Computer, and then to Hosts. Highlight the second host.Select the drop-down menu from Management and then select Maintenance. This will put your host into maintenance mode.Make an SSH connection to the second host as cloud_user and then patch the system:
sudo yum -y update
After patching, reboot:
sudo systemctl reboot
Observe the oVirt Hosts page as the second host comes back up.When the host is back up, make sure the host is highlighted and select the drop-down menu from Management and then select Activate.This will bring the host back into oVirt as active. You should see a green triangle pointing up on the left side of the hosts' entry in the host list. In this lesson, we covered:Adding a New User Managing Events Creating a Template from the oVirt Image Repository Performing Maintenance on a Second Host

Creating a Virtual Machine Using oVirt

00:13:05

Lesson Description:

We're going to use our configured oVirt environment to create some guest virtual machines. We will explore creating a CentOS 8 virtual machine using the oVirt Administration Portal and set up a new CentOS 7 guest from a template using the oVirt VM Portal. Reference Links ISO Downloads: CentOS 7 | Mirrors List CentOS 8 | Mirrors List Creating a Virtual Machine Using oVirt Connecting to the oVirt Engine Web Interface In a web browser, navigate to https://manager-fqdn, replacing manager-fqdn with the FQDN for your oVirt hosted engine. If you're not already logged in, log in with the admin user and the password you set when you configured the hosted engine. Enter the Administration Portal. Uploading the ISO install images to the ISO storage domain Before we can create a new virtual machine, we will need to install media in our oVirt environment. The install ISO files must be uploaded to the ISO storage domain.I've copied two ISO files from my computer to the hosted engine using scp:

scp Downloads/CentOS-* root@ovirt:~
That puts the ISO files into the /root directory on the hosted engine.Now that the files are on the hosted engine, log in as root via SSH. By default, we will be in the /root directory.We will use the engine-iso-uploader command to upload the ISO files into the ISO domain:
engine-iso-uploader --iso-domain=ISO upload CentOS-7-x86_64-Minimal-2003.iso CentOS-8.1.1911-x86_64-boot.iso
The name of your ISO file may be different, so adjust as necessary.Now, go to the oVirt web interface and click on Storage, then Domains. Click on the ISO link, then click on the Images tab. You should see the ISO files we just uploaded.Creating a new CentOS 8 virtual machine using the oVirt Administration PortalNavigate to Compute and then to Virtual Machines. Click on the *New button along the top. This will open the *New Virtual Machine wizard.Fill out the information in the General pane:Cluster: Default Template: Blank Operating System: Red Hat Enterprise Linux 8.X x64 Instance Type: Custom Optimized for: Server Name: centos-8-wms1-chicago Description: CentOS 8 WMS1 - Chicago Comment: CentOS 8 WMS1 - Chicago VM ID: BLANK Stateless: Unchecked Start in Pause Mode: Unchecked Delete Protection: UncheckedFill out Instance Images - Create Virtual Disk:Next, under Instance Images, click the Create button. Set the size, choose the correct Storage Domain, and leave the rest as default.Attach the virtual NICs:Set nic1 to the ovirtmgmt network. OPTIONAL: Set nic2 to the WMS-Private network.Click on Show Advanced Options.Tour the tabs.On System, set the memory and CPUs.Under Boot Options, attach the CentOS 8 ISO and select Enable menu to select boot device.Click on OK in the lower right-hand corner.Highlight the centos-8-wms1-chicago virtual machine and click on the Run button. In the upper right-hand corner, click on Console. Open the file with the remote viewer.Walk through the CentOS 8 installer and install a Minimal system. When the installation is complete, click Reboot. Disconnect from the console.Creating a new CentOS 7 virtual machine using the oVirt VM PortalGo back to the main oVirt page by clicking on oVirt in the upper left-hand corner. Enter the VM Portal. We are going to create a new virtual machine from the CentOS 7 template we created earlier, using the **VM Portal.In the 'VM Portal', in the upper right-hand corner, click the Create Virtual Machine button. This will open the Create A New Virtual Machine wizard.Name: centos-7-wms1-chicago Description: CentOS 7 WMS1 - Chicago Cluster: Default Template: Your CentOS 7 template from earlier Operating System: Red Hat Enterprise Linux 7.x x64 Defined Memory: 2048 (or what you can spare - at least 1024) Total Virtual CPUs: 2 (or what you can spare - at least 1) Boot Menu: OFF Boot Sequence: First Device: Hard Disk Second Device: [None]Cloud-Init: ON Hostname: centos-7-wms1-chicago SSH Authorized Keys: PASTE YOUR PUBLIC KEY HEREIcon: Ignore thisClick on Create VM. Let oVirt do its work.Once the VM has been created, add a network interface on the ovirtmgmt network in Network Interfaces.Click on Run to start the VM. Once the VM is up, click on Console. See how you can attach to the VM console. We can't log in directly here, as we don't have any passwords set. We do have an SSH key configured on the system, though, so let's use that.To log in, we will make an SSH connection as centos to the IP address of the VM from the machine we provided the public key for, as the user who provided the key.Now that we're logged in, let's patch the system:
sudo yum -y update
Once the virtual machine is patched, log out of the SSH connection. Go back to your browser. Click on Shutdown in the upper right-hand corner.Go back to the main oVirt page by clicking on oVirt in the upper left-hand corner.In this lesson, we covered:Uploading the ISO install images to the ISO storage domain Creating a new CentOS 8 virtual machine using the oVirt Administration Portal Creating a new CentOS 7 virtual machine using the oVirt VM Portal

Managing a Virtual Machine Using oVirt

00:07:48

Lesson Description:

Now that we have some virtual machines let's take a look at how we can manage them using oVirt. We're going to use the Administration Portal and the VM Portal to perform some reconfiguration of our CentOS 7 and 8 virtual machines. Reference Links oVirt Virtual Machine Management Guide | oVirt Managing a Virtual Machine Using oVirt Connect to oVirt Engine Web Interface In a web browser, navigate to https://manager-fqdn, replacing 'manager-fqdn' with the FQDN for your oVirt hosted engine. If you're not already logged in, log in with the admin user and the password you set when you configured the hosted engine. Enter the Administration Portal Managing the CentOS 7 virtual machine using the oVirt Administration PortalNavigate to Compute, then Virtual Machines8. Click on centos-7-wms1-chicago. We're going to add a second network interface. Click on the Network Interfaces tab and then click on the New button in the upper right-hand corner. You can use the default name of nic2 and connect to any Profile you want. Click OK. Let's add a second disk. Click on the Disks tab, then click on the New button in the upper right-hand corner. Configure the size as you wish, leave the rest as defaults, then click OK. Let's take a snapshot. Click on the Snapshots tab, then click on Create in the upper right-hand corner. Name the snapshot just-in-case. Go back to the General tab. Start the VM by clicking on Run. To log in, we will make an SSH connection as centos to the IP address of the VM from the machine we provided the public key for, as the user who provided the key.Let's Check our Work:List all the disks on the system:

sudo fdisk -l
We should see two.Check out the network interfaces:
ip addr
We should also see two.Log out of the centos-7-wms1-chicago virtual machine.Managing the CentOS 8 virtual machine using the oVirt VM PortalGo back to the main oVirt page by clicking on oVirt in the upper left-hand corner. Enter the VM Portal. Click on the centos-8-wms1-chicago VM. We're going to add a second disk. Navigate over to Disks and click on the Edit (pencil) icon. Click on Create Disk. This will open the Create New Disk wizard. Set the size as you deem fit, choose the storage domain, and then click OK. Click on the checkmark.Let's edit the memory and CPUs on this VM.Click on the pencil icon in the Details section. Adjust the Total Virtual CPUs and Memory as you see fit. Click on the checkmark. Click on the Reboot button in the upper right-hand corner, so our changes will be applied. Once the VM has been rebooted, click on the Console button in the upper right-hand corner. Log in as the cloud_user user.Let's Check our Work:Confirm the amount of memory configured:
grep MemTotal /proc/meminfo
Confirm the number of CPUs:
grep -i processor /proc/cpuinfo | wc -l
Confirm that we have two virtual disks:
sudo fdisk -l
Log out. Close the Remote Viewer. Shut down the VM. Go back to Virtual Machines. Select the centos-7-wms1-chicago guest and shut down this VM as well. Log out of oVirt.In this lesson, we covered:Managing the CentOS 7 virtual machine using the oVirt Administration Portal Managing the CentOS 8 virtual machine using the oVirt VM Portal

Managing the oVirt Hosted Engine

00:12:25

Lesson Description:

The oVirt Hosted Engine is the "brain" of the oVirt infrastructure. While it is robust and reliable, sometimes you will need to troubleshoot or manage it outside of the web interface. We will take a look at the hosted-engine command, an important tool in managing an oVirt installation. We will also take a look at backing up the hosted engine using the engine-backup command. Reference Links Backups and Migration | oVirt Utilities | oVirt Chapter 3. Troubleshooting a Self-Hosted Engine Deployment Red Hat Virtualization 4.2 | Red Hat Customer Portal Managing the oVirt Hosted Engine oVirt comes with a rich, web-based management interface, but how do we manage the hosted engine that provides this interface? Using the hosted-engine Command In order to use the hosted-engine command, we need to log in to the host where our hosted engine is running. You can use SSH. The hosted-engine command is used to manage the oVirt self-hosted engine. In order to get HELP, use:

sudo hosted-engine --help
This will show all the commands and their usage. Quite often, we will want to confirm the hosted engine VM's status. We can do that with:
sudo hosted-engine --vm-status
This will show us the current status of the hosted engine. We can shut down, power off (force), or start the hosted engine with the hosted-engine command. This comes in handy if we have an unresponsive VM. We will take a look at this when we patch the hosted engine. Patching the Hosted Engine We need to do a little maintenance on the hosted engine before we continue deploying virtual machines for our WMS team. We're going to check for patches and install them if they are available. In order to perform important maintenance, we need to put the hosted engine into 'global' maintenance mode:Log out of the web interface, then run:
sudo hosted-engine --set-maintenance --mode=global
Check the status of the hosted engine to confirm we are in maintenance mode:
sudo hosted-engine --vm-status
Let's attach to the hosted engine's console:
sudo hosted-engine --console
Hit Enter, then log in as root using the password you created when you installed oVirt.Once you're logged in as root, use yum to install updates:
yum -y update
When updates are installed, log out and disconnect from the console using CTRL-].Let's shut down the hosted engine:
sudo hosted-engine --vm-shutdown
Check the status of the hosted engine:
sudo hosted-engine --vm-status
Once the hosted engine is shut down, start it back up:
sudo hosted-engine --vm-start
Check the status of the hosted engine:
sudo hosted-engine --vm-status
Connect to the console:
sudo hosted-engine --console
Log in as root.Backing up the hosted engine using engine-backup In case of disaster, we need to create periodic backups of our hosted engine:Create a full backup:
engine-backup --scope=all --mode=backup --file=/root/full_he_backup.tar --log=/root/full_he_backup.log
Take a look at the backup files:
ls -al /root/*backup*
Create an engine database backup:
engine-backup --scope=files --scope=db --mode=backup --file=/root/db_he_backup.tar --log=/root/db_he_backup.log
Take a look at the backup files:
ls -al /root/*backup*
Log out and disconnect from the console using CTRL + ]. Take the hosted engine out of global maintenance mode:
sudo hosted-engine --set-maintenance --mode=none
Check the status of the hosted engine:
sudo hosted-engine --vm-status
We're good to go now.Moving the hosted engine to another host Connect to oVirt Engine Web Interface:In a web browser, navigate to https://manager-fqdn, replacing manager-fqdn with the FQDN for your oVirt hosted engine. If you're not already logged in, log in with the admin user and the password you set when you configured the hosted engine. Enter the Administration PortalNavigate to Compute, then Virtual Machines. Our environment isn't configured to migrate VMs between hosts, but you can take a look at how it's done.Right-click on the HostedEngine VM, and select Edit. Click on Host and check out the options for where the hosted engine can run. Click on Cancel.Right-click on the HostedEngine VM, and select Migrate. Check out the options in the Migrate VMs wizard. Click on Cancel.You can also highlight the HostedEngine VM, then click on the Migrate button in the upper right-hand corner. This will put you in the Migrate VMs wizard, as above.In this lesson, we covered:Using the hosted-engine command Patching the hosted engine Moving the hosted engine to another host Backing up the hosted engine using engine-backup

Final Words

KVM Virtualization on Linux - a Review

00:05:04

Lesson Description:

In this course, we’ve explored KVM Virtualization on Linux from four perspectives. Let's review what we covered. Lesson - KVM Virtualization on Linux - A Review What is Virtualization? In the past, in x86/x64 computing, what we thought of as a SERVER or HOST was made up of:A hardware component An operating system One or more applicationsVirtualization allows you to separate the SOFTWARE component of what we think of as a “server” from the HARDWARE component. A virtual machine, from the guest operating system’s perspective, looks like physical hardware. All the devices that the operating system expects to see, from CPUs to memory, disks to network cards, video to BIOS, is there. What Is a Hypervisor? A hypervisor is software that sits between the guest (virtual machine) operating system and either the hardware itself or another operating system (host). The HYPERVISOR SOFTWARE provides the resources the operating system expects to see, through either emulation or paravirtualization. The guest operating system is installed in the virtual machine just as if you were performing an installation on bare metal hardware. You might have to install some drivers to get full functionality, just as on bare metal. The hypervisor provides the resources that the guest operating system requires:Virtual CPU(s) Virtual Memory Virtual Disk(s) Virtual Networking Mapped physical resources: Networking: IP StorageGPU(s)Other resources: Virtual media: CD/DVD/ISO images USBSound VideoType-1 vs. Type-2 Hypervisors Type-1 Hypervisor:Sits directly on the hardware It is the host operating system Example: VMWare ESX / KVMType-2 Hypervisor:Runs on top of a host operating system Example: VirtualBox / QEMWhat Is KVM? Kernel-based Virtual Machine (KVM) is a Linux Kernel Module that allows the kernel to function as a Type-1 hypervisor. KVM requires hardware virtualization extensions, such as Intel VT-x or AMD-V. What Is QEMU? QEMU is a type-2 hypervisor that runs in user space. When used with KVM, it accelerates the performance of a QEMU guest, and the combination becomes a type-1 hypervisor. What Is libvirt? Libvirt is a toolkit to manage virtualization platforms. It allows mixing and matching of many management utilities/frameworks with many different hypervisors. How Does It Work?KVM: Provides acceleration through access to hardware virtualization extensions QEMU: Type-2 hypervisor that utilizes KVM for type-1 hypervisor acceleration libvirt: Toolkit to manage virtualization platforms, like QEMU/KVMIn this course, we’ve explored KVM Virtualization on Linux from four perspectives:Workstation virtualization using CentOS 8 Virtual Machine Manager virt-managerWeb-based administration using CentOS 8 Cockpit Web ConsoleCLI administration using CentOS 8 Explored oVirt on CentOS 7Virtual Machine Manager From the Virtual Machine Manager website: "The virt-manager application is a desktop user interface for managing virtual machines through libvirt. It primarily targets KVM VMs but also manages Xen and LXC (Linux containers). It presents a summary view of running domains, their live performance, and resource utilization statistics. Wizards enable the creation of new domains, and configuration and adjustment of a domain’s resource allocation and virtual hardware. An embedded VNC and SPICE client viewer presents a full graphical console to the guest domain." Cockpit/Web Console From the Cockpit Project website: “The easy-to-use, integrated, glanceable, and open web-based interface for your servers.” Cockpit and Web Console are the same thing. Cockpit is the upstream project that feeds Web Console in the RHEL offering. How does Cockpit work? Cockpit runs in user space and leverages a plugin to use libvirt to access the underlying hypervisor. Because of this, Cockpit doesn’t have to know how to “talk to” the hypervisor — it only has to communicate with libvirt via the libvirtd service. How does Cockpit plugin work? “Access to Libvirtd is wrapped either by the virsh tool or libvirt D-Bus API bindings, depending if the latter is installed on the system.” — Cockpit Project CLI - Using 'virsh' Why use CLI utilities?More control than other methods Enable scripting/automation No GUI/web browser required: Less overhead Easier to access the CLIMany management utilities leverage virsh: Easier to troubleshoot issuesFrom the libvirt website: “The virsh program is the main interface for managing virsh guest domains.” 'virsh' is installed when you install the libvirt package Interacting with virsh: You can use virsh in one of two ways:From the Linux shell As its own interactive shell: The virsh shelloVirt From the oVirt website: “oVirt is an open-source distributed virtualization solution, designed to manage your entire enterprise infrastructure. oVirt uses the trusted KVM hypervisor and is built upon several other community projects, including libvirt, Gluster, PatternFly, and Ansible.” What's included?Rich web-based user interfaces for both admin and non-admin users Integrated management of hosts, storage, and network configuration Live migration of virtual machines and disks between hosts and storage High availability of virtual machines in the event of host failureoVirt:oVirt is built on libvirt/QEMU/KVM oVirt is the upstream of RHEVoVirt can:Create, edit, start, and stop guest VMs Move guest VMs between hosts Provide console access for guest VMs Provide operating metrics for guest VMs Display the current status of guest VMs Manage virtual networks Manage virtual storage Provide disaster recovery MoreoVirt is made up of two components: oVirt engine:Standalone or self-hosted Java backend GWT web toolkit frontend WildFly (JBoss) application server PostgreSQL databaseoVirt node:RHEL/CentOS (predominantly) QEMU/KVM/libvirt VDSM Node management APIGluster/PatternFly/Ansible Nodes can be clusteredIn this course, we’ve aspired to provide an interesting journey through four scenarios that use KVM Virtualization on Linux. We hope you enjoyed it!

Take this course and learn a new skill today.

Transform your learning with our all access plan.

Start 7-Day Free Trial