Lin­ux­u­la­tor explained: How to cre­ate Lin­ux bina­ries on FreeB­SD

There may by cas­es where you want to gen­er­ate a Lin­ux bina­ry on a FreeB­SD machine. This is not a prob­lem with the lin­ux­u­la­tor, but not with the default linux_base port.

As you may know, the linux_base port is designed to deliv­er an inte­grat­ed expe­ri­ence with FreeB­SD native pro­grams. As such some parts of the native FreeB­SD infra­struc­ture is used. If you would try to use a Lin­ux-com­pil­er to gen­er­ate Linux-bina­ries, you would run into the prob­lem that by default the FreeB­SD includes are used.

Pre­req­ui­sites

To have a ful­ly fea­tured and non-integrated Lin­ux envi­ron­ment on your FreeB­SD sys­tem either mount an exist­ing (and com­pat­i­ble) Lin­ux instal­la­tion some­where into your FreeB­SD sys­tem, or install a linux_dist port. This can be done addi­tion­al­ly to an already installed linux_base port.

Prepa­ra­tion

When you have a com­plete Lin­ux envi­ron­ment avail­able, you need to mount the FreeB­SD devfs to /path/to/complete_linux/dev, lin­procfs to /path/to/complete_linux/proc and lin­sys­fs to /path/to/complete_linux/sys to have a com­plete set­up.

Use it

Now you just need to chroot into this  /path/to/complete_linux and you configure/make/install or what­ev­er you need to do to gen­er­ate your desired Lin­ux bina­ry.

Send to Kin­dle

Lin­ux­u­la­tor D‑Trace probes com­mit­ted to cur­rent

A while ago I com­mit­ted the lin­ux­u­la­tor D‑Trace probes I talked about ear­li­er. I wait­ed a lit­tle bit for this announce­ment to make sure I have not bro­ken any­thing. Nobody com­plained so far, so I assume noth­ing obvi­ous­ly bad crept in.

The >500 probes I com­mit­ted do not cov­er the entire lin­ux­u­la­tor, but are a good start. Adding new ones is straight for­ward, if some­one is inter­est­ed in a junior-ker­nel-hack­er task, this would be one. Just ask me (or ask on emu­la­tion@), and I can guide you through it.

Send to Kin­dle

linux_base-c6

Seems I for­got to announce that the linux_base-c6 is in the Ports Col­lec­tion now. Well, it is not a replace­ment for the cur­rent default lin­ux base, the lin­ux­u­la­tor infra­struc­ture ports are miss­ing and we need to check if the ker­nel sup­ports enough of 2.6.18 that noth­ing breaks.

TODO:

To my knowl­edge, nobody is work­ing on any­thing of this. Any­one is wel­come to have a look and pro­vide patch­es.

Send to Kin­dle

Lin­ux­u­la­tor progress

This week­end I made some progress in the lin­ux­u­la­tor:

  • I MFCed the report­ing of some linux-syscalls to 9‑stable and 8‑stable.
  • I updat­ed my lin­ux­u­la­tor-dtrace patch to a recent ‑cur­rent. I already com­piled it on i386 and arundel@ has it com­piled on amd64. I count­ed more than 500 new DTrace probes. Now that DTrace res­cans for SDT probes when a ker­nel mod­ule is loaded, there is no ker­nel pan­ic any­more when the lin­ux mod­ule is loaded after the DTrace mod­ules and you want to use DTrace. I try to com­mit this at a morn­ing of a day where I can fix things dur­ing the day in case some prob­lems show up which I did not notice dur­ing my test­ing.
  • I cre­at­ed a PR for portmgr@ to repocopy a new linux_base port.
  • I set the expi­ra­tion date of linux_base-fc4 (only used by 7.x and upstream way past its EoL) and all depen­dent ports. It is set to the EoL of the last 7.x release, which can not use a lat­er linux_base port. I also added a com­ment which explains that the date is the EoL of the last 7.x release.
Send to Kin­dle

New oppor­tu­ni­ties in the lin­ux­u­la­tor

Last week­end I com­mit­ted some dummy-syscalls to the lin­ux­u­la­tor in FreeB­SD-cur­rent. I also added some com­ments to syscalls.master which should give a hint which lin­ux ker­nel had them for the first time (if the lin­ux man-page I looked this up in is cor­rect). So if some­one wants to exper­i­ment with a high­er com­pat.linux.osrelease than 2.6.16 (as it is need­ed for a Cen­tOS based linux_base), he should now get some ker­nel mes­sages about unim­ple­ment­ed syscalls instead of a silent fail­ure.

There may be some low-hanging fruits in there, but I did not real­ly ver­i­fy this by check­ing what the dum­my syscalls are sup­posed to do in lin­ux and if we can eas­i­ly map this to exist­ing FreeB­SD fea­tures. In case some­one has a look, please send an email to emulation@FreeBSD.org.

Send to Kin­dle