Published BSDun, Module For Running FreeBSD Executables On Linux

The project BSDun has been published, a developing module for the Linux kernel that allows you to recognize, load and run unmodified executable files in ELF format, compiled for FreeBSD, on Linux. To launch, an emulated FreeBSD environment is used, located in the /compat/freebsd directory. In general, the project is the complete opposite of FreeBSD Linuxulator. The code is distributed under the GPLv2+ license and written using the Claude Code AI assistant.

With the help of BSDun, we were able to successfully run many applications from the FreeBSD packages on Linux, including pkg, nginx, mc, ping, xeyes, xfce4-panel, Thunar, xfce4-terminal, Libreoffice, Midori, Epiphany, Chromium and VScode. To run Chromium and VScode, you need to disable sandbox isolation and limit the size of video memory using the options “–no-sandbox –force-gpu-mem-available-mb=1024”.

The module does not apply for inclusion in the main kernel, since since the removal of the Solaris ABI, the Linux kernel architecture does not allow the inclusion of other executable file handlers (OS Personalities) and provides for the presence of only one system call table. To get around this problem, BSDun used the kprobe mechanism to intercept all system calls.

With kprobe, FreeBSD system calls were separated from Linux system calls and wrapped in a separate table. Some of the FreeBSD system calls were tied directly to Linux system calls, others were repackaged with parameter and result structures, others were replaced with stubs (such as those associated with Capcicum), and a fourth were implemented based on internal Linux kernel structures.
To implement the kevent/kqueue mechanism on top of epoll(), a modification of user space components was applied separately, which is automatically carried out when loading each FreeBSD executable file.

In total, about 250 system calls were implemented. Also implemented are SystemV IPC, network functions, futex, sysctl MIB, prctl, timers and ioctl. To differentiate file systems, a chroot environment was used on the Linux side (during experiments without chroot, the author overwrote the contents of /usr/local/* in Linux by running “pkg install …”). However, some utilities can still work without chroot.

The proposed module can be used to develop, build and port software for FreeBSD without using virtual machines. Brief instructions for use:

/Reports, release notes, official announcements.