jails Can the Linux emulation mechanism written for FreeBSD supports different layers than the Ubuntu one ?

Hello.

I've thought to try all the systemd free Linux distros below inside the jail because I want to find the most compatible one. Do you think that I will have some success ? I've read that the linux emulation written for FreeBSD is compatible only with the ubuntu layer. So,what will happens if I try to install a non Ubuntu layered distro like some of the listed below distros ?

1) Alpine
2) Artix
3) Crux
4) Guix
5) Slackware
6) Void

thanks.
 
Last edited:
Utter nonsense, the "official" userland is Centos. It doesn't really matter, all the "linuxulator" does is implement Linux syscalls and provide some filesystem "overlay".
I experienced, this compatibility with Linux, and I must say it is horrible. I prefer to use pure FreeBSD
 
As Zirias indicates above "only compatible with Ubuntu" is a nonsense.

The Linux kernel is a strictly controlled entity, curated by Linus Torvalds.

Pretty much all of the variability in Linux distributions derives from custom software (i.e. applications and shared libraries) added on top of the (common) Linux kernel by the various distributions.

The FreeBSD Linuxulator provides shims to emulate (as many as possible) system calls available in the Linux kernel. The aim is to allow Linux binaries to run on a FreeBSD kernel. But there is no guarantee because in addition to system calls, binaries can rely on other services. These include things like:
  • Linux specific virtual file systems, e.g. /proc;
  • other applications running in the user (non-kernel) space, e.g. systemd.
These can add a whole extra layer of effort to the effort required to port an application.

To illustrate what's possible, with concerted effort, have a look at Debian's (now defunct) GNU/kFreeBSD which is Debian packages running on top of a FreeBSD kernel.

The Linux "flavour" presented by FreeBSD applications using the Linuxulator depends on which Linux applications and shared libraries have been ported.
 
So,its ok,it makes sense to try them all with the goal to find the better one,since each of that distros uses different shared libraries and ported applications,but every distro does not use systemd (and some of them uses a different init system),because it creates troubles. Let's see what happens. I'm curious. The most interesting one is CRUX for sure. It seems that it shares some mechanisms with BSD :

CRUX is a lightweight Linux distribution for the x86-64 architecture targeted at experienced Linux users. The primary focus of this distribution is keep it simple, which is reflected in a straightforward tar.gz-based package system, BSD-style initscripts, and a relatively small collection of trimmed packages. The secondary focus is utilization of new Linux features and recent tools and libraries. CRUX also has a ports system which makes it easy to install and upgrade applications.

Also Void seems to be good :

I guess that the most linuxish BSD bistro is either the BSD spin of Debian or PacBSD which is Archlinux on top of the BSD kernel.
The most BSDish Linux distro I know is Void, which focuses on adopting many security features from BSD distros while using the Linux kernel.
 
Your subject is tagged "jails".

Your subject line mentions "Linux emulation mechanism".

The text of you post mentions "trying Linux distros".

There seems to be some confusion there.

You can run any Linux distro inside a virtual machine hypervisor like bhyve.

You can run some Linux binaries on a native FreeBSD system using the FreeBSD Linuxulator.

shkhln indicated that the Linuxulator packages are Centos derived.

You need to tell us what you want to achieve.

 
I meant Linux JAIL,but I didn't find this specific label,so I have chosen the closest one. What confusion are u talking about ? The Linux emulation mechanism is used inside a Linux JAIL. The Linux distros that I've talked about could be installed inside a Linux JAIL ? What's the most compatible one ? This is the question that I'm asking. I think that a new label "Linux JAIL" could be added between the list,to distinguish a FreeBSD JAIL from a Linux JAIL (https://wiki.freebsd.org/LinuxJails).
 
A Linux jail is different from what "Linuxulator" is doing (a filesystem overlay, standard path /compat/linux), just to start with.

The default userland for Linuxulator (from ports/packages) is CentOS, still you can use anything else if you want. You can also install a Linux userland in a jail, but that's a very different thing (of course using the same Linux-compatible syscalls offered by FreeBSD kernel).
 
How about PacBSD ? It seems a good hybrid between Linux and FreeBSD. Can be an advantage to use a so much BSD oriented Linux distro inside the jail to reach a good emulation compatibility ? ( I mean,like it was a physical installation of Linux,that can run a large number of applications,maybe even GUI / networked applications)
 
Just, why? What are you trying to achieve?

First, most important, question: Do you want
  • a jailed Linux userland or
  • running Linux apps directly on your FreeBSD system

edit: just to get that straight for once:
  • If you want a "real" Linux system, go with bhyve (or any other full virtualization solution), running the whole system, including Linux kernel itself, virtualized.
  • If you want to just run Linux apps on your system, "Linuxulator" is the way to go, and ports/packages provide a userland from CentOS for that. If, for some reason, this doesn't work, you can install your own userland, typically in a different directory (like /compat/ubuntu) and point Linuxulator there setting the sysctl compat.linux.emul_path.
  • A Linux jail would be kind of "middle grounds", installing a jailed Linux userland that still uses the FreeBSD kernel, IOW "userspace virtualization".
 
It depends how much difficult is to reach those goals. I'm not a programmer and I don't want to become it. I presume that "running Linux apps directly on your FreeBSD system" implies that I should have a deeper knowledge of how the low levels components of FreeBSD are working,right ? Maybe one day I will try,but today I want only limit myself to testing and configuring the various components in a generic / abstract way. So,I think that I choose the number 1 : "a jailed Linux userland". I don't want to virtualize anything with bhyve as a primary goal at the moment. I'm intrigued by the Linuxulator and jails.

---> point Linuxulator there setting the sysctl compat.linux.emul_path.

I'm not sure that it works right now. I've already set this variable on the file /etc/sysctl.conf,but it has been ignored.
 
Well, whether you use Linuxulator or a jail, the answer is still use any userland you like. They will all work, and they will all have the same limitations (e.g. it isn't possible to configure FreeBSD network interfaces using Linux tools. If you're trying to setup a VNET jail, the workaround is to copy some FreeBSD tools from /rescue, like e.g. ifconfig, inside the linux jail).
 
So,I presume that,changing linux distro,I will not be able to fix the bug below. (I suspect that it is a linuxulator bug) :

Code:
@marietto:/# /opt/google/chrome/chrome --no-sandbox


[7772:7772:0219/230348.496603:ERROR:directory_reader_posix.cc(42)] opendir /proc/self/fd: No such file or directory (2)


[0219/230348.497778:ERROR:directory_reader_posix.cc(42)] opendir /proc/self/fd: No such file or directory (2)
[7770:7770:0219/230352.438133:ERROR:browser_dm_token_storage_linux.cc(94)] Error: /etc/machine-id contains 0 characters (32 were expected).
[7770:101916:0219/230354.585387:ERROR:file_path_watcher_linux.cc(321)] inotify_init() failed: Function not implemented (38)
[0219/230355.532994:ERROR:ptracer.cc(476)] Unexpected registers size 0 != 216, 68
[0219/230355.533248:ERROR:proc_task_reader.cc(45)] format error
Trace/breakpoint trap (core dumped)
 
Looks like you didn't mount linprocfs(5). Linuxulator init-scripts do that automatically (with linux_mounts_enable=YES in /etc/rc.conf), if you're setting up a jail, it's your job to do so...

edit: and no, it doesn't matter which userland you install for that. Procfs is provided by the Linux kernel on a "real" Linux system, FreeBSD's procfs isn't compatible and linprocfs(5) is the emulation FreeBSD provides.

Typical setup when using Linuxulator:
Code:
$ mount | grep proc
procfs on /proc (procfs, local)
linprocfs on /compat/linux/proc (linprocfs, local)
With that, /compat/linux/proc will shadow /proc when running a Linux executable, so it will find there what it expects.
 
Code:
added linux_mounts_enable="YES" to /etc/rc.conf

@marietto:/usr/home/marietto # chroot /compat/devuan /bin/bash

@marietto:/# mount | grep proc
mount: failed to read mtab: No such file or directory

@marietto:/# mount -t linprocfs none /proc               

@marietto:/# mount | grep proc         
proc on /proc type proc (rw)
proc on /compat/devuan/proc type proc (rw)

@marietto:/# /opt/google/chrome/chrome --no-sandbox

[11254:11254:0220/143057.005436:ERROR:directory_reader_posix.cc(42)] opendir /proc/self/fd: No suchfile or directory (2)
[0220/143057.095335:ERROR:directory_reader_posix.cc(42)] opendir /proc/self/fd: No such file or directory (2)
[11252:11252:0220/143102.530396:ERROR:browser_dm_token_storage_linux.cc(94)] Error: /etc/machine-id contains 0 characters (32 were expected).
[11252:107224:0220/143103.477647:ERROR:file_path_watcher_linux.cc(321)] inotify_init() failed: Function not implemented (38)
[0220/143104.516907:ERROR:ptracer.cc(476)] Unexpected registers size 0 != 216, 68
[0220/143104.517192:ERROR:proc_task_reader.cc(45)] format error
Trace/breakpoint trap (core dumped)
 
Code:
@marietto:/# mount -t linsysfs none /sys
@marietto:/# mount -t tmpfs none /tmp             
@marietto:/# mount

/dev/ada2p2 on / type ufs (rw)
devfs on /dev type devfs (rw)
/dev/ada2p1 on /boot/efi type vfat (rw)
proc on /proc type proc (rw)
/sys on /sys type sysfs (rw)
devfs on /dev type devfs (rw)
fdescfs on /dev/fd type fdescfs (rw)
tmpfs on /dev/shm type tmpfs (rw)
proc on /compat/devuan/proc type proc (rw)
/sys on /compat/devuan/sys type sysfs (rw)
tmpfs on /compat/devuan/tmp type tmpfs (rw)


@marietto:/# /opt/google/chrome/chrome --no-sandbox
    
[11388:11388:0220/143729.077256:ERROR:directory_reader_posix.cc(42)] opendir /proc/self/fd: No such file or directory (2)
[0220/143729.078654:ERROR:directory_reader_posix.cc(42)] opendir /proc/self/fd: No such file or directory (2)
[11386:11386:0220/143729.876069:ERROR:browser_dm_token_storage_linux.cc(94)] Error: /etc/machine-id contains 0 characters (32 were expected).
[11386:107425:0220/143729.937505:ERROR:file_path_watcher_linux.cc(321)] inotify_init() failed: Function not implemented (38)
[0220/143730.005897:ERROR:ptracer.cc(476)] Unexpected registers size 0 != 216, 68
[0220/143730.005960:ERROR:proc_task_reader.cc(45)] format error
Trace/breakpoint trap (core dumped)
 
instead,this is what happens if I invoke chrome outside of the jail :

Code:
@marietto:/usr/home/marietto # /compat/devuan/bin/chrome

[11434:107526:0220/143945.490331:ERROR:file_path_watcher_linux.cc(321)] inotify_init() failed: Function not implemented (38)

(chrome:11434): Gtk-WARNING **: 14:39:47.345: Unknown key gtk-applications-prefer-dark-theme in /root/.config/gtk-3.0/settings.ini
Gtk-Message: 14:39:47.767: Failed to load module "colorreload-gtk-module"
Gtk-Message: 14:39:47.767: Failed to load module "window-decorations-gtk-module"
[11434:107535:0220/143948.347298:ERROR:bus.cc(397)] Failed to connect to the bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
[11434:107535:0220/143948.362326:ERROR:bus.cc(397)] Failed to connect to the bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
[11434:107527:0220/143949.186694:ERROR:address_tracker_linux.cc(196)] Could not create NETLINK socket: Address family not supported by protocol (97)
[11434:107534:0220/143949.203095:ERROR:bus.cc(397)] Failed to connect to the bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
[11434:107534:0220/143949.203420:ERROR:bus.cc(397)] Failed to connect to the bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
[11434:107528:0220/143950.073326:ERROR:udev_watcher.cc(52)] Failed to initialize a udev monitor.
[11441:107543:0220/143950.443407:ERROR:address_tracker_linux.cc(196)] Could not create NETLINK socket: Address family not supported by protocol (97)
[11441:107545:0220/143950.443420:ERROR:file_path_watcher_linux.cc(321)] inotify_init() failed: Function not implemented (38)
[11434:11434:0220/143950.588943:ERROR:process_singleton_posix.cc(1100)] Failed to bind() /tmp/.com.google.Chrome.sUj5jO/SingletonSocket: No such file or directory (2)
[11434:11434:0220/143950.640279:ERROR:chrome_browser_main.cc(1305)] Failed to create a ProcessSingleton for your profile directory. This means that running multiple instances would start multiple browser processes rather than opening a new window in the existing process. Aborting now to avoid profile corruption.
 
you guys have already entered into another binary emulation issue, so I need emulation, where you have the source code available, and compile, whatever you want. I've used Crux and Slackware. I don't want to use Debian, with an emulation on my BSD, I no longer like systemd.
 
you guys have already entered into another binary emulation issue, so I need emulation, where you have the source code available, and compile, whatever you want. I've used Crux and Slackware. I don't want to use Debian, with an emulation on my BSD, I no longer like systemd.

Are Crux and Slackware working correctly with the Linuxulator ? Are u able to make a tutorial about how u have configured everything ? :D
 
Trying to run a web browser as root is the dumbest thing one can do. Your resistance to learn from our advices makes it very difficult for us to give serious answers to your questions.

Code:
marietto@marietto:~ $ /compat/linux/bin/chrome

[12717:108862:0220/160436.018253:ERROR:file_path_watcher_linux.cc(321)] inotify_init() failed: Function not implemented (38)
[0220/160436.082801:ERRORtracer.cc(476)] Unexpected registers size 0 != 216, 68
[0220/160436.090122:ERRORroc_task_reader.cc(45)] format error
Trace/BPT trap (core dumped)

marietto@marietto:~ $ /compat/devuan/bin/chrome     
[12739:108883:0220/160554.217160:ERROR:file_path_watcher_linux.cc(321)] inotify_init() failed: Function not implemented (38)
[0220/160554.219797:ERROR:ptracer.cc(476)] Unexpected registers size 0 != 216, 68
[0220/160554.219853:ERROR:proc_task_reader.cc(45)] format error
 
Back
Top