Installing Debian 12 on an LXC container

Last updated:05.04.2023

Warning: this page is in development!

Introduction

This page describes the procedure for installing Debian 12 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. It is hoped that eventually this procedure will support ZFS datasets as backing storage, rather than zvols. However, for the time being it supports zvols. As such make sure to complete the ‘Hypervisor plugins’ section of Configuring virtualisation services (revision 4).

Creating a basic container

  1. 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
  2. If not done already then download the virttools module:
    mkdir -p ~/opt
    svn co https://svn.pasta.freemyip.com/main/virttools/trunk ~/opt/virttools
  3. Decide on the volume names: if the container will have only one disk then <vol-name> should probably be <container-name>. If the container will have more than one disk then the <vol-name>s should probably be something like <container-name>_<one-word-description> or alternatively <container-name>_disk1, <container-name>_disk2, etc.
  4. The page that led you here should have specified volume and container creation commands; run them on one node of the virtualisation cluster now.
  5. Start the ccntainer with:
    virsh --connect=lxc:/// start <container-name> --console
    

Post-basic-OS-installation

  1. Log in as root.
  2. No packages need to be added or removed at this point as my lxc-debian template did it already. (The same does not apply to a PM/VM.)
  3. Install and run PCMS.

See also