OPS245 Lab 2 dev

From CDOT Wiki
Revision as of 12:23, 29 January 2023 by Jason Michael Carman (talk | contribs) (Part 2: Configure VMware Workstation for Nested VMs)
Jump to: navigation, search

LAB PREPARATION

At the end of lab2, your VMware Workstation application will contain 4 virtual machines (c7host in your VMware Workstation application, and centos1, centos2, centos3 VMs in your KVM application). You will now have the option to run one virtual machine at a time, or run all machines simultaneously to learn about networking (covered in later labs)

Purpose / Objectives of Lab 2

In this lab, you will create 3 remaining virtual machines using another virtualization program called KVM that will run in your r9host VM. These VMs will be used throughout the remainder of this course to learn how to administer them (installing software, managing services, networking, etc).

While you are performing this lab, it is recommended to generally note the major differences in the different installation methods, and which method you prefer to use if you were a Linux system administrator in charge of installing many Linux distributions for an organization.

Main Objectives

  • Installing additional Virtualization Software on your r9host machine (KVM)
  • Create 3 separate VMs (virtual machines) using different installation methods:
  • rhel1: Network Red Hat Enterprise Linux Installation (Graphical)
  • rhel2: Network Red Hat Enterprise Linux Installation (minimal install - CLI only)
  • rhel3: Network Red Hat Enterprise Linux Installation with Kickstart configuration file (CLI only)
  • Manipulate virtual machines by CLI (virsh)
  • Properly backup VM images and backup VM configuration files
  • Create and run Bash Shell scripts to automatically create a post-install report for an installed VM.


Minimum Required Materials
Linux Command Reference
Solid State Drive
USB key
(for backups)
Lab2 Log Book

Virtualization
virt-manager
virsh
Installation Guides
What is KVM?
Using KVM (tutorial)
virsh command reference

Miscellaneous
gzip , gunzip
ip
grep
wc
pwd
ls
more
file
wget
chmod
vi

Matrix Online Tutorials:
  • Shell Scripting - Part 2 (Logic & Math Expressions):
    /home/ops235/scripting-2
  • Shell Scripting - Part 3 (Loops)
    /home/ops235/scripting-3

INVESTIGATION 1: SETUP FOR NESTED VIRTUAL MACHINES

Part 1: Install KVM Virtualization Application

We will now install the KVM package in order to create our remaining "nested" VMs. We will also be starting several services (including nftables) and disabling the firewalld service. We will learn more about managing firewalls using nftables in lab6.

Perform the following steps:
  1. Log into your r9host machine.
  2. perform a software update on your r9host VM by issuing the following command: sudo dnf update
Important.png
Yum Update Hangs
If you experience yum update "hanging" around item 689 of over 1200 packages, issue the following commands (in a new terminal!):
sudo pkill systemctl
sudo yum clean all
sudo yum update
NOTE: Do NOT press <ctrl>c since it may cause your machine to cause a kernel panic when you restart your machine.
  1. Using elevated privileges, install the virtualization software by issuing the command:
    sudo dnf install libvirt virt-manager python3-libvirt virt-viewer

  2. Restart your r9host virtual machine. If you fail to do this, you may experience virtualization network problems.
    Note.png
    About KVM
    There are actually several key programs installed for virtualization using KVM:
    • kvm/qemu - the hypervisor and other hardware emulation systems.
    • A system service named libvirt that manages the VMs.
    • A graphical tool for managing virtual machines (virt-manager) and the virsh command-line tool.
  3. Start the virtualization service: sudo systemctl start libvirtd

    NOTE: The most recent variants of RHEL a service called nftables that replaces firewalld, however the firewalld is still active by default. Firewalld rules are translated by the kernel into nftables rules. Therefore, it makes sense to learn nftables. In this course we will concentrate on nftables.

  4. To disable and remove firewalld, issue the following commands:
    sudo systemctl disable firewalld
    sudo systemctl stop firewalld
    sudo yum remove firewalld

  5. To start and enable the nftables services, issue the following commands:
    sudo systemctl enable nftables
    sudo systemctl start nftables

  6. Issue the following command to confirm the nftables service is running:
    sudo systemctl status nftables
Important.png
Run virt-manager as a regular user, not as root
Otherwise all your virtual machines will be owned by root and you won't be able to use them as a regular user.
  1. Start the graphical tool by selecting the menu options Applications>System Tools>Virtual Machine Manager or by typing the command virt-manager (without sudo!)
  2. You will be learning in the next investigation to perform several different types of Red Hat Linux installs.

Part 2: Configure VMware Workstation for Nested VMs

Although we are using VMware Workstation to run our r9host VM, we will now install and configure another virtualization package called KVM in order to install the remaining VMs for this course. Since we are "nesting" VMs (i.e. running a VM inside another VM) we need to configure our r9host's Linux boot-up parameters in order to allow these VMs to run efficiently.

Perform the following steps:
  1. In a terminal use elevated privileges to edit the file called: /etc/modprobe.d/kvm.conf
    • If this file doesn't exist, double-check your UEFI settings in VMWare Workstation for r9host. If BIOS is selected, you MUST redo Lab 1.
  2. Search for the first occurrence of the Linux Kernel boot command. Do not make the following changes on more than one entry!
  3. Uncomment (remove the #) the boot option: options kvm_intel nested=1 (for AMD processors options kvm_amd nested=1).
    Important.png
    About the reference settings shown below
    • Only ONE of these settings might be applicable.
    • Enter JUST the text highlighted in BLUE as your kernel version, root, and LVM settings might vary slightly.
    -->