Page MenuHomeFreeBSD

Handbook WG - linuxemu
ClosedPublic

Authored by carlavilla on Apr 18 2023, 6:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 8 2024, 1:58 PM
Unknown Object (File)
Mar 25 2024, 10:32 PM
Unknown Object (File)
Nov 21 2023, 9:55 AM
Unknown Object (File)
Oct 10 2023, 8:53 AM
Unknown Object (File)
Oct 7 2023, 9:23 AM
Unknown Object (File)
Jun 20 2023, 5:22 PM
Unknown Object (File)
Jun 8 2023, 5:47 PM
Unknown Object (File)
May 27 2023, 1:21 PM
Subscribers
None

Details

Summary

Upgrade Linuxemu chapter

Changes:

Preview: https://www.carlavilla.es/freebsd/linuxemu.html

Diff Detail

Repository
R9 FreeBSD doc repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

carlavilla created this revision.
documentation/content/en/books/handbook/linuxemu/_index.adoc
73

The previous version implies that statically linked Linux binaries work after enabling linux in rc.conf. This version says that it is possible to run such binaries outright without any preparations. Not sure if this is true.

91

The Linux rc service/rc script, maybe?

196

IIRC, service linux start loads these modules automatically.

203

I doubt this is ever will be needed for some user.

fernape requested changes to this revision.Apr 19 2023, 8:31 AM

My take on this. Thanks for the work!

documentation/content/en/books/handbook/linuxemu/_index.adoc
73

I don't have an example now, but having a look at the code I think in general statically linked Linux binaries won't work.
For instance, the code for linux_fork is in linux_fork.c which is part of the linux.ko kernel module. If that kernel module is not loaded, I don't think most statically linked files will work.

The original doc has that text but after starting the linux service.

76

I don't know if phabricator is doing something funky here, but it looks like too many spaces in To enable

118–125

If all wanted --> If all that is wanted

also pkg --> pkg(8)

131

To install CentOS userland --> To install the CentOS userland

138–141

from CentOS 7 at --> from CentOS 7 into

140

Avoid "verify" repetition. Replace second one ... to verify... --> ... to check...

182

Spaces
To enable

182

...due to possible clash... --> ...due to possible clashes...

196

Yes, the linux rc script already does this:

# Explicitly load the filesystem modules; they are usually required,
# even with linux_mounts_enable="NO".
load_kld fdescfs
load_kld linprocfs
load_kld linsysfs
211

Shouldn't be necessary. linux_enable="YES" will take care of that.

243

To access to the system... --> To access the system...

264

I would rephrase this. Here is an attempt:

Once inside the chroot, the system behaves as in a normal Ubuntu installation.

297

"But" normally connects two sentences:

...by the [.filename]#/etc/rc.d/linux# script.
But can...
-->
...by the [.filename]#/etc/rc.d/linux# script but can...

453

I would remove this last section completely and link to the article on Linux emulation.

This revision now requires changes to proceed.Apr 19 2023, 8:31 AM
documentation/content/en/books/handbook/linuxemu/_index.adoc
219

This line sounds awkward to me; directories have no desires, and I wouldn't say that nullfs should be mounted, but rather home and tmp. Perhaps something like this.

221

I thought some of these were handled by the linux script?

314

I don't understand what this sentence means, in either new or old versions. But it should probably still say "on 64-bit hosts" or "on 64-bit amd64 and arm64 hosts".

344

Not necessary /compat/linux, other examples are used above.

454–455

I'm not sure this is correct in all cases. The FreeBSD csh looks for an initial '#", and if not found, invokes /bin/sh. Maybe this is an uncommon case. Also, if the first two bytes are "#!", the rest of the line is used to identify the interpreter and arguments, and that is implemented by execve.

carlavilla added inline comments.
documentation/content/en/books/handbook/linuxemu/_index.adoc
73

can you please provide a new paragraph?

219

hahaha, good point, but remember, Skynet will come :)

221

No, in this case no, the linux script mount the files in "/compat/linux"

297

Sorry, don't get the point :)

314

@fernape can you please help me here too hehe

344

I prefer to keep the path, because can be "/compat/ubuntu" or "/compat/debian"

carlavilla marked 3 inline comments as done.
documentation/content/en/books/handbook/linuxemu/_index.adoc
73

Just moving the sentence This is enough for statically linked Linux binaries to work. after the part where we say //Once enabled, it can be started without rebooting executing the following command://.

So activating the Linux emulation service is enough to run most statically linked Linux binaries.

75

Wrong character 'º'

264

The sentences still reads weird to me, but I'm not an English native speaker.

297

Sorry I didn't explain better. I think we should join the two sentences using but like this:

This is normally handled by the [.filename]#/etc/rc.d/linux# script but can be disabled at boot executing the following command:

314

32-bit kernels can only execute 32-bit executables. 64-bit kernels can execute 32- and 64-bit executables. However, what can't be done is to statically link "different bit sized" parts into one single kernel. The kernel (or any other executable for that matter) is either 64 or 32-bit.

carlavilla added inline comments.
documentation/content/en/books/handbook/linuxemu/_index.adoc
264

Well, we can improve this later :)

carlavilla marked an inline comment as done.

Everything fixed :)
I'll wait a couple of days and I'll make the commit

documentation/content/en/books/handbook/linuxemu/_index.adoc
73

They can be started in the same

Who they?

118–125

To my taste, this sentence has too many "install" words. How about

If all that is wanted is to run some software already included in the Ports tree, it can be installed via package manager and man:pkg[8] will automatically setup the required Linux userland.

I also suggest to remove the "like Sublime Text 4" part since you're talking about it in the next sentence.

documentation/content/en/books/handbook/linuxemu/_index.adoc
182

Didn't we already explained how to enable Linux ABI at the boot time above? Why repeat that?

documentation/content/en/books/handbook/linuxemu/_index.adoc
219

Missing to before be able to run X11 applications?

documentation/content/en/books/handbook/linuxemu/_index.adoc
73

This part: They can be started in the same way native FreeBSD binaries can; they behave almost exactly like native processes and can be traced and debugged the usual way.
should be after
The Linux service will load necessary kernel modules and mount filesystems expected by Linux applications under [.filename]#/compat/linux#. in line 91.

264

I would use the proposed one Once inside the chroot, the system behaves as in a normal Ubuntu installation.. I think it conveys the idea and is somehow clearer.

On re-reading this chapter, I think I understand the usage of /compat/linux, /compat/ubuntu, etc. But I don't think that it's very clear how they interact. It may be worth a paragraph near the beginning to say /compat/linux is meant for Centos, /compat/ubuntu for Debian/Ubuntu, etc. They are treated differently, in that the rc script does things automagically for /compat/linux.

documentation/content/en/books/handbook/linuxemu/_index.adoc
449

What is /etc/host.conf? I don't have one, or a man page. Or is it installed/used by the linux support code?

carlavilla added inline comments.
documentation/content/en/books/handbook/linuxemu/_index.adoc
118–125

Much better!

182

Good idea

449

If you're talking about FreeBSD, is https://man.freebsd.org/cgi/man.cgi?hosts

If you're talking about /compat/linux/etc/host.conf, it will be available after install 'linux_base-c7'

carlavilla marked 3 inline comments as done.
documentation/content/en/books/handbook/linuxemu/_index.adoc
449

No, I was talking about /etc/host.conf, which this sentence refers to.

carlavilla added inline comments.
documentation/content/en/books/handbook/linuxemu/_index.adoc
449
documentation/content/en/books/handbook/linuxemu/_index.adoc
449

No, the existing file and man page is /etc/hosts, the sentence refers to /etc/host.conf. If the sentence means to refer to compatibility of /etc/hosts, it is not well formed.

carlavilla added inline comments.
documentation/content/en/books/handbook/linuxemu/_index.adoc
449

My fault. I get your point now.
I found the file in my system.
I'm gonna make a clean installation and look in /etc/

documentation/content/en/books/handbook/linuxemu/_index.adoc
449

Yes, in FreeBSD it is /etc/hosts without the trailing .conf.

documentation/content/en/books/handbook/linuxemu/_index.adoc
449

No, /etc/hosts is a host address database, not a config file. Linux (at least Ubuntu) has both /etc/hosts and /etc/host.conf. /etc/hosts appears to have a compatible format.

documentation/content/en/books/handbook/linuxemu/_index.adoc
449

Yes, they are different things. What I wanted to say is that there is no /etc/host.conf in FreeBSD, the closest is /etc/hosts which, as you pointed out, has a different goal.

The thing with the Linuxolator, if I'm reading the code properly is that Linux binaries prefer files under /compat/linux and if they are not found, they are looked for in the normal namespace starting at /. This is done in the kern_alternate_path function.

I think the original paragraph is misleading. I think it is meant to say:

When [.filename]#/compat/linux/etc/host.conf# does not exist, Linux applications use [.filename]#/etc/host.conf# in the host system but they complain since that file does not exist in FreeBSD.

carlavilla marked 4 inline comments as done.
carlavilla added inline comments.
documentation/content/en/books/handbook/linuxemu/_index.adoc
449

Thanks to both of you, I trust that with the last change contributed by Fernando it is clear :)

This revision is now accepted and ready to land.May 2 2023, 6:34 PM
karels added inline comments.
documentation/content/en/books/handbook/linuxemu/_index.adoc
449

I don't know what actually happens, but the sentence makes sense now.

This revision was automatically updated to reflect the committed changes.
carlavilla marked an inline comment as done.