TurboPanel Docs
Using TurboPanel

Raspberry Pi, databases and memory limits

A Raspberry Pi needs two boot changes before TurboPanel works fully on it: the 4 KiB kernel, so apps can reach managed databases, and memory limits turned on, so the limits TurboPanel sets on services and containers are enforced. A first install makes both and restarts the server once.

The 4 KiB kernel

Every server whose apps use a managed database runs a small database proxy. Apps connect to localhost:13306 (MySQL and MariaDB) or localhost:15432 (Postgres), and the proxy sends each connection to the right database server, using the login name. This is true even when no database runs on that server.

The proxy needs a 4 KiB memory page size. A Raspberry Pi 5 on Raspberry Pi OS (Debian 13, "trixie") uses a 16 KiB kernel by default, and the proxy cannot start on it. Until the Pi boots the 4 KiB kernel, apps on it cannot reach their databases.

Switch an existing server

Run this on the server. It needs sudo. The installer only restarts on a first install; on a server that is already installed or already enrolled, you run this yourself:

Terminal
sudo /opt/turbopanel/share/orchestration/scripts/tp-orchestrate kernel-features status
sudo /opt/turbopanel/share/orchestration/scripts/tp-orchestrate kernel-features apply pi-4k-pagesize --reboot

status prints three tab-separated columns: feature id, state, and reason. Tabs are shown as spaces here. When the server can switch:

PLAINTEXT
pi-4k-pagesize    switchable    this server can switch to the 4 KiB kernel (a restart is needed)

The state is one of not-applicable, switchable, restart-needed, ready, or blocked.

When status prints switchable for pi-4k-pagesize, the server can switch.

apply copies /boot/firmware/config.txt to config.txt.tp-backup-<date and time> in the same directory, then adds the line kernel=kernel8.img at the top of config.txt.

With --reboot, it waits until the server has finished enrolling with TurboPanel, then shows a countdown (Restarting in 10 second(s)…). Press Ctrl-C to cancel and restart yourself later.

When the server is back, getconf PAGESIZE prints 4096 and status prints ready. The database proxy then starts by itself.

Leave out --reboot to save the change and restart on your own schedule. status then reads restart-needed.

Memory limits

Raspberry Pi firmware starts the kernel with cgroup_disable=memory. That turns off the kernel's memory controller, so memory limits on services and containers are accepted but not enforced: a service can use more memory than its limit. You can see it on the server: memory is missing from /sys/fs/cgroup/cgroup.controllers.

The pi-memory-cgroup feature turns the controller back on. The kernel reads its settings in order, so a cgroup_enable=memory after the firmware's own setting wins.

Terminal
sudo /opt/turbopanel/share/orchestration/scripts/tp-orchestrate kernel-features status pi-memory-cgroup
sudo /opt/turbopanel/share/orchestration/scripts/tp-orchestrate kernel-features apply pi-memory-cgroup --reboot

When status prints switchable for pi-memory-cgroup, the server can turn memory limits on.

apply copies /boot/firmware/cmdline.txt to cmdline.txt.tp-backup-<date and time> in the same directory, removes any cgroup_disable=memory from its single line and adds cgroup_enable=memory at the end. The line ending stays as it was. Spaces at the end of the line are dropped, and when it removes cgroup_disable=memory, runs of spaces between the other settings become one.

With --reboot, it restarts the server the same way as the kernel switch: after enrolment, with a countdown you can cancel with Ctrl-C.

When the server is back, memory is listed in /sys/fs/cgroup/cgroup.controllers and status prints ready. Running apply again then prints state=ready changed=no.

It does nothing when the server is not a Raspberry Pi, when the memory controller is already on, or when the controller is off for another reason than the firmware's cgroup_disable=memory. status says blocked, and nothing is changed, when:

  • cmdline.txt is missing, empty, has more than one line, or has no root= setting.
  • cmdline.txt holds a control character other than a tab and the line ending (for example a stray carriage return inside the line).
  • config.txt has a cmdline= or os_prefix= setting, so the firmware may read another command line file.
  • cmdline.txt turns off control groups itself (for example cgroup_disable=cpu,memory).
  • The kernel already started with cgroup_enable=memory and the controller is still missing (a restart would not help).

At install time

On a Raspberry Pi, the installer makes both changes as its last step, after everything else is installed — but only on a first install. It records whether the server was already enrolled, then explains what is about to happen and saves every change that applies. Before it restarts the server, once, it waits:

  1. for fresh enrolment files, so the server can enrol after the restart,
  2. for TurboPanel to finish setting up the server (its first setup run, which can take several minutes on a Pi),
  3. until no software is being installed (no apt, dpkg, unattended upgrade or setup run is going),

then it stops the TurboPanel daemon so it starts nothing new, counts down from 10 and restarts. It comes back by itself, usually in about a minute, and no further restart is needed. If a wait runs out, it does not restart and prints sudo reboot for you to run when the server is ready. Press Ctrl-C during the countdown to cancel; the changes are already saved and take effect at the next restart, and the daemon starts again, as it does whenever the restart does not happen. If one change is saved and the next one fails, it says the saved change needs a restart.

On a re-run of the installer on an already installed server, or on a server that is already enrolled, it never restarts: it prints the apply commands instead. Updates never do this, and it never restarts while an update is waiting to be confirmed.

To skip both changes, set TURBOPANEL_SKIP_KERNEL_SWITCH=1 when you run the installer. To keep only memory limits off, set TURBOPANEL_SKIP_MEMORY_LIMITS_SWITCH=1. You can run the commands above later instead. To undo it afterwards, see Undo.

Terminal
curl -fsSL https://turbopanel.sh | TURBOPANEL_SKIP_MEMORY_LIMITS_SWITCH=1 TURBOPANEL_LICENSE=<license> sh

When the kernel switch does nothing

  • The server is not a Raspberry Pi.
  • The OS is not Raspberry Pi OS on Debian 13 ("trixie").
  • The page size is already 4 KiB.
  • /boot/firmware/config.txt already chooses another kernel. It is left as it is, and status says blocked.
  • The 4 KiB kernel modules (*-rpi-v8) are not installed, and status says blocked.
  • config.txt has auto_initramfs=1 but initramfs8 is missing from the boot partition, and status says blocked.

Undo

Terminal
sudo /opt/turbopanel/share/orchestration/scripts/tp-orchestrate kernel-features undo pi-4k-pagesize
sudo /opt/turbopanel/share/orchestration/scripts/tp-orchestrate kernel-features undo pi-memory-cgroup
sudo reboot

undo only takes back what TurboPanel added; a marker in /var/lib/turbopanel-kernel records that. For pi-4k-pagesize it removes the kernel=kernel8.img line. For pi-memory-cgroup it puts the cmdline.txt line back exactly as it was; if the line was edited since, it only removes cgroup_enable=memory. If you made either change yourself, it prints Nothing to undo and you change the file by hand. undo never restarts the server. The backup copies are left in place.

After a purge the tp-orchestrate command is gone, but both boot settings stay on purpose: taking the kernel=kernel8.img line out changes the kernel the board boots, and taking cgroup_enable=memory out turns memory limits off. The purge summary says so. To undo them by hand, delete the kernel=kernel8.img line from /boot/firmware/config.txt if you want the 16 KiB kernel back, remove cgroup_enable=memory from the line in /boot/firmware/cmdline.txt (keep it one line), or copy the oldest /boot/firmware/*.tp-backup-… copy of a file back over it (later copies were made by later changes, including undo). Then restart. Delete the backup copies and /var/lib/turbopanel-kernel once you no longer need them.

If a Pi does not come back

Take the SD card out and mount its boot partition on another computer. Delete the kernel=kernel8.img line from config.txt and cgroup_enable=memory from cmdline.txt, or copy the config.txt.tp-backup-… and cmdline.txt.tp-backup-… files over them, then put the card back.

Edit on GitHub

Last updated on

On this page