@alswl: Did you know the Linux kernel has a feature introduced in 1997 that allows Apple Silicon Macs to efficiently run x86 containers? It's called binfmt_misc, introduced in Linux 2.1.43, nearly 30 years ago. The principle is extremely simple: Linux...
Summary
This article introduces the binfmt_misc feature introduced in the Linux kernel in 1997. It allows registering rules to hand off binary execution to a specified interpreter. Today, combined with Rosetta on Apple Silicon Macs, it enables efficient x86 container operation, achieving performance close to 70-90% of native.
View Cached Full Text
Cached at: 06/05/26, 03:16 PM
Did you know that the Linux kernel has a feature introduced in 1997 that enables Apple Silicon Macs to efficiently run x86 containers?
It’s called binfmt_misc, introduced in Linux 2.1.43 — nearly 30 years ago.
The principle is extremely simple: When the Linux kernel executes a binary, it first reads the magic number from the file header. If you have registered a rule in /proc/sys/fs/binfmt_misc/ — “for files with this magic, hand them over to a specific interpreter” — the kernel automatically delegates execution to that interpreter. It’s essentially the same mechanism as #!/bin/bash (shebang), but it matches binary file headers instead.
Originally, it was used to let Linux directly “run” Java class files and Windows PE executables. Later, QEMU used this mechanism for user-mode cross-architecture emulation — on ARM Linux, executing an x86 ELF directly, with the kernel automatically invoking qemu-x86_64 to translate.
Then Apple came along. When you launch a Linux VM using Colima / Lima on an Apple Silicon Mac (using macOS’s Virtualization.framework) with rosetta: true enabled, the following happens:
- macOS mounts the Rosetta translator binary into the Linux VM’s
/mnt/lima-rosetta/rosettavia virtio-fs - Inside the VM, a standard
binfmt_miscrule is registered: when encountering x86_64 ELF magic (7f454c46...02003e00), hand it over to/mnt/lima-rosetta/rosetta - From then on, any execution of x86_64 binaries within the VM is automatically handed off to Rosetta for translation by the kernel
This is completely transparent to containers — docker run --platform linux/amd64 nginx: Docker pulls down an x86 image, the processes inside the container are x86 ELF binaries, and the Linux kernel automatically invokes Rosetta via binfmt_misc to translate and execute them. The container itself has no idea what’s happening.
Performance comparison:
- Rosetta approach: approximately 70-90% of native performance (JIT translation, instruction-level optimization)
- QEMU full virtualization approach: only about 10-30% (complete x86 CPU emulation)
A kernel feature designed in 1997 to run Java class files became, in 2024, the critical infrastructure for running x86 containers on Apple Silicon. Sometimes the most enduring architectural decisions are those that are simple and generic enough abstractions.
$ colima ssh
$ cat /proc/sys/fs/binfmt_misc/rosetta
enabled
interpreter /mnt/lima-rosetta/rosetta
flags: OCF
magic 7f454c4602010100000000000000000002003e00
Similar Articles
@geekbb: NTFS read/write on Apple Silicon macOS — no kernel extensions, no SIP disable. It actually runs a libkrun microVM (based on anylinuxfs, with ntfs-3g inside) to handle the actual NTFS writes, then…
ntfsmac is an open-source tool that enables NTFS read/write on Apple Silicon macOS by using a libkrun microVM running ntfs-3g, avoiding kernel extensions and SIP modifications. It provides both CLI and a GUI menu-bar app.
@sitinme: There's a pretty interesting open-source project called Cider, specifically designed to accelerate local AI inference on Macs with Apple Silicon chips. Many people buy a Mac mini or MacBook Pro and want to run models locally, but often encounter issues like insufficient speed and high memory usage. Actually...
Cider is an open-source project designed for Apple Silicon Macs, accelerating local AI inference by fully leveraging the computing power of M-series chips. It is compatible with the MLX ecosystem, supports models like Qwen and Llama, and is easy to install.
elfuse: Run Arm64/x86-64 Linux ELF binaries on macOS Apple Silicon
elfuse is a lightweight, process-scoped runtime that runs Linux ELF binaries natively on macOS Apple Silicon without Docker or full VMs, using Hypervisor.framework and optionally Rosetta for x86_64 translation.
@timsneath: One of my personal favorite features announced at WWDC will I suspect be a sleeper hit: container machines, allowing yo…
Apple has open-sourced 'container', a tool for running Linux containers as lightweight VMs on Apple silicon Macs, supporting OCI images and optimized for macOS 26.
macOS Container Machines
Apple has released 'container', an open-source tool that lets macOS users create and run Linux containers as lightweight virtual machines, optimized for Apple silicon and supporting OCI-compatible images.