Possible to run Linux distro in a jail?
Alexandre L.
axelbsd at ymail.com
Sat May 29 21:15:39 UTC 2010
I have this link to a French Blog : http://blog.etoilebsd.net/post/Emprisonner_une_debian_dans_un_FreeBSD
This describe how to "jail" a Linux Debian in FreeBSD.
I hope this will help you. I haven't used it.
Thanks to its author : Baptiste Daroussin.
I translated it in English :
<<<<<<<<<
# mkdir /home/jails/debian
# mkdir /home/jails/debian/dev
# mkdir /home/jails/debian/proc
# mkdir /home/jails/debian/sys
# kldload linux
# kldload linprocfs
# kldload linsysfs
# kldload lindev
# mount -t devfs none /home/jails/debian/dev
# mount -t linprocfs none /home/jails/debian/proc
# mount -t linsysfs none /home/jails/debian/sys
We are using /home/jails/debian for the root of the Linux Debian.
We will load all the necessary devices (nota : lindev appeared in Freebsd 9-CURRENT and has MFCed in 8-STABLE, it is not obligatory).
We could do the install with debootstrap, but I prefered to use an openvz template :
# fetch http://download.openvz.org/template/precreated/debian-5.0-x86.tar.gz
And I unpack it in my jail :
# tar xvfp debian-5.0-x86.tar.gz -C debian --exclude dev* --exclude proc* --exclude sys*
To correctly start my jail, at least 1 service must be started in the jail (I failed to build a persistent linux jail only). By default the startup script of jails try to launch /etc/rc that we will create and launch /etc/rc.shutdown to stop it.
# echo "/etc/init.d/cron start" > /home/jails/debian/etc/rc
# chmod 755 /home/jails/debian/etc/rc
# echo "/etc/init.d/cron stop" > /home/jails/debian/etc/rc.shutdown
# chmod 755 /home/jails/debian/etc/rc.shutdown
In /etc/rc.conf we configure the startup of the jail :
jail_debian_rootdir=/home/jails/debian
jail_debian_hostname="debian"
jail_debian_ip="192.168.1.3"
jail_debian_interface="nfe0"
jail_debian_devfs_enable="YES"
jail_debian_devfs_ruleset="devfsrules_jail"
jail_debian_flags="-n debian"
We start the jail :
# /etc/rc.d/jail start debian
And voilà :
#jls
JID IP Address Hostname Path
15 192.168.1.3 debian /home/jails/debian
#jexec debian uname -a
Linux debian 2.6.16 FreeBSD 8.0-STABLE #3: Sun Jan 10 20:39:38 CET 2010 i686 GNU/Linux
#jexec debian cat /etc/debian_version
5.0.4
Here a beautiful Debian Linux jailed in FreeBSD
But be careful, not everything works perfectly : sysklogd don't run cause to /dev access. But 99% is functional.
--- En date de : Ven 28.5.10, Yuri <yuri at rawbw.com> a écrit :
> De: Yuri <yuri at rawbw.com>
> Objet: Possible to run Linux distro in a jail?
> À: "freebsd-questions" <freebsd-questions at FreeBSD.ORG>
> Date: Vendredi 28 mai 2010, 20h16
> When I googled "linux in a jail" I
> got some references but no particular howto.
> Since currently VirtualBox is broken (hangs OS after a
> while), is it really possible to install Linux into a jail
> as a virtual machine?
>
> Yuri
> _______________________________________________
> freebsd-questions at freebsd.org
> mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
>
More information about the freebsd-questions
mailing list