Skip to content

Instantly share code, notes, and snippets.

@jmarhee
Last active May 4, 2024 16:12
Show Gist options
  • Save jmarhee/2fd1abb6699bf97810ff9bceaeed9842 to your computer and use it in GitHub Desktop.
Save jmarhee/2fd1abb6699bf97810ff9bceaeed9842 to your computer and use it in GitHub Desktop.

Install Elemental with virt-install on KVM

Using virt-install to install SUSE Elemental on KVM.

Prerequisites

When creating your Machine Registration Endpoint in the Rancher UI, ensure that registration.emulated-tpm-seed is set to -1, if you plan to add more than a single machine using the ISO you will be building.

For example:

config:
  cloud-config:
    users:
      - name: root
        passwd: root
  elemental:
    install:
      device: /dev/vda
      poweroff: true
    registration:
      auth: tpm
      emulate-tpm: true
      emulated-tpm-seed: -1
    reset:
      reboot: true
      reset-oem: true
      reset-persistent: true
machineInventoryLabels:
  environment: suse-qemu-local-dev
  machineUUID: '"${System Information/UUID}"'
  manufacturer: '"${System Information/Manufacturer}"'
  productName: '"${System Information/Product Name}"'
  serialNumber: '"${System Information/Serial Number}"'

Running

Once your ISO is downloaded this script assumes a default image path of /var/lib/libvirt/images and that your ISO will be under that path. It assumes an external bridge, br0, please update to reflect your host configuration (i.e. default virbr0).

The script takes positional arguments for the path to the ISO, the memory allocation in MB, and vcpus:

./boot.sh elemental-general-2023-11-18T04_34_47Z.iso 8196 4

Connect to the console to view the setup:

/var/lib/libvirt/images# virsh list
 Id   Name                 State
------------------------------------
 6    rancher              running
...
 23   elemental-32b69400   running
 24   elemental-4cbfd4e4   running
 25   elemental-f621b6b6   running
virsh console 23

Upon completion, the machines will reboot to the virtual disk.

Check your Rancher UI for the Machine Inventory which will update with your new machines during the initial installation, and will show active once the reboot to the virtual disk is completed, and you can proceed to create your Elemental cluster.

#!/bin/bash
VM_NAME=$(openssl rand -hex 4)
MEMORY=$2
VCPU=$3
sudo qemu-img create /var/lib/libvirt/images/${VM_NAME}-system.img 80G
sudo virt-install \
--name=elemental-${VM_NAME} \
--ram=${MEMORY} --vcpus=${VCPU} \
--cdrom=/var/lib/libvirt/images/$1 \
--os-variant=slem5.2 \
--disk path=/var/lib/libvirt/images/${VM_NAME}-system.img \
--network bridge=br0,model=virtio --graphics vnc,listen=0.0.0.0 --noautoconsole \
--tpm backend.type=emulator,backend.version=2.0,model=tpm-crb \
--boot uefi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment