Are different Linux/Unix kernels interchangeable?

No, kernels from different implementations of Unix-style operating systems are not interchangeable, notably because they all present different interfaces to the rest of the system (user space) — their system calls (including ioctl specifics), the various virtual file systems they use...

What is interchangeable to some extent, at the source level, is the combination of the kernel and the C library, or rather, the user-level APIs that the kernel and libraries expose (essentially, the view at the layer described by POSIX, without considering whether it is actually POSIX). Examples of this include Debian GNU/kFreeBSD, which builds a Debian system on top of a FreeBSD kernel, and Debian GNU/Hurd, which builds a Debian system on top of the Hurd.

This isn’t quite at the level of kernel interchangeability, but there have been attempts to standardise a common application binary interface, to allow binaries to be used on various systems without needing recompilation. One example is the Intel Binary Compatibility Standard, which allows binaries conforming to it to run on any Unix system implementing it, including older versions of Linux with the iBCS 2 layer. I used this in the late 90s to run WordPerfect on Linux.

See also How to build a FreeBSD chroot inside of Linux.


Some kernels have binary compatibility allowing you to mix userspace programs with different ABIs (eg freebsd can work with linux binaries to a degree) - however, the core binaries (eg the init program, the module loader, device driver setup tools, the C library, the tools needed to setup the filesystems... ) will in practice have too much need-to-know about kernel level interfaces to boot a system with a foreign kernel successfully.

Also, filesystems would need to be compatible. Also, binary compatibility options would need to be compiled "hard" into the kernel - anything implemented as a kernel module would like fail because you could not run the module loader.

As mentioned, the user environments tend to be somewhat portable if you are willing to recompile - like freebsd-based debian systems, or setting up the netbsd pkgsrc system on linux (absolutely non trivial, but supported and possible!).