Building Custom Linux with Yocto on Hetzner: With 9 Steps

Search for a command to run...

No comments yet. Be the first to comment.
A complete, code-first walkthrough of building a live object detector using YOLOv8, ONNX, and OpenCV's DNN module — no Python required at runtime. Introduction Object detection has become one of the m

Recently it was announced that Sandpack will no longer be actively maintained. Not really great news to wake up to, but C'est la vie. I personally was introduced to Sandpack when going through the blo

ERPNext provides a powerful REST API that allows you to integrate external applications, automate workflows, and extend functionality. This guide will walk you through both consuming existing APIs and creating your own custom APIs in ERPNext. Underst...

C++ gives developers a lot of control over memory and performance. That control is also the reason many bugs in C++ are subtle, hard to detect, and sometimes disastrous.Most of these issues are not caused by advanced features, but by small, everyday ...

When a chess engine looks at a position, it does not rely on intuition or experience. Instead, it assumes two things: It will always try to play the best possible move Its opponent will also always try to play the best possible move The Minimax a...

Building a custom Linux distribution gives you complete control over your system's components, dependencies, and footprint. The Yocto Project is the industry-standard framework for creating tailored Linux distributions, and Hetzner provides powerful, affordable dedicated servers perfect for compilation workloads. This guide walks you through the entire process of building a custom Linux system using Yocto on a Hetzner server.
Yocto Benefits:
Complete control over every system component
Optimized for embedded and production systems
Reproducible builds
Extensive hardware support
Active community and commercial backing
Hetzner Advantages:
Powerful dedicated servers at competitive prices
High-speed network connectivity
Located in European data centers
Excellent build server specifications
No bandwidth limitations for compilation tasks
Before starting, you'll need:
A Hetzner dedicated server (minimum 16GB RAM, 4+ cores recommended)
Ubuntu 22.04 LTS or Debian 11+ installed
Root or sudo access
At least 100GB free disk space
Basic Linux command line knowledge
Log into the Hetzner Robot panel and provision a dedicated server. For Yocto builds, I recommend:
CPU: Intel Xeon or AMD Ryzen with 6+ cores
RAM: 32GB or more (builds are memory-intensive)
Storage: NVMe SSD preferred for faster compilation
Once provisioned, SSH into your server and update the system:
ssh root@your-server-ip
apt update && apt upgrade -y
Yocto requires several build tools and libraries. Install them with:
apt install -y gawk wget git diffstat unzip texinfo gcc build-essential \
chrpath socat cpio python3 python3-pip python3-pexpect xz-utils \
debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa \
libsdl1.2-dev pylint xterm python3-subunit mesa-common-dev zstd liblz4-tool
Never run Yocto builds as root. Create a dedicated build user:
useradd -m -s /bin/bash yocto
usermod -aG sudo yocto
su - yocto
Clone the Yocto Project reference distribution (Poky). We'll use the latest LTS release:
cd ~
git clone git://git.yoctoproject.org/poky
cd poky
git checkout -b my-build scarthgap # LTS release
Source the build environment setup script:
source oe-init-build-env
This creates a build directory and sets up your shell environment. You'll need to source this script every time you open a new terminal session.
Navigate to the build configuration directory and edit local.conf:
cd ~/poky/build/conf
nano local.conf
# Set machine architecture (e.g., x86-64, ARM, etc.)
MACHINE ?= "qemux86-64" # For testing in QEMU
# MACHINE ?= "genericx86-64" # For physical x86-64 hardware
# Increase parallel build tasks based on your CPU
BB_NUMBER_THREADS ?= "8" # Number of CPU cores
PARALLEL_MAKE ?= "-j 8" # Parallel make jobs
# Add systemd support (optional)
DISTRO_FEATURES:append = " systemd"
VIRTUAL-RUNTIME_init_manager = "systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
# Add additional packages to your image
IMAGE_INSTALL:append = " openssh vim htop curl wget"
# Set download directory to save bandwidth on rebuilds
DL_DIR ?= "${TOPDIR}/../downloads"
# Shared state cache for faster rebuilds
SSTATE_DIR ?= "${TOPDIR}/../sstate-cache"
Yocto provides several base images. Choose based on your needs:
core-image-minimal: Bare minimum system
core-image-base: Small image with some utilities
core-image-full-cmdline: Full command-line system
core-image-sato: Image with graphical interface
For a server, core-image-base or core-image-full-cmdline are good starting points.
Launch your first build:
bitbake core-image-minimal
The first build takes 2-8 hours depending on your server specs and will download several gigabytes of source code. Subsequent builds are much faster thanks to caching.
After the build completes, your images are located in:
~/poky/build/tmp/deploy/images/qemux86-64/
Congratulations! For new set of issues in your life