By Kevin McAleer, 6 Minutes
Page last updated November 24, 2026

By the end of this lesson you will be able to flash a 64-bit Raspberry Pi OS card for each node with its own hostname and SSH access, and turn on the memory cgroup that K3s needs.
K3s runs on several 64-bit Linux systems. In this course I use Raspberry Pi OS Lite (64-bit), the headless version with no desktop, because it is the official, well-supported choice and it matches the other Pi courses on this site. Ubuntu Server for Raspberry Pi also works well, and the steps below note where it differs.
Pick the 64-bit image. Container images for Pis are mostly published for arm64, and a 32-bit OS cuts you off from many of them.
flowchart LR
A["Flash Pi OS Lite 64-bit<br/>with Imager settings"] --> B["Boot and ssh in"]
B --> C["Update packages"]
C --> D["Enable memory cgroup"]
D --> E["Reboot and check"]
Use Raspberry Pi Imager from raspberrypi.com/software. For each Pi:
pi-server, pi-node1, pi-node2), a username and password, and enable SSH. Add your Wi-Fi details only if you must, though we will use Ethernet.Setting the hostname here means every card is unique from the start. This matters later: K3s identifies each node by its hostname, and two nodes with the same name will clash.
You may see old guides telling you to create an empty file called ssh on the boot partition. Imager’s customisation does that job for you, so you do not need it.
Give the Pi a minute or two, then from your computer:
Replace pi with the username you chose. If the name does not resolve, find the Pi’s address in your router’s device list and use that instead. Then update the system:
sudo apt update && sudo apt full-upgrade -y
On Ubuntu Server the same commands work, and the first login asks you to change a default password.
Kubernetes limits and measures memory with Linux control groups (cgroups). On Raspberry Pi OS the memory cgroup is switched off by default, and K3s will refuse to start without it, with an error asking you to add cgroup_memory=1 cgroup_enable=memory to the kernel command line.
The kernel command line lives in cmdline.txt. On current Raspberry Pi OS (Bookworm and later) it is at /boot/firmware/cmdline.txt. On older releases it was /boot/cmdline.txt. Ubuntu for the Pi also uses /boot/firmware/cmdline.txt.
This file must stay on one single line. Append the two settings to the end of that line with a space before them:
sudo sed -i '$ s/$/ cgroup_memory=1 cgroup_enable=memory/' /boot/firmware/cmdline.txt
cat /boot/firmware/cmdline.txt
The cat should show one long line ending in cgroup_memory=1 cgroup_enable=memory. If you see two lines, or the settings are on a line of their own, fix it with sudo nano /boot/firmware/cmdline.txt. Then reboot:
sudo reboot
After the Pi is back, check that the memory controller is enabled:
grep memory /proc/cgroups
The line that starts with memory should end with a 1 in its last column (enabled). If it ends in 0, the setting did not take.
Before moving on, on every node:
ssh in using the hostname you chosehostname prints the right namegrep memory /proc/cgroups ends in 1Teachers: Flashing cards is the slow step in a class. Prepare the cards beforehand, one per Pi, and label each card and Pi with its hostname (a coloured sticker works well). Make sure learners write down the username and password they set, since a forgotten password means reflashing. Editing
cmdline.txtis a good moment for a pair check, because one stray line break stops the Pi booting properly.
ssh in by hostname.uname -m and confirm it prints aarch64, the sign of a 64-bit OS.free -h before and after enabling the cgroup. Does available memory change much?ssh: Could not resolve hostname pi-server.local..local names (mDNS).Why: .local names rely on multicast DNS, which some networks and operating systems block.
cmdline.txt.Why: The kernel reads the whole file as one command line, so a stray line break can split or lose settings.
Failed to find memory cgroup./boot/firmware/cmdline.txt, not /boot/cmdline.txt, then reboot./boot/firmware, so edits to the old path are ignored.Quick quiz 1 of 3
Where is the kernel command line file on current Raspberry Pi OS?
Quick quiz 2 of 3
Why must cmdline.txt stay on one line?
Quick quiz 3 of 3
Why do we set a different hostname for each Pi when flashing?
Comments