Passa al contenuto principale

Testing LTSP

We will test LTSP in a virtual environment.

LTSP can be used in several scenarios. The most simple and easy one, which is also the most common case, is a computer lab with several identical PCs, which are connected to an ethernet LAN (has a switch and network cables). We also assume that there is a router which acts as a gateway to the internet for this LAN, and also provides DHCP for it.

In this case, we can use any of the PCs of the lab as an LTSP server, and the others will boot from the LAN. The system that we will install on the server will be like a template for the other PCs (the clients). The user accounts that will be created on the server will be available to all the clients.

This is very convenient because we install and maintain only one PC, instead of installing and maintaining all the PCs of the lab. In addition, we also have centralized user accounts.

1. Create virtual machines

In Incus, the default network incusbr0 acts like a gateway for all the virtual machines, and provides DHCP for them.

Let's create two virtual machines, named pc01 and pc02, which will be used for the server and for a client:

incus init pc01 --empty --vm \
--network=incusbr0 \
-d root,size=30GB \
-c limits.memory=8GB \
-c limits.cpu=3
incus config device show pc01
incus config show pc01
incus init pc02 --empty --vm \
--network=incusbr0 \
-c limits.memory=8GB \
-c limits.cpu=3 \
-c security.secureboot=false
incus config device show pc02

incus config device set \
pc02 eth0 boot.priority=1

incus config device show pc02
incus config show pc02

2. Add a cdrom device to the server

Let's try to install LinuxMint Cinnamon on pc01.

  1. Download the ISO:

    wget https://mirror.netcologne.de/linuxmint/iso/stable/22.1/linuxmint-22.1-cinnamon-64bit.iso
  2. Attach the ISO as a CDROM device to the VM:

    incus config device add \
    pc01 cdrom disk \
    source=$(pwd)/linuxmint-22.1-cinnamon-64bit.iso \
    boot.priority=1

    incus config set \
    pc01 security.secureboot=false

    incus config device show pc01
    incus config show pc01

3. Setup Xpra

Xpra is like a "screen for X". It is similar to X11 forwarding, but much more efficient and with lots of features. We need it in order to access the graphical console of the virtual machines.

  1. Install it on the server:

    apt install ca-certificates
    wget -O "/usr/share/keyrings/xpra.asc" https://xpra.org/xpra.asc
    cd /etc/apt/sources.list.d/
    wget https://raw.githubusercontent.com/Xpra-org/xpra/master/packaging/repos/bookworm/xpra-lts.sources
    cat xpra-lts.sources
    apt update
    apt install xpra xpra-x11 \
    virt-viewer tilix dbus-x11

    More details here.

  2. Install it on the client:

    apt install ca-certificates
    wget -O "/usr/share/keyrings/xpra.asc" https://xpra.org/xpra.asc
    cd /etc/apt/sources.list.d/
    wget https://raw.githubusercontent.com/Xpra-org/xpra/master/packaging/repos/noble/xpra-lts.sources
    cat xpra-lts.sources
    apt update
    apt install xpra
  3. Start it from the client:

    xpra --ssh="ssh" start ssh:srv1:200 --start=tilix

    Here, srv1 is the name of the SSH connection, as defined on ~/.ssh/config:

    Host srv1
    HostName 11.12.13.14
    Port 222
    User root
    IdentityFile ~/.ssh/srv1.key

    This will open a Tilix terminal in a graphical window, which is running on the server. If we start an application from this terminal (for example Firefox or Chrome), its window will appear on the local machine, although it is running on the server.

4. Install LinuxMint on pc01

  1. From the Tilix terminal displayed by Xpra, run the command:

    incus start pc01 --console=vga

    It will open the graphical console of the VM and will start it from the ISO that is attached. After booting from the LiveCD, click on the installation icon and follow the installation steps.

  2. When the installation is finished, remove the CDROM from the VM, and boot it again:

    incus stop pc01 --force

    incus config device rm pc01 cdrom
    incus config device show pc01

    incus start pc01
    incus console pc01 --type=vga
  3. Install incus agent inside the VM, to make easier our interaction with the VM (it is not needed on a real environment).

    Login, open a terminal, and run these commands:

    sudo su
    mount -t 9p config /mnt
    cd /mnt
    ./install.sh
    cd
    umount /mnt
    systemctl start incus-agent
  4. Update LinuxMint:

    incus shell pc01
    apt update
    apt upgrade

5. Install LTSP in pc01

Following the instruction from the installation page, we can install LTSP in pc01 like this:

apt install --install-recommends \
ltsp ipxe dnsmasq nfs-kernel-server openssh-server \
squashfs-tools ethtool net-tools epoptes

gpasswd -a user1 epoptes

ltsp dnsmasq
ltsp image /
ltsp ipxe
ltsp nfs
ltsp initrd

For a quick testing, let's start pc01 with vga console:

incus config show pc02

incus start pc02 --console=vga

6. User accounts

  1. Let's download a script that can help with managing user accounts:

    incus shell pc01

    wget https://gitlab.com/docker-scripts/linuxmint/-/raw/master/inject/users.sh
    chmod +x users.sh
    ./users.sh
  2. Let's create a new account:

    echo "user01:pass01" | ./users.sh create
    groupadd student
    echo "user01:pass01" | ./users.sh create
    ls /home/
  3. Create some more accounts:

    ./users.sh create << EOF
    user02:pass02
    user03:pass03
    user04:pass04
    user05:pass05
    EOF
  4. Update initrd:

    ltsp initrd
  5. Start again pc02 from Tilix and try to login as one of these users:

    incus stop pc02 -f
    incus start pc02 --console=vga

7. Improvements

  1. There is a problem when trying to start epoptes (the module distutils is missing). We can fix it by installing the package python3-setuptools:

    incus shell pc01
    apt install python3-setuptools
  2. We don't want to display the list of all the users on the login screen. We can fix it like this:

    cat > /etc/ltsp/ltsp.conf
    [clients]
    LIGHTDM_CONF="greeter-hide-users=true"
    EOF

    cat /etc/ltsp/ltsp.conf
    ltsp initrd

    NOTE: For more configuration details see: https://ltsp.org/man/ltsp.conf/

    NOTE: Whenever we modify the configuration or user accounts, we have to do ltsp initrd in order to make them available to the clients.

  3. When we update pc01 with apt update ; apt upgrade, or when we install new packages and want to make them available to the clients, we have to rebuild the image that is used by the clients:

    ltsp image /

    NOTE: This takes some time.