For the complete documentation index, see llms.txt. This page is also available as Markdown.

33.3 Ubuntu Jail

The method for creating an Ubuntu Jail is the same as for Debian. This example uses Ubuntu 22.04 (Jammy).

Build the Base System

Create the Ubuntu Jail root directory and install the system using debootstrap:

# Create the Ubuntu Jail root directory
# mkdir -p /usr/jails/ubuntu

# Install Ubuntu Jammy system into the Jail using debootstrap, specifying the mirror
# debootstrap jammy /usr/jails/ubuntu https://mirrors.ustc.edu.cn/ubuntu/

Manage Mount Files

Create the /etc/fstab.ubuntu file with the following content:

devfs      /usr/jails/ubuntu/dev      devfs       rw                      0  0
tmpfs      /usr/jails/ubuntu/dev/shm  tmpfs       rw,size=1g,mode=1777    0  0
fdescfs    /usr/jails/ubuntu/dev/fd   fdescfs     rw,linrdlnk             0  0
linprocfs  /usr/jails/ubuntu/proc     linprocfs   rw                      0  0
linsysfs   /usr/jails/ubuntu/sys      linsysfs    rw                      0  0
/tmp       /usr/jails/ubuntu/tmp      nullfs      rw                      0  0

Manage the Jail Configuration File

Add the Ubuntu configuration to the /etc/jail.conf file:

Allow Network Access

Add the Jail's address to the jails table in the pf firewall to allow the Jail to access the network:

Start the Ubuntu Jail Instance

Start the instance:

If jail_enable=YES has already been set in /etc/rc.conf, you can also use:

For boot-time startup settings, refer to the Debian Jail. Run the following command to add the ubuntu Jail to the startup list:

Update the Ubuntu System

The process is the same as for the Debian Jail; simply replace debian with ubuntu in the commands. Refer to other relevant chapters in this book.

References

Last updated