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