Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linuxjails [2021/03/13 11:27] – Mention Bastille EdwardTomaszNapieralalinuxjails [2023/10/14 18:16] (current) – ChrisMoerz
Line 1: Line 1:
-This page describes the steps required to configure Ubuntu-based Linux jail or chroot - a complete Linux userspace environment running on top of [[Linuxulator]].+This page describes the steps required to configure an Ubuntu-based Linux jail or chroot - a complete Linux userspace environment running on top of [[Linuxulator]].
  
 Required steps: Required steps:
  
-  - Run %%FreeBSD%% 13-CURRENT or 12.2-RELEASE on amd64. +  - Have %%FreeBSD%% 14-CURRENT or 13.0-RELEASE on amd64, or 14-CURRENT on arm64 
-  - Have linux(4) compatibility enabled, as documented in the [[https://www.freebsd.org/cgi/man.cgi?linux|man page]]; this boils down to having ''%%linux_enable=YES%%'' in ''%%/etc/rc.conf%%''.  This is to load the neccessary kernel modules and set some sysctls. +  - Have linux(4) compatibility enabled, as documented in the [[https://www.freebsd.org/cgi/man.cgi?linux|man page]]; this boils down to having ''%%linux_enable=YES%%'' in ''%%/etc/rc.conf%%''; running ''%%service linux start%%'' as root after adding it there.  This is to load the neccessary kernel modules and set some sysctls. 
-  - Install [[https://www.freshports.org/sysutils/debootstrap/|sysutils/debootstrap]]; ''%%pkg install debootstrap%%''.  You need at least debootstrap-1.0.123_1. +  - Install [[https://www.freshports.org/sysutils/debootstrap/|sysutils/debootstrap]]; ''%%pkg install debootstrap%%''. 
-  - Run ''%%debootstrap --no-check-gpg bionic /compat/ubuntu%%''.  This will install Ubuntu Bionic into ''%%/compat/ubuntu%%''.  While it is technically possible to install into ''%%/compat/linux%%'' instead, it's discouraged due to possible clash with %%CentOS%%-based ports and packages ([[https://www.freshports.org/emulators/linux_base-c7/|linux_base-c7]] et al).  You might see some errors during configuration phase - they are generally harmless; as long as the log ends with "Base system installed successfully", everything is fine. +  - Run ''%%debootstrap bionic /compat/ubuntu%%''.  This will install Ubuntu Bionic into ''%%/compat/ubuntu%%''.  While it is technically possible to install into ''%%/compat/linux%%'' instead, it's discouraged due to possible clash with %%CentOS%%-based ports and packages ([[https://www.freshports.org/emulators/linux_base-c7/|linux_base-c7]] et al).  You might see some errors during the configuration phase - they are generally harmless; as long as the log ends with "Base system installed successfully", everything is fine. 
-  - Create a new file, ''%%/compat/ubuntu/etc/apt/apt.conf.d/00aptitude%%'', containing a single line: ''%%APT::Cache-Start 251658240;%%''. +  - Set up mounts in ''%%/etc/fstab%%'', as described in [[https://www.freebsd.org/cgi/man.cgi?linux|linux(4) man page]].  Remember to actually mount them (''%%mount -al%%'' if you use the example below) afterwards.  If you want to share home directory contents, and be able to run X11 apps, you will also need [[https://www.freebsd.org/cgi/man.cgi?nullfs|null mounts]] for ''%%/home%%'' and ''%%/tmp%%''.  For example:
-  - Set up mounts in ''%%/etc/fstab%%'', as described in [[https://www.freebsd.org/cgi/man.cgi?linux|linux(4) man page]].  Remember to actually mount them (''%%mount -al%%'' if you use the example below) afterwards.  If you want to share home directory contents, and be able to run X11 apps, you will also need null mounts for ''%%/home%%'' and ''%%/tmp%%''.  For example:+
  
 <code> <code>
Line 21: Line 20:
 </code> </code>
  
-That's it!  You should now be able to run ''%%chroot /compat/ubuntu /bin/bash%%'' and use ''%%apt%%'' like you would on a typical Ubuntu instance.  You will probably want to add users and groups with UIDs/GIDs matching the ones on the host system.  While ''%%systemd%%'' doesn't work, the ''%%service%%'' command works as usual.  Some things that would probably get set up by the installer require manual tweaking: if you get warnings about LC_ALL you'll want to install appropriate locales (''%%apt search language-pack%%'').  There's a configuration problem with the rsyslog package; use ''%%apt remove rsyslog%%'' to make ''%%apt%%'' stop whining.  To get your environment variables set up in the typical Ubuntu way you might want to start sshd(8) (''%%service ssh start%%'') and log in this way; you can add ''%%chroot /compat/ubuntu /usr/sbin/service ssh start%%'' to ''%%/etc/rc.local%%'' to make it run at boot.+That's it!  You should now be able to run ''%%chroot /compat/ubuntu /bin/bash%%'' and use ''%%apt%%'' like you would on a typical Ubuntu instance.  You will probably want to add users and groups with UIDs/GIDs matching the ones on the host system.  While ''%%systemd%%'' doesn't work, the ''%%service%%'' command works as usual.  Some things that would probably get set up by the installer require manual tweaking: if you get warnings about LC_ALL, you'll want to install appropriate locales (''%%apt search language-pack%%'').  There's a configuration problem with the rsyslog package; use ''%%apt remove rsyslog%%'' to make ''%%apt%%'' stop whining.  To get your environment variables set up in the typical Ubuntu way you might want to start sshd(8) (''%%service ssh start%%'') and log in this way; you can add ''%%chroot /compat/ubuntu /usr/sbin/service ssh start%%'' to ''%%/etc/rc.local%%'' to make it run at boot.  As with any other Ubuntu, you will probably want to add the package repositories missing from defaults; for the amd64 (x86_64) version of Bionic, make your ''%%/compat/ubuntu/etc/apt/sources.list%%'' look like this:
  
-Note that the instructions above apply to both jails and chroots - it makes no difference from Linuxulator point of view; the part that matters is changing the filesystem root directory, which is common to both.  Also note that the instructions don't describe how to manage the jail; take a look at [[https://www.harshadsharma.com/posts/2020/12/ubuntu-bionic-on-freebsd-with-iocage-managed-jails/|this article]] for instructions on how to manage your Ubuntu jail using [[https://iocage.io/|iocage]], or [[https://hackacad.net/post/2021-01-23-create-a-ubuntu-linux-jail-on-freebsd/|this one]] for [[https://bastillebsd.org/|Bastille]].+<code> 
 +deb http://archive.ubuntu.com/ubuntu bionic main universe restricted multiverse 
 +deb http://security.ubuntu.com/ubuntu/ bionic-security universe multiverse restricted main 
 +deb http://archive.ubuntu.com/ubuntu bionic-backports universe multiverse restricted main 
 +deb http://archive.ubuntu.com/ubuntu bionic-updates universe multiverse restricted main 
 +</code> 
 + 
 +For arm64, it should look like this: 
 + 
 +<code> 
 +deb http://ports.ubuntu.com/ubuntu-ports bionic main universe restricted multiverse 
 +</code> 
 + 
 +Note that the instructions above apply to both jails and chroots - it makes no difference from Linuxulator's point of view; the part that matters is changing the filesystem root directory, which is common to both.  Also note that the instructions don't describe how to manage the jail; take a look at [[https://www.harshadsharma.com/posts/2020/12/ubuntu-bionic-on-freebsd-with-iocage-managed-jails/|this article]] for instructions on how to manage your Ubuntu jail using [[https://iocage.io/|iocage]], or [[https://bastillebsd.org/blog/2021/08/01/bastille-experiments-with-ubuntu-and-debian-linux-containers/|this one]] for [[https://bastillebsd.org/|Bastille]].
  
 You can find the list of tested apps at [[LinuxApps]].  Feel free to add new entries. You can find the list of tested apps at [[LinuxApps]].  Feel free to add new entries.
 +
 +It is possible to use VNET with a Linux jail if one replaces the linux version of ''%%ifconfig%%'' with ''%%/rescue/ifconfig%%'' and ''%%route%%'' with ''%%/rescue/route%%'' (see the [[https://forums.freebsd.org/threads/vnet-and-a-linux-jail.82787/|forums]] for a more in-depth explanation).
  
 ---- ----
  • linuxjails.1615634869.txt.gz
  • Last modified: 2021/03/13 11:27
  • by EdwardTomaszNapierala