Growing Wiki

Setting up VM for enterprise environment

🌿 Budding

The Enterprise Virtualization Stack

I will need to set up my instance of Virtual Machine in a way that sort of replicates a professional enterprise environment as closely as possible.

So instead of using a third-party application like VirtualBox, I will instead go for the native Linux virtualisation stack.

Components for the stack

  • KVM ( Kernel-based Virtual Machine ) - Handles the heavy lifting of CPU and memory
  • QEMU - The “hands and feet” of the VM, providing the emulated hardware ( think USB ports and network cards, etc )
  • Libvirt - The “engine” or “nervous system” of the VM; The API that controls the brain and body.
  • Virt-manager - The “user interface” you interact with. 1

Infrastructure Setup

I will be using virt-install to ensure the environment is reproducible.

Preparation

Before that, we need to make sure that Libvirt is installed and libvirtd is running.

sudo pacman -S libvirt

sudo systemctl enable libvirtd.service    # This will also enable virtlogd.socket
                                          # and virtlocked.socket

sudo systemctl start libvirtd.service

And we will also need a copy of the ISO, we could do so by using the wget to download a copy from Rocky Linux’s website. In this case, I chose the minimal version which is likely to be better for learning purpose as we don’t require “unnecessary” tools that the default ships with.

wget https://download.rockylinux.org/pub/rocky/10/isos/x86_64/Rocky-10.1-x86_64-minimal.iso ~/Download/
# This basically pulls the minimal version of ISO from their website
# and download it onto the "Download" folder in our home directory.

Virsh

Virsh is the program we will use to manage our virtual machines in our terminal, without a GUI. The command will be available as part of the libvirt library.

You can run an interactive terminal by simply running just virsh, which also has support for tab completion.

Storage Pools

To proceed with our installation of VM, we will need a specified location where our storage volume can be kept. This is often called “virtual disks” or “virtual machine images” in other tools.

Pool locations can be:

  • directory
  • network filesystem
  • partition

Pools can also be toggled active or inactive and allocated for space.

  • Creating a new pool

    There are couple of different ways to create a new pool, depending on the type of pool you wish to use.

    virsh pool-define-as poolname /home/user/dir --targer /target/dir
    

    Next up, we will have to build and start the pool that we’ve created:

    virsh pool-build poolname
    virsh pool-start poolname
    virsh pool-autostart poolname
    

Domain

After the pool has been created and started successfully, we will need a domain. A domain is basically the “virtual machine”, think of it as an instance of a machine.

Installation

We can do this in two main ways, either graphically using virt-manager or in terminal with a CLI tool ( in this case, we will use virt-install ).

First, installed the package sudo pacman -S virt-install.

And then we will run the command like so ( with minor tweaks to the directories ): This command does not only “install” but also defined the virtual hardware.

virt-install \
    --name rocky-node-01 \
    --memory 2048 \
    --vcpus 2 \
    --os-variant rocky10 \
    --disk pool=rocky,path=/home/dir/to/install-location,size=10 \
    --location /home/dir/to/image/Rocky-10.1-x86_64-minimal.iso \
    --graphics=none \
    --extra-args="console=ttyS0"
  • Installation command break down

    virt-install - the tool for installing domains/VMs

    --name rocky-node-01 = the name of the VM, “node-01” is just a naming convention

    --memory 2048 = assigned memory for the VM, in this case, 2GB

    --vcpus 2 = virtual CPU cores

    --os-variant rocky10 = the OS we are installing (not required to be defined)

    --disk ... = “pool” is the pool we made earlier, “path” is the path to the location where we want the VM file to be and “size” is the size of the VM image file (10G)

    --location = location of the ISO file

    --graphics=none = no graphical interface

    --extra-args = “console=ttyS0” is basically the first serial port, which mitigates the need for a graphical interface

  • Finalisation

    After the virt-install command is run, we will get prompts and instructions on installing the system and some configurations. For now, it’s safe to just choose the defaults. And all we need to do is set up password for the root account as well as user account ( which will also be given the admin/root privilege ).

    And … we should be able to boot up the brand new VM with the login prompt!

The Next Step

So now we should have a running virtual machine. Let’s proceed onto learning about the new distro!


  1. This is no longer part of the stack after consideration ↩︎