#!/bin/sh
export JAILNAME="Linux"
export JAIL="/usr/jail/$JAILNAME"
mkdir -p $JAIL
for DIR in /dev/fd /dev/shm /tmp /proc /sys; do mkdir -p $JAIL/${DIR}; done
pkg install -y debootstrap
debootstrap --arch=amd64 --no-check-gpg focal $JAIL
cat <<EOF > $JAIL/etc/fstab
devfs $JAIL/dev devfs rw 0 0
tmpfs $JAIL/dev/shm tmpfs rw,size=1g,mode=1777 0 0
fdescfs $JAIL/dev/fd fdescfs rw,linrdlnk 0 0
linprocfs $JAIL/proc linprocfs rw 0 0
linsysfs $JAIL/sys linsysfs rw 0 0
/tmp $JAIL/tmp nullfs rw 0 0
EOF
cat <<EOF >> /etc/jail.conf
$JAILNAME {
host.hostname="$JAILNAME";
ip4.addr= 192.168.1.111;
path="$JAIL";
allow.raw_sockets=1;
exec.start='/bin/true';
exec.stop='/bin/true';
persist;
mount.fstab="$JAIL/etc/fstab";
}
EOF
kldload linux64
sysrc +=kld_list linux64
sysrc jail_enable=YES
service jail start Linux
jls
jexec Linux /bin/bash
root@X1:/etc# jexec Linux /bin/bash
groups: cannot find name for group ID 0
groups: cannot find name for group ID 5
I have no name!@Linux:/#
root@X1:/#It appears your jail does not have a hostname and you might be missing /etc/group?
cat /etc/jail.conf
:-Linux {
host.hostname="Linux";
ip4.addr= 192.168.1.111;
interface = wlan0;
path="/usr/jail/Linux";
allow.raw_sockets=1;
exec.start='/bin/true';
exec.stop='/bin/true';
persist;
mount.fstab="/usr/jail/Linux/etc/fstab";
}
service jail start Linux
jls
JID IP Address Hostname Path
1 192.168.1.108 openwrt /usr/jail/openwrt
2 192.168.1.109 FreeBSD /usr/jail/FreeBSD
3 192.168.1.110 mfsbsd /usr/jail/mfsbsd
5 192.168.1.111 Linux /usr/jail/Linux
sysrc linux_enable=YES && service linux start
. This ensures that all required linuxkpi kernel modules are loaded for the compatibility layer to be available. debootstrap
, this should all be set up out of the box. See https://wiki.freebsd.org/LinuxJailsI always use adduser(8) and explicitly create users in a jail. I.e.…
As for users and groups, I have no idea how they should be dealt with in a jail. Does the jail inherit the values from the host or should the jail have its own? I didn't see any reference for handling these in the guide I followed.
jexec my-jail sh
adduser myuser
/usr/jail/Linux/etc/group is missing from the jail's filesystem. The rest looks fine though.The linux jail gets its groups from /etc/group within its directory root. So, if you install your linux environment under /jail/linux, then it's going to be under /jail/linux/etc/group. /compat/linux is not required for that. That's used not for linux jails but for linux compatibility in the host system.
I installed sysutils/debootstrap but then ranYou need to have linux compatibility turned on, otherwise it won't work. I.e.sysrc linux_enable=YES && service linux start
. This ensures that all required linuxkpi kernel modules are loaded for the compatibility layer to be available.
![]()
Chapter 12. Linux Binary Compatibility
FreeBSD provides binary compatibility with Linux, allowing users to install and run most Linux binaries on a FreeBSD system without having to first modify the binarydocs.freebsd.org
If you use i.e.debootstrap
, this should all be set up out of the box. See https://wiki.freebsd.org/LinuxJails
If your posts up there are from your system: what's under /usr/jails/Linux and /usr/jails/Linux/etc/group in particular? Watch the uppercase L there.
debootstrap --arch=amd64 --no-check-gpg focal /usr/jail/Linux
. debootstrap bionic /compat/ubuntu
If you want to run an entire Linux system inside a jail, check the LinuxJails page on the FreeBSD Wiki. That’s the guide you’re looking for. The Linuxulator page is more about the underlying compatibility layer itself. For jails, Debian/Ubuntu are the best supported, though other Linux flavors may work with more tinkering.”
The “I have no name!” prompt happens because your jail’s /etc/passwd and /etc/group don’t have entries for UID 0 and GID 0/5.Many thanks Holger . I tried to incorporate your instructions into the following script:-
Bash:#!/bin/sh export JAILNAME="Linux" export JAIL="/usr/jail/$JAILNAME" mkdir -p $JAIL for DIR in /dev/fd /dev/shm /tmp /proc /sys; do mkdir -p $JAIL/${DIR}; done pkg install -y debootstrap debootstrap --arch=amd64 --no-check-gpg focal $JAIL cat <<EOF > $JAIL/etc/fstab devfs $JAIL/dev devfs rw 0 0 tmpfs $JAIL/dev/shm tmpfs rw,size=1g,mode=1777 0 0 fdescfs $JAIL/dev/fd fdescfs rw,linrdlnk 0 0 linprocfs $JAIL/proc linprocfs rw 0 0 linsysfs $JAIL/sys linsysfs rw 0 0 /tmp $JAIL/tmp nullfs rw 0 0 EOF cat <<EOF >> /etc/jail.conf $JAILNAME { host.hostname="$JAILNAME"; ip4.addr= 192.168.1.111; path="$JAIL"; allow.raw_sockets=1; exec.start='/bin/true'; exec.stop='/bin/true'; persist; mount.fstab="$JAIL/etc/fstab"; } EOF kldload linux64 sysrc +=kld_list linux64 sysrc jail_enable=YES service jail start Linux jls jexec Linux /bin/bash
This seems to work, but I get the following when entering the jail:-
Looks like I'm missing something... Any idea what I've overlooked?Code:root@X1:/etc# jexec Linux /bin/bash groups: cannot find name for group ID 0 groups: cannot find name for group ID 5 I have no name!@Linux:/#
You’re seeing “I have no name!” because your jail’s Linux root filesystem is missing proper user/group info. A FreeBSD jail does not inherit users from the host — it needs its own /etc/passwd and /etc/group.root@X1:/#cat /etc/jail.conf
:-
Code:Linux { host.hostname="Linux"; ip4.addr= 192.168.1.111; interface = wlan0; path="/usr/jail/Linux"; allow.raw_sockets=1; exec.start='/bin/true'; exec.stop='/bin/true'; persist; mount.fstab="/usr/jail/Linux/etc/fstab"; }
service jail start Linux
Starting jails: Linux.
jls
Code:JID IP Address Hostname Path 1 192.168.1.108 openwrt /usr/jail/openwrt 2 192.168.1.109 FreeBSD /usr/jail/FreeBSD 3 192.168.1.110 mfsbsd /usr/jail/mfsbsd 5 192.168.1.111 Linux /usr/jail/Linux
As for users and groups, I have no idea how they should be dealt with in a jail. Does the jail inherit the values from the host or should the jail have its own? I didn't see any reference for handling these in the guide I followed.
The /compat/linux directory doesn’t appear automatically — it’s created when you install the FreeBSD Linux compatibility base.According to Holger's guiide, there is no mention of Configuring Linux Binary Compatibility so am not sure if this is required or not. Also I have no /compat/linux. What creates is such a directory?
And where does the Linux jail get its users defined?
Just to clarify a few points:The linux jail gets its groups from /etc/group within its directory root. So, if you install your linux environment under /jail/linux, then it's going to be under /jail/linux/etc/group. /compat/linux is not required for that. That's used not for linux jails but for linux compatibility in the host system.
You need to have linux compatibility turned on, otherwise it won't work. I.e.sysrc linux_enable=YES && service linux start
. This ensures that all required linuxkpi kernel modules are loaded for the compatibility layer to be available.
![]()
Chapter 12. Linux Binary Compatibility
FreeBSD provides binary compatibility with Linux, allowing users to install and run most Linux binaries on a FreeBSD system without having to first modify the binarydocs.freebsd.org
If you use i.e.debootstrap
, this should all be set up out of the box. See https://wiki.freebsd.org/LinuxJails
If your posts up there are from your system: what's under /usr/jails/Linux and /usr/jails/Linux/etc/group in particular? Watch the uppercase L there.