Ubuntu bionic on FreeBSD with iocage managed jails
How I managed to run Ubuntu in a FreeBSD Jail managed with iocage.
What?¶
Here's the host machine, running FreeBSD 12.2-RELEASE.
uname -srmi FreeBSD 12.2-RELEASE-p1 amd64 GENERIC
Log into the Ubuntu Jail with iocage:
iocage console ubuntu Last login: Tue Dec 15 22:22:16 UTC 2020 on pts/1 Welcome to Ubuntu 18.04 LTS (GNU/Linux 3.2.0 x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage
Here's the Ubuntu Jail, running under FreeBSD's Linux compatibility layer:
uname -a Linux ubuntu 3.2.0 FreeBSD 12.2-RELEASE-p1 GENERIC x86_64 x86_64 x86_64 GNU/Linux
Requirements:¶
-
FreeBSD 12.2
installed on a baremetal or a virtual machine. -
iocage
installed and configured.
Enable Linux Compatibility Layer¶
Set up /boot/loader.conf
to load required kernel modules at boot:
linprocfs_load=YES linsysfs_load=YES tmpfs_load=YES
Enable Linux in /etc/rc.conf
using the handy utility sysrc
and reboot.
sysrc linux_enable=YES reboot
Create empty iocage jail¶
iocage create -e -n ubuntu exec_start="/bin/true" exec_stop="/bin/true" ip4_addr="em0|10.0.0.99/16"
-
Disable startup scripts by setting
/bin/true
toexec_start
andexec_stop
. -
Set IPv4 address on host's network interface or bridge, don't use VNET.
-
Replace
em0
with your interface or bridge name.
Install and run debootstrap¶
pkg install -y debootstrap debootstrap --arch=amd64 --no-check-gpg bionic /zroot/iocage/jails/ubuntu/root/ echo "APT::Cache-Start 251658240;" > /zroot/iocage/jails/ubuntu/root/etc/apt/apt.conf.d/00aptitude
-
Use the path to your ubuntu jail instead of
/zroot/iocage/jails/ubuntu/root/
Set up filesystems for the jail¶
iocage fstab -e ubuntu
-
If you've not yet set up the
$EDITOR
environment variable, now's the time toexport EDITOR=nvim
, replace nvim with your preferred text editor.
devfs /zroot/iocage/jails/ubuntu/root/dev devfs rw 0 0 tmpfs /zroot/iocage/jails/ubuntu/root/dev/shm tmpfs rw,size=1g,mode=1777 0 0 fdescfs /zroot/iocage/jails/ubuntu/root/dev/fd fdescfs rw,linrdlnk 0 0 linprocfs /zroot/iocage/jails/ubuntu/root/proc linprocfs rw 0 0 linsysfs /zroot/iocage/jails/ubuntu/root/sys linsysfs rw 0 0 /tmp /zroot/iocage/jails/ubuntu/root/tmp nullfs rw 0 0 /home /zroot/iocage/jails/ubuntu/root/home nullfs rw 0 0
Finally¶
iocage start ubuntu
Once logged into the jail:
apt update apt remove rsyslog
Tinker around, find out what works and read the references below for details.
References: