Solved How to create a Linux jail?

  • Thread starter Deleted member 63539
  • Start date
D

Deleted member 63539

Guest
With the base Linux is /compat/linux. I didn't found any guides like this. Most of them is setting up Debian/Devuan based jail with debootstrap. It's not what I need. I want to utilize the existing /compat/linux installed by linux-c7. Thanks.
 
 
Thank you. But it's not what I want.
 
Note that /compat/linux is not a jail.

A long time ago you actually had a choice of Linux systems, emulators/linux_base-debian for example.

I said about creating a Linux jail from /compat/linux.

I figured out how to do it as follow:

Code:
doas pkg install cpdup
doas zfs create rpool/DATA/LINUX
doas zfs set mountpoint=/LINUX rpool/DATA/LINUX
doas cpdup -vvv /compat/linux /LINUX
doas sysrc jail_enable="YES"
doas service jail start


/etc/jail.conf:

Code:
LINUX {
        host.hostname = "LINUX.jail";
        interface = re0;
        ip4.addr = 192.168.1.10;
        path = /LINUX;
        persist;

        mount.devfs;
        mount.fstab = /etc/fstab.LINUX;

        allow.mount;
        allow.mount.devfs;
}


/etc/fstab.LINUX:

Code:
linprocfs   /LINUX/proc    linprocfs    rw,late    0    0
linsysfs    /LINUX/sys    linsysfs    rw,late    0    0
tmpfs    /LINUX/dev/shm    tmpfs    rw,late,mode=1777    0    0


Code:
doas jail -c LINUX
doas jexec LINUX /bin/bash


Everything works as expected. But what I'm stuck now is the jail is very bare metal. Many things commonly found on a Linux distro don't exist (e.g: useradd, ping,...). So I decided to populate the jail with Joyent's pkgsrc repo for EL7: https://pkgsrc.joyent.com/install-on-linux/ It took a while for me to done setting up the bootstrap, since the jail doesn't have wget and even tar, I have to do this from the host system. But when I run pkgin update, I realized the jail doesn't have access to the internet! Please help. I'm stuck. Thanks.
 
/compat/linux is not suitable to be a base for a linux jail. My idea of reuse it for this purpose is plain wrong. It's too bare metal and lacks an init system. I will mark the thread as solved nevertheless.
 
Back
Top