Skip to main content

Intro

Libvirtd

The libvirtd program is the server side daemon component of the libvirt virtualization management system. This daemon runs on host servers and performs required management tasks for virtualized guests. This includes activities such as starting, stopping and migrating guests between host servers, configuring and manipulating networking, and managing storage for use by guests. The libvirt client libraries and utilities connect to this daemon to issue tasks and collect information about the configuration and resources of the host system and guests. (see https://libvirt.org/manpages/libvirtd.html)

Virt-install

virt-install is a command line tool for creating new KVM , Xen, or Linux container guests using the "libvirt" hypervisor management library. See the EXAMPLES section at the end of this document to quickly get started. virt-install tool supports both text based & graphical installations, using VNC or SDL graphics, or a text serial console. The guest can be configured to use one or more virtual disks, network interfaces, audio devices, physical USB or PCI devices, among others. The installation media can be held locally or remotely on NFS , HTTP , FTP servers. In the latter case virt-install will fetch the minimal files necessary to kick off the installation process, allowing the guest to fetch the rest of the OS distribution as needed. PXE booting, and importing an existing disk image (thus skipping the install phase) are also supported.

To see more details about virt-install options, please visit https://linux.die.net/man/1/virt-install To see more details about virt-manager and the graphical interface, please visit https://virt-manager.org/

Image-based process step by step

We have to create the image based and prepare the image with ignition and combustion files. Basically we will use the following documents as reference to create the image changing the base SLEMicro image to be downloaded (in this case will be SLE Micro x86_64):

  • Download the raw image file from the SUSE website at https://www.suse.com/download/sle-micro/
    • Select AMD64/Intel 64 architecture
    • Look for the raw file (I.e.- SLE-Micro.x86_64-5.4.0-Default-GM.raw.xz)

NOTE: You need to have a valid user on the SUSE site to be able to download the file.

If you are trying to download to a remote server, you can use scp to copy that file to the server.

  • Access to SCC.suse.com to generate a registration code

    • Search for SUSE Linux Enterprise Micro via the Products menu, select the arch/version then copy and manually activate the registration code
  • Butane, qemu-img and cdrtools installed (using zypper for example)

 sudo zypper install butane qemu-tools xz mkisofs
  • Unzip the file
  xz -d SLE-Micro.x86_64-5.4.0-Default-GM.raw.xz 
  • Resize the image file. In this example, to 30G
 qemu-img resize -f raw ~/PATH-TO-FILE/SLE-Micro.x86_64-5.4.0-Default-GM.raw 30G > /dev/null

Convert the raw image to qcow2

qemu-img convert -O qcow2 SLE-Micro.x86_64-5.4.0-Default-GM.raw slemicro

Ignition & Combustion files

To automate the installation, we will leverage Butane, Ignition and Combustion as explained before:

  • Create a temporary folder to store the assets

    TMPDIR=$(mktemp -d)
  • Create the required folders for ignition and combustion

    mkdir -p ${TMPDIR}/{combustion,ignition}
  • Create a config.fcc butane config file as required. See the following example to set a root password for the root user, and to configure the hostname to be "slemicro"'

    cat << 'EOF' > ${TMPDIR}/config.fcc 
    variant: fcos
    version: 1.4.0
    storage:
    files:
    - path: /etc/hostname
    mode: 0644
    overwrite: true
    contents:
    inline: "slemicro"
    passwd:
    users:
    - name: root
    password_hash: "$y$j9T$/t4THH10B7esLiIVBROsE.$G1lyxfy/MoFVOrfXSnWAUq70Tf3mjfZBIe18koGOuXB"
    EOF
  • Create a script combustion file as required. See the following example to register the SLE Micro instance to SUSE's SCC (use your own email/regcode) and to create a /etc/issue.d/combustion file

    cat << EOF > ${TMPDIR}/combustion/script  
    #!/bin/bash
    # combustion: network

    # Redirect output to the console
    exec > >(exec tee -a /dev/tty0) 2>&1

    # Set hostname at combustion phase for SUSEConnect
    hostname slemicro

    # Registration
    if ! which SUSEConnect > /dev/null 2>&1; then
    zypper --non-interactive install suseconnect-ng
    fi

    SUSEConnect --email foobar@suse.com --url https://scc.suse.com --regcode YOURCODE

    # Leave a marker
    echo "Configured with combustion" > /etc/issue.d/combustion
    EOF
  • Convert the butane config to ignition

    butane -p -o ${TMPDIR}/ignition/config.ign ${TMPDIR}/config.fcc
  • Create an ISO file. It is requried for both ignition and combustion to work that the ISO is labeled as ignition (hence the -V parameter)

    mkisofs -full-iso9660-filenames -o ignition-and-combustion.iso -V ignition ${TMPDIR}
  • Optional: Remove the temporary folder

    rm -Rf ${TMPDIR}

Create the VM

virt-install --name MyVM --memory 4096 --vcpus 4 --disk ./slemicro --import --cdrom ./ignition-and-combustion.iso --network default --osinfo detect=on,name=sle-unknown

NOTES:

  • Pass the --noautoconsole flag in case your console hangs on the installation, this will allow you to run other commands without CTRL-C interrupt
  • Pass the --debug flag if you run into issues
  • If you run into an issue and you need to restart, or if you get an error saying that MyVM is already running, run this command:
 virsh destroy MyVM ; virsh undefine MyVM

After a couple of seconds, the VM will boot up and will configure itself using the ignition and combustion scripts, including registering itself to SCC

virsh list
Id Nombre State
----------------------------------
14 MyVM running

Access to the vm

You can access to the VM using virsh console:

virsh console MyVM

Connected to domain MyVM

or using ssh directly and the user set in the ignition file (in this case root)

virsh domifaddr MyVM
Nombre MAC address Protocol Address
-------------------------------------------------------------------------------
vnet14 52:54:00:f0:be:e5 ipv4 192.168.122.221/24

ssh root@192.168.122.221

Delete the VM

virsh destroy MyVM ; virsh undefine MyVM