Re: Building a Linuxulator userland from source

From: Felix Palmen <>
Date: Mon, 21 Aug 2023 09:30:21 UTC
* Tatsuki Makino <> [20230821 17:40]:
> Felix Palmen wrote on 2023/08/21 16:21:
> > This works perfectly fine when used from within a Linux shell. Example
> > from testing my new userland:
> > 
> > | [00:00:20] Entering interactive test mode. Type 'exit' when done.
> > | root@14a-default:~ # /compat/linux/bin/bash
> > | bash-5.2# ldd /bin/bash
> > | (0x00007fffffffe000)
> > | => /usr/lib64/ (0x0000000801154000)
> > | => /usr/lib64/ (0x00000008011ad000)
> > | => /usr/lib64/ (0x00000008011bb000)
> > | => /usr/lib64/ (0x0000000801400000)
> > |         /lib64/ (0x0000000001021000)
> > | bash-5.2# 
> Oh, I understand.
> If we try to use it directly, the command not found if bash is not installed.

Installing a FreeBSD bash won't help either, this script expects
/bin/bash which will never exist on FreeBSD (it's installed in

> we want poudriere to mount real devfs to /compat/linux/dev as well,
> since linux binary behaves like chroot to /compat/linux.

Well, first /compat/linux is *not* a chroot or jail, but actually just
some kind of "filesystem overlay", which is the great thing about it. It
means Linux binaries can access *all* files of the FreeBSD system, as
long as they are not "shadowed" by something below /compat/linux.

And indeed, to support building native Linux software using poudriere,
it *should* mount devfs on /compat/linux/dev.

> Alternatively, pkg-plist in emulators/linux_base-c7 is creating dummy
> /compat/linux/dev, and removing it seems to be a workaround.

In a live system, there's no issue. /etc/rc.d/linux will mount all
necessary pseudo filesystems:

| if checkyesno linux_mounts_enable; then
|         linux_mount linprocfs "${_emul_path}/proc" -o nocover
|         linux_mount linsysfs "${_emul_path}/sys" -o nocover
|         linux_mount devfs "${_emul_path}/dev" -o nocover
|         linux_mount fdescfs "${_emul_path}/dev/fd" -o nocover,linrdlnk
|         linux_mount tmpfs "${_emul_path}/dev/shm" -o nocover,mode=1777
| fi

So far, poudriere doesn't mount anything on /compat/linux/dev for its
building jails, although it *does* mount /compat/linux/proc.

For now, I found that a simple symlink to the real /dev also does the
trick, which I can add with some hackery in the port Makefile itself, by
adding some extra prerequisite for "build-depends" when a poudriere
build is detected. In the long run, poudriere should mount a real devfs

Cheers, Felix

 Felix Palmen <>     {private}
 -- ports committer --                     {web}
 {pgp public key}
 {pgp fingerprint} 6936 13D5 5BBF 4837 B212  3ACC 54AD E006 9879 F231