AboutBlogContact
DevOps & InfrastructureMarch 10, 2000 2 min read 126Updated: June 22, 2026

NetBSD: Running Everything with COMPAT_LINUX (2000)

AunimedaAunimeda
📋 Table of Contents

NetBSD: Running Everything with COMPAT_LINUX

NetBSD's portability is legendary, but sometimes you just need to run a proprietary Linux binary (looking at you, Netscape). Instead of a slow VM, NetBSD uses kernel-level binary emulation. This isn't emulation in the "slow" sense; it's a high-performance syscall translation layer.

How it Works

When the kernel loads an ELF binary, it checks the brand. If it's a Linux binary, it switches the process to the Linux emulation vector. Every time the process makes a syscall, the kernel redirects it to a translation function.

Enabling Emulation

First, you need COMPAT_LINUX in your kernel config:

options         COMPAT_LINUX
options         EXEC_ELF32

And you need the Linux libraries in /emul/linux.

A Look at the Translation

Inside the kernel source (sys/compat/linux/common/linux_socket.c), you'll see how NetBSD maps Linux socket calls to native ones:

/* Linux socketcall syscall */
int
linux_sys_socketcall(struct proc *p, void *v, register_t *retval)
{
    struct linux_sys_socketcall_args /* {
        syscallarg(int) what;
        syscallarg(void *) args;
    } */ *uap = v;

    switch (SCARG(uap, what)) {
    case LINUX_SYS_SOCKET:
        return linux_sys_socket(p, SCARG(uap, args), retval);
    case LINUX_SYS_BIND:
        return linux_sys_bind(p, SCARG(uap, args), retval);
    /* ... and so on ... */
    }
    return (ENOSYS);
}

The overhead is minimal-just a few extra instructions to swap structure layouts. This is why NetBSD is often a better "Linux" than Linux itself when it comes to stability and flexibility. If it exists, NetBSD runs it.


Aunimeda provides DevOps engineering and infrastructure services - CI/CD pipelines, containerization, cloud deployments, and monitoring setups.

Contact us to discuss your infrastructure needs. See also: DevOps Services, Custom Software Development

Read Also

Kafka: Zero-Copy and Why It's Fast (2015)aunimeda
DevOps & Infrastructure

Kafka: Zero-Copy and Why It's Fast (2015)

How does Kafka push gigabits of data on commodity hardware? The secret isn't in the code; it's in the Linux kernel's sendfile() call.

The 2008 Scaling Crisis: Caching at the Edge with Memcachedaunimeda
DevOps & Infrastructure

The 2008 Scaling Crisis: Caching at the Edge with Memcached

Your database is the bottleneck. In 2008, if you're hitting your MySQL server for every user profile, you're not scaling. It's time to offload the heavy lifting to a distributed memory pool.

Xen: The Magic of Paravirtualization (2005)aunimeda
DevOps & Infrastructure

Xen: The Magic of Paravirtualization (2005)

Full virtualization is for slowpokes. Paravirtualization is how we get near-native performance. Let's look at hypercalls.

Need IT development for your business?

We build websites, mobile apps and AI solutions. Free consultation.

DevOps Services

Get Consultation All articles