Debian GNU/kFreeBSD may be installed in a jail on a FreeBSD host. Interesting if you want to keep your server under FreeBSD but you also want to enjoy the jails that can draw packages from Debian repositories. Here is how to proceed.
Load the modules
# kldload fdescfs linprocfs linsysfs tmpfs
Or, permanently, edit the /boot/loader.conf file:
fdescfs_load = “YES”
linprocfs_load = “YES”
linsysfs_load = “YES”
tmpfs_load = “YES”
Note: these modules are not essential to the operation of the Debian GNU/kFreeBSD jail. But if one installs this OS from ISO official, one sees that they are present and associated with mount points as we will see later. My assumption is that they provide a “Linux compatibility” for some non-fully-functional software. linprocfs is used inter alia for ps and df. In addition it does not eat bread activate 🙂
Creation of the jail
He’ll use debootstrap and also install perl5 which is addictive.
# pkg install debootstrap perl5
And then you created the directory of the jail:
# mkdir-p/usr/jails/debian
It installs everything:
# debootstrap wheezy/usr/jails/debian http://cdn.debian.net/debian
Configuration of the jail
Edit the file /etc/jail.conf
# DEFAULT PARAMETERS
#
exec.start = “/ bin/sh/etc/rc”;
exec.stop = “/ bin/sh /etc/rc.shutdown”;
exec.clean;
Mount.devfs;
path = “/ usr/jails/$name”;
host.hostname = “$name”;
# INDIVIDUAL JAIL PARAMETERS
#
Debian {}
allow.Mount;
Mount.devfs;
Mount.fstab=”/usr/jails/Debian/etc/fstab.Debian”;
ip4.addr @description re0|192.168.0.13.
exec.start = “/etc/init.d/rc 3”;
exec.stop = “/etc/init.d/rc 0”;
}
Then edit /usr/jails/debian/etc/fstab.debian:
sys/usr/jails/debian/sys linsysfs rw 0 0
proc/usr/jails/debian/proc linprocfs rw 0 0
tmpfs/usr/jails/debian/run tmpfs rw, noexec, nosuid 0 0
Kludge to make for the password, otherwise the jail will not start:
# cp/usr/jails/debian/etc/etc/master.passwd.
# pwd_mkdb-d/usr/jails/debian/etc p /usr/jails/debian/etc/master.passwd
Start the jail
# service jail start debian
We can then see if the jail turns:
# jls
IADB IP Address Hostname Path
15 192.168.0.13/usr/jails/debian debian
And it also shows our mount points:
# df h
Filesystem Size Used Avail Capacity Mounted on
/ dev/ada0p2 140G 11 G 118G 9% /.
devfs 1.0 K 1.0 K 0 B 100% / dev
devfs 1.0 K 1.0 K 0 B 100% / usr/jails/debian/dev
fdescfs 1.0 K 1.0 K 0 B 100% / usr/jails/debian/dev/fd
linsysfs 4.0 K 4.0 K 0 B 100% / usr/jails/debian/sys
linprocfs 4.0 K 4.0 K 0 B 100% / usr/jails/debian/proc
tmpfs 4.0 G 24 K 4.0 G 0% / usr/jails/debian/run
devfs 1.0 K 1.0 K 0 B 100% / usr/jails/debian/dev
Note that the items displayed may be different depending on your system.
Configure our Debian/kFreeBSD
Enter the jail:
# jexec debian bash
Start by rebuilding the users and passwords, because we copy those of FreeBSD (the host) but causes problems:
# dpkg – reconfigure base-passwd
Reconfigure tzdata to set the record straight at the time:
# dpkg – reconfigure tzdata
Configure the local:
# apt – get update
# apt – get install local
# dpkg – reconfigure local
And voila.
Note that Debian GNU/kFreeBSD is still relatively little used, and I have not yet found of feedback on this OS, let alone when used in a FreeBSD jail. It is a little explored territory should therefore be cautious especially on a production environment.