Debian GNU/kFreeBSD in a FreeBSD Jail - part 2
Previously I wrote about getting Debian GNU/kFreeBSD working in a jail. I've worked on it a bit more, polishing things up so I've got it working pretty seamlessly with my existing ezjail FreeBSD jails, so everything starts automatically, and you can use the ezjail
commands to stop/restart the jail.
Here are a few more notes about how things got setup for my jail I named debian
:
Kernel Modules
In /boot/loader.conf
, I added these lines:
fdescfs_load="YES"
linprocfs_load="YES"
linsysfs_load="YES"
tmpfs_load="YES"
Mounting Filesystems
Created /etc/fstab.debian
and populated with:
linproc /jails/debian/proc linprocfs rw 0 0
linsys /jails/debian/sys linsysfs rw 0 0
tmpfs /jails/debian/lib/init/rw tmpfs rw 0 0
ezjail Config
Created /usr/local/etc/ezjail/debian
with these contents:
export jail_debian_hostname="debian"
export jail_debian_ip="127.0.0.6"
export jail_debian_interface="lo0"
export jail_debian_rootdir="/jails/debian"
export jail_debian_mount_enable="YES"
export jail_debian_devfs_enable="YES"
export jail_debian_devfs_ruleset="devfsrules_jail"
export jail_debian_fdescfs_enable="YES"
export jail_debian_exec_start="/etc/init.d/rc 3"
export jail_debian_flags="-l -u root"
I also tried adding an IPv6 address to the jail, and that seems to work OK
So you can now stop/start with jail with
service ezjail.sh stop debian
service ezjail.sh start debian
Connect to the jail console
If you create a symlink for login
(so that from the jail's POV there's a /usr/bin/login
, like there would be on a FreeBSD jail)
cd /jails/debian/usr/bin/
ln -s ../../bin/login .
then you can use the ezjail-admin
command to get a console in the jail, with:
ezjail-admin console debian
Otherwise, I've been using my own script to get a console (which assumes bash
is installed in the jail), named /usr/local/sbin/jlogin
#!/bin/sh
#
# log into a jail, running bash
#
JID=`jls | grep " $1 " | awk '{print $1}'`
exec jexec $JID env -i PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin TERM=$TERM EDITOR=$EDITOR LANG=$LANG HOME=/root bash -l
That runs as:
jlogin debian