Skip to content

Getting Started

This tutorial walks through building your first Linux kernel with ELMOS on macOS.

Ensure ELMOS is installed and the workspace initialized.

Choose a target architecture (e.g., RISC-V):

Terminal window
./build/elmos arch riscv

This auto-selects the riscv64-unknown-linux-gnu toolchain if installed.

Clone the Linux kernel repository:

Terminal window
./build/elmos kernel clone

This makes a shallow clone of the pinned tag (v6.18) into the workspace volume and applies the macOS host patches that elmos ships for that tag. Use --ref <tag> for another tag and --full for the whole history.

Generate a default config:

Terminal window
./build/elmos kernel config defconfig

For custom config, use menuconfig:

Terminal window
./build/elmos kernel config menuconfig

Build the kernel with the detected toolchain:

Terminal window
./build/elmos kernel build

This may take 10-30 minutes depending on hardware (about 7 minutes on an Apple M-series Mac for arm64 defconfig).

Building Linux natively on macOS is experimental: upstream does not support macOS as a build host, and ELMOS’s workarounds are kept for the pinned v6.18 kernel only.

Create the root filesystem:

Terminal window
./build/elmos rootfs create

By default this pulls alpine:3 for the target architecture and writes it straight into an ext4 image (a few seconds, no sudo). Alpine’s busybox provides insmod and ip, so modules load and the network comes up. Choose another image with --image debian:stable-slim (no insmod, no ip: add them yourself), or the debootstrap path with --engine debootstrap (needs sudo).

Boot the kernel in QEMU:

Terminal window
./build/elmos qemu run

You should see the Linux boot process. Login with root (no password).

For debugging, run with GDB stub:

Terminal window
./build/elmos qemu debug

Connect GDB in another terminal:

Terminal window
gdb-multiarch build/linux/vmlinux
(gdb) target remote :1234

If builds fail, check Troubleshooting or run ./build/elmos doctor.