Jail starts but doesn't start

Devin Teske dteske at vicor.com
Thu May 12 18:16:31 UTC 2011


> -----Original Message-----
> From: owner-freebsd-jail at freebsd.org [mailto:owner-freebsd-jail at freebsd.org]
> On Behalf Of Paul Schenkeveld
> Sent: Thursday, May 05, 2011 3:41 AM
> To: freebsd-jail at freebsd.org
> Subject: Re: Jail starts but doesn't start
>
> On Wed, May 04, 2011 at 04:24:11PM -0700, Mickey Harvey wrote:
> > Hosts /etc/rc.conf
> >
> >    1. ifconfig_bge0="inet 192.168.224.11 netmask 255.255.255.0"
> >    2. defaultrouter="192.168.224.1"
> >    3. sshd_enable="YES"
> >    4.
> >    5. linux_enable="YES"
> >    6. zfs_enable="YES"
> >    7. jail_enable="YES"
> >    8. jail_list="www0 dns0 smarty0 centos"
> >    9.
> >    10. ifconfig_bge0_alias0="inet 192.168.224.12 netmask 255.255.255.255"
> >    11. jail_www0_rootdir="/tank/jails/www0"
> >    12. jail_www0_hostname="www0"
> >    13. jail_www0_ip="192.168.224.12"
> >    14. jail_www0_devfs_enable="YES"
> >    15. jail_www0_exec_stop="/etc/rc.shutdown"
> >    16.
> >    17. #JAIL READY TO USE, JUST NEEDS APPROPRIATE FSTAB ENTRIES
> >    18. #ENTRIES ARE IN LOADER.CONF
> >    19. #TRIED TO BOOT WITH REQUIRED FSTAB BUT IT BROKE SO I REVERTED
> >    20. #5/3/11 MH
> >    21. #ifconfig_bge0_alias1="inet 192.168.224.13 netmask 255.255.255.255"
> >    22. #jail_deb0_rootdir="/tank/jails/deb0"
> >    23. #jail_deb0_hostname="deb0"
> >    24. #jail_deb0_ip="192.168.224.13"
> >    25. #jail_deb0_devfs_enable="YES"
> >    26. #jail_deb0_exec_start="/etc/init.d/rc 3"
> >    27. #jail_deb0_exec_stop="/etc/init.d/rc 0"
> >    28. #jail_deb0_flags="-l -u root"
> >    29.
> >    30. ifconfig_bge0_alias1="inet 192.168.224.14 netmask 255.255.255.255"
> >    31. jail_dns0_rootdir="/tank/jails/dns0"
> >    32. jail_dns0_hostname="dns0"
> >    33. jail_dns0_ip="192.168.224.14"
> >    34. jail_dns0_devfs_enable="YES"
> >    35. jail_dns0_exec_stop="/etc/rc.shutdown"
> >    36.
> >    37. ifconfig_bge0_alias2="inet 192.168.224.15 netmask 255.255.255.255"
> >    38. jail_smarty0_rootdir="/tank/jails/smarty0"
> >    39. jail_smarty0_hostname="smarty0"
> >    40. jail_smarty0_ip="192.168.224.15"
> >    41. jail_smarty0_devfs_enable="YES"
> >    42. jail_smarty0_exec_stop="/etc/rc.shutdown"
> >    43.
> >    44. ifconfig_bge0_alias3="inet 192.168.224.16 netmask 255.255.255.255"
> >    45. jail_centos_rootdir="/tank/jails/centos"
> >    46. jail_centos_hostname="centos"
> >    47. jail_centos_ip="192.168.224.16"
> >    48. jail_centos_devfs_enable="YES"
> >
> >
> > Result of jls after /etc/rc.d/jail start centos (notice there's no
> > entry for
> > centos)
> >
> >    JID  IP Address      Hostname                      Path
> >      1  192.168.224.12  www0                          /tank/jails/www0
> >      2  192.168.224.14  dns0                          /tank/jails/dns0
> >      3  192.168.224.15  smarty0                       /tank/jails/smarty0
> >
> >
> > No error messages when starting or stopping centos jail.
> > /var/run contains jail_centos.id
> > Alias exists on bge0.
> >
> > So I tried "jexec 4 /bin/bash" figuring jls just isn't showing the
> > centos jail for some reason but:
> > jexec: jail_attach(4): Invalid argument
> >
> > Anybody have any idea about what might be happening here?
>
> This usually happens when there are no processes running in the jail to keep
it
> up.  By default, jails started thru rc.d/jail are not persistent.
> Try adding something like cron_enable="YES" to rc.conf inside the jail.


The /etc/rc.d/jail script will (by default) run "/bin/sh /etc/rc" as the jailed
process. On FreeBSD, /etc/rc is responsible for booting the system. By default,
a vanilla FreeBSD jail will run syslogd, sendmail, and cron, all of which fork
and daemonize, triply allowing the jail to persist.

CentOS -- which also has /etc/rc (as a symbolic link to /etc/rc.d/rc) --
meanwhile may not have any services that are enabled by default. I would either

a. chroot(8) into the jail and use chkconfig(8) to enable something like cron in
runlevel 5 (e.g. chkconfig --level 5 crond on)
or simply...
b. ln -sf ../init.d/crond /tank/jails/centos/etc/rc5.d/S90crond

On a side note: this is the first that I've ever heard that you could run CentOS
Linux in a FreeBSD jail. It should work -- afterall, my CentOS 4.7 box appears
to have /etc/rc as a symlink to /etc/rc.d/rc, so in-theory there should be no
problems with the /etc/rc.d/jail FreeBSD script from firing up a CentOS jail
(*cough* in-theory *cough*).

Do let me know how you fair.
--
Devin


_____________

The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.
_____________


More information about the freebsd-jail mailing list