Installing Debian 11 on an LXC container

Introduction

This is a work in progress! Last updated 09/12/2021.

This page describes the procedure for installing Debian 11 on an LXC-based container. The procedure is deliberately kept as short as possible, with most of the work being offloaded to PCMS. Other pages on this website explain how to configure server applications.

Prologue

  1. Prepare DNS entries.
  2. Perform a full backup! Yes, really.
  3. Assign a UID+GID offset for the container; what this really means is:
    1. Create a list (e.g. on paper, in a file, in git, …) and ensure there is only ever one instance of it (i.e. don’t copy it somewhere else for your convenience). For myself: my list is pasta.net:~alexis/doc/def/computing/container-uid-gid-shifts/container-uid-gid-shifts.txt).
    2. Add to it a entry of the form:
      <index>:<container-name>:<offset>

      where:

      • <index> is an integer starting with 1 and is unique in the list
      • <container-name> is the name of the container
      • <offset> is equal to <index> * 100000
    3. Never ever change the values!
    4. Remove an entry only when the container is decommissioned!

Procedure

  1. The page that led you here should have specified volume and container creation commands; run them on one node of the virtualisation cluster now.
  2. Start the container with:
    virsh --connect=lxc:/// start <container-name> --console

    and log in as root.

  3. Disable various mounts that won’t work in containers:
    systemctl mask sys-kernel-debug.mount
    systemctl mask sys-kernel-tracing.mount
    systemctl mask sys-kernel-config.mount
    systemctl mask systemd-journald-audit.socket
  4. Align the set of installed packages with a common PM/KVM-VM/LXC baseline (see here for more details) by running:
    apt -y --no-install-recommends install cron whiptail vim-tiny rsyslog apt-utils
    apt -y --purge autoremove dialog
  5. Install and run PCMS.

See also