Getting Started
This tutorial walks through building your first Linux kernel with ELMOS on macOS.
Prerequisites
Section titled “Prerequisites”Ensure ELMOS is installed and the workspace initialized.
Step 1: Select Architecture
Section titled “Step 1: Select Architecture”Choose a target architecture (e.g., RISC-V):
./build/elmos arch riscvThis auto-selects the riscv64-unknown-linux-gnu toolchain if installed.
Step 2: Clone Kernel Source
Section titled “Step 2: Clone Kernel Source”Clone the Linux kernel repository:
./build/elmos kernel cloneThis 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.
Step 3: Configure Kernel
Section titled “Step 3: Configure Kernel”Generate a default config:
./build/elmos kernel config defconfigFor custom config, use menuconfig:
./build/elmos kernel config menuconfigStep 4: Build Kernel
Section titled “Step 4: Build Kernel”Build the kernel with the detected toolchain:
./build/elmos kernel buildThis 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.
Step 5: Create RootFS
Section titled “Step 5: Create RootFS”Create the root filesystem:
./build/elmos rootfs createBy 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).
Step 6: Run in QEMU
Section titled “Step 6: Run in QEMU”Boot the kernel in QEMU:
./build/elmos qemu runYou should see the Linux boot process. Login with root (no password).
Step 7: Debug (Optional)
Section titled “Step 7: Debug (Optional)”For debugging, run with GDB stub:
./build/elmos qemu debugConnect GDB in another terminal:
gdb-multiarch build/linux/vmlinux(gdb) target remote :1234Next Steps
Section titled “Next Steps”- Develop modules
- Customize toolchains
- Use the TUI for interactive workflows
Troubleshooting
Section titled “Troubleshooting”If builds fail, check Troubleshooting or run ./build/elmos doctor.