Chapter 1: Build Your Practice Lab

Project, profile and extra disks

Phases 05 to 07: give the lab its own LXD project, turn the project's default profile into a template that creates the lab users on first boot, and create the two spare disks the storage chapters need.

Phase 05 · Create the rhce project (~2 min)

  • Keep the lab in its own LXD project so it cannot collide with anything else on the machine.

LXD UI: create the project

Project selector (top left) → Create project:

FieldValueWhy
Project namerhce
DescriptionKernel Path practice lab
FeaturesCustomised
Allow custom profiles✓ onThe lab gets its own template
Allow storage volumes✓ onThe extra disks belong to the lab
Allow imagesoffShare downloaded images
Allow networksoffUse rhcebr0 from the previous section

LXD UI: switch to it

Click Create, then switch the selector to rhce. Stay in it from now on.

Host: make the command line use it too

Then you don't need --project rhce on every command.

lxc project switch rhce

The lab profile

A profile is a template every VM inherits. The rhce project's default profile becomes the lab template: disk, network, size, and a cloud-init script that creates the users on first boot.

PartWhat it does
limits.*Default VM size. You raise it for workstation only.
users: / chpasswd:Creates student (with sudo) and sets root's password
packages:Manual pages and everyday tools, LVM, tar and rsync for the storage and transfer chapters, a nicer vim, plus the SELinux policy, firewalld and chrony a RHEL server has
runcmd: + preserve_hostnameSets the full hostname from the VM name, e.g. servera.lab.example.com, and keeps it after reboots. Also switches on firewalld and chrony, and keeps lxc exec working under SELinux
power_state:Reboots once after the first boot, so SELinux labels the disk and starts in enforcing mode
devices:A 20 GiB system disk and a network card on rhcebr0

Phase 06 · Set up the lab profile (~10 min)

  • Make every new VM boot with the lab users, packages and hostname.

LXD UI: open the profile editor

Project rhce → Profiles → default → Configuration → YAML configuration → Edit profile.

LXD UI: replace everything and save

Replace the whole profile with this, then Save changes. Nothing needs editing.

name: default
description: Kernel Path lab machine template
config:
  limits.cpu: "1"
  limits.memory: 1GiB
  security.secureboot: "false"        # avoids boot problems with Rocky VM images
  cloud-init.user-data: |
    #cloud-config
    ssh_pwauth: true                  # VM-to-VM password SSH
    preserve_hostname: true           # keep the FQDN set below across reboots
    users:
      - name: student
        gecos: Student User
        groups: [wheel]               # wheel = sudo with password
        shell: /bin/bash
        lock_passwd: false
        plain_text_passwd: student
    chpasswd:
      expire: false
      users:
        - name: root
          password: redhat
          type: text
    timezone: UTC                     # or your own, e.g. Europe/London
    packages:
      - python3
      - vim-enhanced
      - bash-completion
      - man-db                        # manual pages for the help chapter
      - man-pages
      - tree
      - tmux
      - lsof
      - nano
      - bind-utils                    # dig and host, for the networking chapter
      - lvm2
      - tar
      - rsync
      - selinux-policy-targeted       # the image ships without SELinux; RHEL runs it enforcing
      - policycoreutils-python-utils  # semanage and friends
      - firewalld                     # running by default, as on a RHEL server
      - chrony
    runcmd:
      - hostnamectl set-hostname "$(cloud-init query local_hostname).lab.example.com"
      - semanage fcontext -a -t bin_t "/var/run/lxd_agent(/.*)?"   # keeps lxc exec working under SELinux
      - systemctl enable --now firewalld chronyd
    power_state:                      # reboot once: SELinux labels the disk and switches on
      mode: reboot
      condition: test -e /.autorelabel
devices:
  root:
    type: disk
    path: /
    pool: default
    size: 20GiB
  eth0:
    type: nic
    name: eth0
    network: rhcebr0

Phase 07 · Create the extra disks (~5 min)

  • Give servera and serverb an empty 5 GiB disk each for the partition, LVM, file system and NFS exercises.

LXD UI: create two block volumes

Twice, for servera-disk2 and serverb-disk2: Storage → Volumes → Create volume.

FieldValue
Nameservera-disk2
Storage pooldefault
Size5 GiB
Content typeblock