# Keep apps and libs requiring linux compatibilty contained or off system



## decuser (Jun 19, 2021)

Is there a way to turn off linux compatibility and/or isolate anything using it? Should I care?


----------



## monwarez (Jun 19, 2021)

Doing nothing will simply disable linux compatibility since by default


```
linux_enable="NO"
```
And you will most likely need to install emulators/linux_base-c7
Also if you does not want linux compatibility, just does not install linux packages.


----------



## decuser (Jun 19, 2021)

monwarez said:


> Well, by default
> 
> ```
> linux_enable="NO"
> ...


Huh... well, that was easy. I'm a little confused though, cuz I thought drm-fbsd13-kmod was a linux thing... How is this not linux compatibility?


----------



## Jose (Jun 19, 2021)

Keep in mind that x11/nvidia-driver is built with Linux compatibility by default.

Edit: this is not meant to answer your question about drm-fbsd13-kmod. Our posts crossed in midair.


----------



## fbsd_ (Jun 19, 2021)

decuser said:


> Is there a way to turn off linux compatibility and/or isolate anything using it? Should I care?


It can make your computer faster because a kernel module will be loaded and working on the system when its on. There is multiple ways exist to disable it.
*Disable temporarly:
kldunload linux.so linux64.so
*Disable all the time:
1)Go to rc.conf in /etc/rc.conf
2)Change linux_enable="YES" to -> linux_enable="NO"
3)Reboot required to apply changes

You can take a look at which modules loaded by writing:
kldstat
If you see any Linux module just disable it by using kldunload but they can load again on next reboot so check rc.conf and loader.conf

You can also remove linux compatibility package by writing:
"pkg remove emulators/linux_base-c7"

More information about Linux Binary Compatibility:








						Chapter 11. Linux Binary Compatibility
					

FreeBSD provides binary compatibility with Linux, allowing users to install and run most Linux binaries on a FreeBSD system without having to first modify the binary




					docs.freebsd.org


----------



## Jose (Jun 19, 2021)

decuser said:


> Huh... well, that was easy. I'm a little confused though, cuz I thought drm-fbsd13-kmod was a linux thing... How is this not linux compatibility?


It is Linux compatibility of a sort. The Freebsd KMS-DRM wiki says: 





> These folders contain source code from Linux, patched (minimally) to run on FreeBSD with LinuxKPI.



So it is Linux source compiled to run in the Freebsd kernel. Contrast with unmodified Linux binaries running in userland. The latter is what is usually being described when one talks about "linux compatibility."


----------



## kpedersen (Jun 19, 2021)

I believe it is kind of similar to how we had an opensolaris.ko to provide some necessary plumbing for ZFS.


----------



## monwarez (Jun 19, 2021)

If you had to recompile the code, I will not call it linux compatibility, it is just increase of portability of the code. Else we may as well call all program that use systemd that was patched to work without it to be a linux compatibility thing. And finally, all program that was first build on linux, and then ported to FreeBSD called linux compatibility.

The big difference for me is: Does the ABI (extend it to kernel too) change or not ? In case of LinuxKPI, since FreeBSD does not have the same calling convention, and also use clang instead of gcc, we are sure that the ABI between the drm-kmod driver from linux, differ with the one from FreeBSD.


----------



## Alain De Vos (Jun 19, 2021)

Run once,

```
kldstat | grep -i linux
```
I you see nothing ,you cannot run linux programs.
Otherwise, kldunload ...


----------



## mtu (Jun 20, 2021)

kpedersen said:


> I believe it is kind of similar to how we had an opensolaris.ko to provide some necessary plumbing for ZFS.


Huh, I never knew. Has it gone with 13.0, or is it still around?


----------



## mer (Jun 20, 2021)

```
freebsd-version 
13.0-RELEASE-p2

kldstat
Id Refs Address                Size Name
 1   80 0xffffffff80200000  1f11ef8 kernel
 2    1 0xffffffff82112000     bdf8 cuse.ko
 3    1 0xffffffff8211e000   67feb0 zfs.ko
 4    1 0xffffffff8279e000     b7b8 opensolaris.ko   <<<<<<<  Still here
 5    1 0xffffffff82920000   158458 i915kms.ko
 6    1 0xffffffff82a79000    7f4c8 drm.ko
 7    2 0xffffffff82af9000     cbc8 linuxkpi_gplv2.ko
 8    2 0xffffffff82b06000     2328 lindebugfs.ko
 9    1 0xffffffff82b09000     20f0 coretemp.ko
10    1 0xffffffff82b0c000     3250 ichsmb.ko
11    1 0xffffffff82b10000     2180 smbus.ko
12    1 0xffffffff82b13000    17310 if_iwm.ko
13    1 0xffffffff82b2b000   1023d8 iwm7260fw.ko
14    1 0xffffffff82c2e000     e538 snd_uaudio.ko
15    1 0xffffffff82c3d000     2340 uhid.ko
16    1 0xffffffff82c40000     3380 usbhid.ko
17    1 0xffffffff82c44000     31f8 hidbus.ko
18    1 0xffffffff82c48000     3320 wmt.ko
19    1 0xffffffff82c4c000     4350 ums.ko
20    1 0xffffffff82c51000    27040 ipfw.ko
```


----------



## zirias@ (Jun 20, 2021)

decuser said:


> I thought drm-fbsd13-kmod was a linux thing... How is this not linux compatibility?


The DRM drivers are taken from Linux with "minor" changes and come with "linuxkpi", which is a Linux compatibility layer _inside_ the kernel. This layer is pretty imcomplete, just enough to run the slightly changed Linux DRM drivers.

It has nothing to do with the "Linuxulator", which is _user-space_ Linux compatibility. The kernel modules (linux.ko and linux64.ko) implement Linux syscalls, so Linux applications can run. "linuxkpi" does nothing like that, it isn't "visible" from user-space.

Comparison in a nutshell:



*Linuxulator**linuxkpi*_purpose_applicationskernel modules_compatibility_binarysource (recompile necessary)_completeness_almost completepartial


----------



## bsduck (Jun 20, 2021)

mtu said:


> Huh, I never knew. Has it gone with 13.0, or is it still around?


It's still available, but not required by ZFS anymore since the switch to OpenZFS.


----------



## kpedersen (Jun 20, 2021)

mtu said:


> Huh, I never knew. Has it gone with 13.0, or is it still around?


Hmm I am not actually sure if OpenZFS has changed this. I don't have a 13.0 on me right now to test.
Most recent bug ticket relating to it is 2019: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240478

Edit: Ah just noticed bsduck already found the answer.


----------



## mer (Jun 20, 2021)

As I posted a couple, kldstat on a 13.0-RELEASE-p2 system, opensolaris.ko is getting loaded from somewhere for some reason.


----------



## decuser (Jun 20, 2021)

mer said:


> As I posted a couple, kldstat on a 13.0-RELEASE-p2 system, opensolaris.ko is getting loaded from somewhere for some reason.


freebsd-version
13.0-RELEASE-p2

1   47 0xffffffff80200000  1f11ef8 kernel
2    1 0xffffffff82113000   67feb0 zfs.ko
3    1 0xffffffff82793000     ae38 cryptodev.ko
4    1 0xffffffff82ae5000     3530 fdescfs.ko
5    1 0xffffffff82ae9000     3378 acpi_wmi.ko
6    1 0xffffffff82aed000     3250 ichsmb.ko
7    1 0xffffffff82af1000     2180 smbus.ko
8    1 0xffffffff82af4000   158458 i915kms.ko
9    1 0xffffffff82c4d000    7f4c8 drm.ko
10    2 0xffffffff82ccd000     cbc8 linuxkpi_gplv2.ko
11    2 0xffffffff82cda000     2328 lindebugfs.ko
12    1 0xffffffff82cdd000     2a08 mac_ntpd.ko

This is my T-430 w/zfs on root and all.. Do you think it's a setting in your loader.conf. This is a fresh install on metal... No opensolaris.ko...


----------



## Alain De Vos (Jun 20, 2021)

Kldstat, mine is a bit more,

```
Id Refs Address                Size Name
 1  259 0xffffffff80200000  1229928 kernel
 2    1 0xffffffff8142a000     bb00 opensolaris.ko
 3    1 0xffffffff81436000     3988 cc_cubic.ko
 4    1 0xffffffff8143a000   682290 zfs.ko
 5    2 0xffffffff81abd000     6110 xdr.ko
 6    1 0xffffffff81d20000     c940 geom_eli.ko
 7    1 0xffffffff81d2d000     3530 fdescfs.ko
 8    1 0xffffffff81d31000     3250 ichsmb.ko
 9    2 0xffffffff81d35000     2180 smbus.ko
10    1 0xffffffff81d38000     3238 filemon.ko
11    1 0xffffffff81e00000   53a420 vmm.ko
12    3 0xffffffff81d3c000    824c8 drm.ko
13    3 0xffffffff81dbf000     cbc8 linuxkpi_gplv2.ko
14    1 0xffffffff81dcc000     2328 lindebugfs.ko
15    1 0xffffffff8233b000   14dc70 radeonkms.ko
16    1 0xffffffff81dcf000     e778 ttm.ko
17    1 0xffffffff81dde000     3258 radeon_CAICOS_pfp_bin.ko
18    1 0xffffffff81de2000     3658 radeon_CAICOS_me_bin.ko
19    1 0xffffffff81de6000     2cd8 radeon_BTC_rlc_bin.ko
20    1 0xffffffff81de9000     7ef8 radeon_CAICOS_mc_bin.ko
21    1 0xffffffff81df1000     8098 radeon_CAICOS_smc_bin.ko
22    1 0xffffffff82489000    341f0 radeon_SUMO_uvd_bin.ko
23    1 0xffffffff81dfa000     4350 acpi_video.ko
24    1 0xffffffff824be000     25d8 snd_driver.ko
25    1 0xffffffff824c1000     42d8 snd_ad1816.ko
26    1 0xffffffff824c6000     3240 snd_als4000.ko
27    1 0xffffffff824ca000     4228 snd_atiixp.ko
28    1 0xffffffff824cf000     3240 snd_cmi.ko
29    1 0xffffffff824d3000     4230 snd_cs4281.ko
30    2 0xffffffff824d8000    13078 snd_csa.ko
31    1 0xffffffff824ec000     a3e0 snd_ds1.ko
32    1 0xffffffff824f7000    14f50 snd_emu10kx.ko
33    1 0xffffffff8250c000     64c0 snd_envy24.ko
34    3 0xffffffff82513000     2100 snd_spicds.ko
35    1 0xffffffff82516000     56a0 snd_envy24ht.ko
36    1 0xffffffff8251c000     7260 snd_es137x.ko
37    1 0xffffffff82524000     4488 snd_ess.ko
38    4 0xffffffff82529000     33f8 snd_sbc.ko
39    1 0xffffffff8252d000     2270 snd_fm801.ko
40    2 0xffffffff82530000     8c50 snd_mss.ko
41    1 0xffffffff82539000     6428 snd_maestro.ko
42    1 0xffffffff82540000     7d20 snd_maestro3.ko
43    1 0xffffffff82548000     f210 snd_neomagic.ko
44    1 0xffffffff82558000     3288 snd_sb16.ko
45    1 0xffffffff8255c000     32e0 snd_sb8.ko
46    1 0xffffffff82560000     4270 snd_solo.ko
47    1 0xffffffff82565000     3290 snd_t4dwave.ko
48    1 0xffffffff82569000     5290 snd_via8233.ko
49    1 0xffffffff8256f000     3230 snd_via82c686.ko
50    1 0xffffffff82573000     4240 snd_vibes.ko
51    1 0xffffffff82578000     2220 cpuctl.ko
52    1 0xffffffff8257b000     20f0 coretemp.ko
53    1 0xffffffff8257e000    1262c hwpmc.ko
54    1 0xffffffff82591000     8a38 ipmi.ko
55    1 0xffffffff8259a000     36c8 sem.ko
56    1 0xffffffff8259e000     b3a8 usb_template.ko
57    1 0xffffffff825aa000     23c0 ulpt.ko
58    1 0xffffffff825ad000     3460 umodem.ko
59    2 0xffffffff825b1000     4d90 ucom.ko
60    1 0xffffffff825b6000     33c0 uslcom.ko
61    1 0xffffffff825ba000     21cc nmdm.ko
62    1 0xffffffff825bd000     22b0 iic.ko
63    1 0xffffffff825c0000     433c iicbus.ko
64    1 0xffffffff825c5000     3d08 ow.ko
65    1 0xffffffff825c9000    11f10 fusefs.ko
66    1 0xffffffff825db000     5a00 udf.ko
67    1 0xffffffff825e1000     2340 uhid.ko
68    1 0xffffffff825e4000     4350 ums.ko
69    3 0xffffffff825e9000     4798 libiconv.ko
70    1 0xffffffff825ee000     3090 libmchain.ko
71    1 0xffffffff825f2000     2138 cd9660_iconv.ko
72    1 0xffffffff825f5000     2138 msdosfs_iconv.ko
73    1 0xffffffff825f8000     2ac0 sysctlinfo.ko
74    4 0xffffffff825fb000     aac8 netgraph.ko
75    1 0xffffffff82606000     31c8 ng_ether.ko
76    1 0xffffffff8260a000     51e8 ng_pppoe.ko
77    1 0xffffffff82610000     3980 ng_socket.ko
78    1 0xffffffff82614000     7638 if_bridge.ko
79    1 0xffffffff8261c000     50d8 bridgestp.ko
80    1 0xffffffff82622000     4700 nullfs.ko
81    1 0xffffffff82627000    27040 ipfw.ko
```


----------



## decuser (Jun 20, 2021)

I'd have module envy, but wtf are you running on - alienware?


----------



## kpedersen (Jun 20, 2021)

Alain De Vos said:


> Kldstat, mine is a bit more,


I am guessing that you are kldloading snd_driver? You should only do this to find out which audio chip you use. After that, then really just load the module you need. snd_driver is like a meta driver which pulls in them all.


----------

