#!/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