jails How to create a ubuntu jail?

Code:
ubuntu {
  exec.start = "/bin/sh /etc/rc";
  exec.stop = "/bin/sh /etc/rc.shutdown";
  exec.consolelog = "/var/log/jail_console_${name}.log";
  allow.raw_sockets;
  exec.clean;
  mount.devfs;
  host.hostname = "${name}";
  path = "/compat/ubuntu";
  ip4.addr = 1.1.1.5;
  interface = tap0;
}
Code:
# service jail start ubuntu
Starting jails: cannot start jail  "ubuntu":
14
jail: ubuntu: getpwnam: No such file or directory
jail: ubuntu: /bin/sh /etc/rc: failed
 
Last edited by a moderator:
TLDR: does jail have /etc/master.passwd and password database?

I've stumbled upon the same issue recently when setting up an Alpine Linux jail. This thread helped me:
 
TLDR: does jail have /etc/master.passwd and password database?

I've stumbled upon the same issue recently when setting up an Alpine Linux jail. This thread helped me:
Thanks, and how to solve the
jail: ubuntu: /bin/sh /etc/rc: failed problem?
I also tried /etc/init.d/rc, but it's same result.
 
To start a FreeBSD jail, yes.
1000042962.jpg

then I asked AI and tried /etc/init.d/rc, but also failed
 
The handbook is wrong on that one.

The following jail.conf is taken from a Bastille created Linux jail. And it works.

Code:
…
  exec.start = '/bin/true';
  exec.stop = '/bin/true';
…
 
Here is the setup I have to run Ubuntu inside the jail:

- Run a thick jail with FreeBSD environment where exec.start = '/bin/sh /etc/rc'
- Install ubuntu environment say under /compat/jammy inside the jail with appropriate settings to the host node to enable Linux Compatibility Layer
- Mount devfs, linprocfs, etc. under $path/compat/jammy in the jail
- Use rc.local to start SSH and other Ubuntu services
Code:
chroot /compat/jammy /usr/sbin/service ssh start

SSH into Ubuntu jail and work as if a Ubuntu server.

As was mentioned above, Ubuntu relies on systemd. It makes such setup generate errors from time to time, when in need to change some settings using CLI tools that rely on systemd. I have to bypass this limitation by manually changing appropriate configs + friends in the old fashion and it seem to work.

Of course bhyve would be a bit more appropriate to run more-or-less full Ubuntu stack including Kernel, but that's a different story.

As an alternative solution, there is a very short but helpful page on running Alpine Linux in a jail, without FreeBSD environment: https://it-notes.dragas.net/2024/01/18/installing-alpine-linux-on-a-freebsd-jail/. Of course, it is a different Linux distribution, but must smaller (Ubuntu 24.04 Server ISO is ~3GB, Alpine mini root filesystem is ~5MB).
 
The handbook is wrong on that one.

The following jail.conf is taken from a Bastille created Linux jail. And it works.

Code:
…
  exec.start = '/bin/true';
  exec.stop = '/bin/true';
…
So there's no way to really start a ubuntu jail?
 
Its described in FreeBSD Handbook how to create Linux Jails:

- https://docs.freebsd.org/en/books/handbook/jails/#creating-linux-jail
There is nothing mentioned in the handbook on how to create new "Thin Jail using UFS"
The handbook indicates only how to create Thin Jail using OpenZFS Snapshots :
zfs snapshot zroot/jails/templates/15.0-RELEASE@base
zfs clone zroot/jails/templates/15.0-RELEASE@base zroot/jails/containers/thinjail


From the handbook:
"The next step will be to create a jail as indicated above, for example in Creating a Thin Jail Using OpenZFS Snapshots, but without performing the configuration. FreeBSD Linux jails require a
specific configuration that will be detailed below. Once the jail has been created as explained above, execute the following command to perform required configuration for the jail and start it:"


Maybe, one has to use the Thin Jail Using NullFS instructions to create FreeBSD or Linux jail(s) in UFS :confused:
 
Back
Top