How to Install Linux Binary Compatibility on FreeBSD

Linux binary compatibility, often referred to as Linuxulator, is a mechanism for running unmodified Linux binaries under the FreeBSD system. Linuxulator does not involve virtual machines or emulators. But in contrast, Linuxulator provides binaries with kernel interfaces identical to those provided by the original Linux kernel. It is technically similar to the way 32-bit FreeBSD binaries run on top of a 64-bit FreeBSD kernel.

The FreeBSD system provides Linux binary compatibility. The presence of Linux binaries will make it easier for users to install and run unmodified Linux binaries. It is available for x86 (32 and 64 bit) and AArch64 architectures. Some Linux-specific operating system features are not yet fully supported. This is because it mostly occurs with functionality specific to the hardware or related to system management, such as cgroups or namespaces.

The operation of Linux binaries on FreeBSD began in 1995. The application utilizes the Linux executable format and provides a special Linux system call table. Early Linux binaries were used to play the video game, Doom. Gradually, many Linux applications and libraries were packaged and made available through the FreeBSD Ports Collection. But because FreeBSD tools do not understand Linux package dependencies, this process is time consuming and manually configured.

This article will describe and explain how to configure and install Linux binaries on FreeBSD. Writing this article to do the above using a computer that has the FreeBSD 13.2 system installed.


1. Linux Binary Installation

The Linux binary installation process on FreeBSD should use the system ports provided. Follow these steps to install the Linux binary package on FreeBSD.

root@ns1:~ # cd /usr/ports/emulators/linux_base-c7
root@ns1:/usr/ports/emulators/linux_base-c7 #
make install clean

After the installation process is complete, a configuration command will appear from the program developer. It looks like below.

====> Compressing man pages (compress-man)
===> Installing for linux_base-c7-7.9.2009_1
===> Checking if linux_base-c7 is already installed
===> Registering installation for linux_base-c7-7.9.2009_1
Installing linux_base-c7-7.9.2009_1...
Some programs need linprocfs mounted on /compat/linux/proc. Add the
following line to
/etc/fstab:

linprocfs /compat/linux/proc linprocfs rw 0 0

Then run "mount /compat/linux/proc".

Some programs need linsysfs mounted on /compat/linux/sys. Add the
following line to
/etc/fstab:

linsysfs /compat/linux/sys linsysfs rw 0 0

Then run "mount /compat/linux/sys".


Some programs need tmpfs mounted on /compat/linux/dev/shm. Add the
following line to
/etc/fstab:

tmpfs /compat/linux/dev/shm tmpfs rw,mode=1777 0 0

Then run "mount /compat/linux/dev/shm".


===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/compat/linux/usr/bin/gawk
/compat/linux/usr/lib64/libdb-4.7.so
/compat/linux/usr/lib/libgio-2.0.so.0.5600.1
/compat/linux/usr/lib64/libdb_cxx-4.7.so
/compat/linux/usr/lib/libresolv-2.17.so
/compat/linux/usr/lib/libgssrpc.so.4.2
/compat/linux/usr/lib/libdb-5.3.so
/compat/linux/usr/lib/libcrypto.so.1.0.2k
/compat/linux/usr/lib64/libgio-2.0.so.0.5600.1
/compat/linux/usr/lib/libdb-4.7.so
/compat/linux/usr/lib64/libselinux.so.1
/compat/linux/usr/libexec/gam_server
/compat/linux/usr/lib64/libgssrpc.so.4.2
/compat/linux/usr/lib64/libcrypto.so.1.0.2k
/compat/linux/usr/lib/libselinux.so.1
/compat/linux/usr/lib64/libresolv-2.17.so
/compat/linux/usr/bin/dgawk
/compat/linux/usr/lib/libdb_cxx-4.7.so
/compat/linux/usr/lib64/libdb-5.3.so
/compat/linux/usr/bin/pgawk

If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.
===> Cleaning for linux_base-c7-7.9.2009_1


In this article I have given color to the display above, meaning we have to do the colored writing first. OK, using the reference above, let's start configuring the Linux binary. We open the /etc/fstab file and edit its contents by entering the script above in the /etc/fstab file. To make it easier, use the "ee" editor to enter the script above.

root@ns1:~ # ee /etc/fstab
linprocfs /compat/linux/proc linprocfs rw 0 0
linsysfs /compat/linux/sys linsysfs rw 0 0
tmpfs /compat/linux/dev/shm tmpfs rw,mode=1777 0 0
devfs /compat/linux/dev devfs rw,late 0 0
fdescfs /compat/linux/dev/fd fdescfs rw,late,linrdlnk 0 0

The next step is to create a /compat/linux folder according to the script above.

root@ns1:~ # mkdir -p /compat/linux/dev/shm
root@ns1:~ #
mkdir -p /compat/linux/proc
root@ns1:~ #
mkdir -p /compat/linux/sys
root@ns1:~ #
mkdir -p /compat/linux/dev/fd

Next, use the "mount" command to activate the script above.

root@ns1:~ # mount /compat/linux/proc
root@ns1:~ #
mount /compat/linux/sys
root@ns1:~ #
mount /compat/linux/dev/shm
root@ns1:~ #
mount /compat/linux/dev/fd

After the Linux binary has been successfully mounted, continue by creating a ZFS dataset for the Linux binary file.

root@ns1:~ # zfs create -o compression=on -o mountpoint=/compat zroot/compat
root@ns1:~ #
zfs snapshot -r zroot/compat@2022-04-22

The script above will create a ZFS file system in the /compat folder. The next step is to install linux-sublime-text4. Follow the steps below to install linux-sublime-text4.

root@ns1:~ # cd /usr/ports/editors/linux-sublime-text4
root@ns1:/usr/ports/editors/linux-sublime-text4 #
make install clean



2. Enable Linux Binary

Even though we have installed the Linux binary package, it cannot be activated yet. OK, now we will activate the Linux binary package on the FreeBSD system. Open and edit the /boot/loader.conf file then enter the following script.

root@ns1:~ # ee /boot/loader.conf
zfs_load="YES"

linux_load="YES"
linux64_load="YES"
fdescfs_load="YES"
linprocfs_load="YES"
tmpfs_load="YES"
linsysfs_load="YES"

The script above will read the Linux kernel and ZFS file system when the computer is turned off or restarted. After that, we create the rc.d startup script in the /etc/rc.conf file.

root@ns1:~ # ee /etc/rc.conf
zfs_enable="YES"
kld_list="linux linux64 cuse fusefs /boot/modules/i915kms.ko"
linux_enable="YES"

After the rc.d startup script has been successfully created, now you restart/reboot the computer.

root@ns1:~ # reboot

Wait until the computer turns back on normally. After the computer is active, at this point the Linux binary installation and configuration has been completed. You can use this Linux binary package to install Ubuntu, Debian and even VGA Card drivers.
Iwan Setiawan

I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

Post a Comment

Previous Post Next Post