general/other Linux (Debian Bullseye) on FreeBSD

I am not a friend of virtualization or emulation on the desktop, but I decided to try.
Linux is not a Thema in this forum, but the emulation :)

I did:

Code:
# pkg install debootstrap
# mkdir /compat/debian
# kldload linux64
# debootstrap bullseye /compat/debian http://deb.debian.org/debian/
# chroot /compat/debian /bin/bash

And now I am trying to mount the virtual filesystem named in


The following commandos fail (in the chroot):

Code:
# mount -t sysfs sysfs /sys
mount: /sys: unknown filesystem type 'sysfs'.
# mount -t tmpfs tmpfs /dev/shm -osize=100m,mode=1777
mount: /dev/shm: unknown filesystem type 'tmpfs'.

And /dev/fd is filled without mounting anything.

I did apt-get install xterm, but get the error:

Code:
# xterm
Warning: locale not supported by C library, locale unchanged
xterm: Error 32, errno 2: No such file or directory
Reason: get_pty: not enough ptys

and

Code:
# mount -t devpts devpts /dev/pts
mount: /dev/pts: unknown filesystem type 'devpts'.
# ls /dev/pts/
0  1  2  3

Any hint?
 
You should mount emulated Linux virtual filesystems from the host, not from within the chroot (or jail). Set it up as a jail and mount virtual filesystems upon jail start; i.e. if using vanilla jails create /etc/fstab.debian like
Code:
linsysfs   /srv/jails/debian/sys   linsysfs   auto  0  0
linprocfs  /srv/jails/debian/proc  linprocfs  auto  0  0
and in /etc/jail.conf
Code:
debian {
    path = "/srv/jails/debian";
    ip4.addr = 192.168.1.77;
    exec.start = "/etc/init.d/rc 2";
    exec.stop = "/etc/init.d/rc 0";
    mount.fstab = /etc/fstab.debian;
    persist = true;
}
Then service jail start debian.
(partial example from an old Debian 8 jail, update jail.conf(5) to match to your setup).
 
Maybe this can give you ideas:
 
  • Thanks
Reactions: _al
Code:
# mount -t sysfs sysfs /sys
mount: /sys: unknown filesystem type 'sysfs'.
# mount -t tmpfs tmpfs /dev/shm -osize=100m,mode=1777
mount: /dev/shm: unknown filesystem type 'tmpfs'.

I think you are close. If you want to mount it manually, I believe it should be:

Code:
# mount -t linsysfs linsysfs /compat/debian/sys
# mount -t tmpfs tmpfs /compat/debian/dev/shm -osize=100m,mode=1777
 
Indeed, dev from within chroot, but proc from host. Or is there a lindevfs?
Yep, I think our native devfs is compatible enough to use directly.
Though the OP will likely want procfs too. This isn't native and so prefixed with lin*.

Code:
# mount -t devfs devfs /compat/debian/dev
# mount -t linprocfs linprocfs /compat/debian/proc

There isn't much info on mounting it manually; mostly via fstab.

@OP, Make sure to mount /compat/debian/dev/shm *after* /compat/debian/dev.
 
Thanks everybody. Till now I collected:

Code:
kldload linux64
sysctl compat.linux.emul_path=/compat/debian
mount -t devfs devfs /compat/debian/dev/
mount -t tmpfs tmpfs /compat/debian/dev/shm/
mount -t fdescfs -o linrdlnk null /compat/debian/dev/fd
mount -t linprocfs linprocfs /compat/debian/proc/
mount -t linsysfs linsysfs /compat/debian/sys/
chroot /compat/debian /bin/bash

Till now I cannot run xterm, opera segfaults. Outside chroot I get:

Code:
# /compat/debian/bin/ls
ELF interpreter /lib64/ld-linux-x86-64.so.2 not found, error 2
Abort
 
Yeah that is a well know issue.
I am not at a freebsd box, so I cannot post absolute details, but the problem is that /lib64/ld-linux-x86-64.so.2 is an absolute link to some target and fails in linuxulator due to the missing prefix /compat/debian/.
Remove it from outside chroot and create a relative link for /compat/debian/lib64/ld-linux-x86-64.so.2 to ../<wherever it pointed> and the issue is gone.
 
I think you are meant to use the sysctl tunable for that issue:

From the handbook (with edits):

It is possible to debootstrap into /compat/linux, but it is discouraged to avoid collisions with files installed from FreeBSD ports and packages. Instead, derive the directory name from the distribution or version name, e.g., /compat/ubuntu. If the bootstrapped instance is intended to provide Linux shared libraries without having to explicitly use chroot or jails, one can point the kernel at it by updating the compat.linux.emul_path sysctl and adding a line like this to /etc/sysctl.conf:

compat.linux.emul_path="/compat/debian"

So it is similar to an overlayfs / unionfs that if it can't find the lib in this directory (fake chroot), it will fall back to the / (root) which of course will fail because it either doesn't exist or is a FreeBSD binary that the linux emulated program can't use.

What is less clear is, since you are using a chroot, I am unsure if you need to set the sysctl to /compat/debian or just / because you are already using relative paths. I think it is the former due to the global nature of the sysctls, however you might want to have a play with both.
 
What is less clear is, since you are using a chroot, I am unsure if you need to set the sysctl to /compat/debian or just / because you are already using relative paths.
As I wrote before, in chroot no problem, but outside.

I do not want to do jails, virtial machines and all the things the first contributors recomended. Just run linux binaries as
simple as possible.
 
The command should be
Issued from what directory? With ln -s I only use absolute paths.

And the command witll complain that /compat/debian/lib64/ld-linux-x86-64.so.2 exists.

Well, originaly
# ls -l /compat/debian/lib64/ld-linux-x86-64.so.2
lrwxr-xr-x 1 root wheel 32 Mar 17 21:37 /compat/debian/lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.31.so
 
Issued from what directory? With ln -s I only use absolute paths.

And the command witll complain that /compat/debian/lib64/ld-linux-x86-64.so.2 exists.
Should not matter from which directory it is issued, ln -s creates relatively to where you create the link.

And you have to remove the broken link under /compat/debian/lib64/ld-linux-x86-64.so.2 first using rm /compat/debian/lib64/ld-linux-x86-64.so.2
 
I guess the original link looked for /lib/x86_64-linux-gnu/ld-2.31.so outside the chroot instead of /compat/debian/lib/x86_64-linux-gnu/ld-2.31.so
 
I guess, outside chroot by following the link looked at /lib/x86_64-linux-gnu/ld-2.31.so and not /compat/debian/lib/x86_64-linux-gnu/ld-2.31.so

It seems, every link will be a problem.

Haven't had a problem with other links yet.
No idea why though.
 
Back
Top