<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
<title>Fun with ones and zeros - debian</title>
<description><![CDATA[Barry's notes on computer software and hardware]]></description>
<link>/blog/tags/debian</link>
<lastBuildDate>Thu, 11 Jun 2026 20:50:11 -0700</lastBuildDate>
<item>
<title>Debian GNU/kFreeBSD in a FreeBSD Jail - part 2</title>
<link>/blog/entries/debian-gnukfreebsd-freebsd-jail-part-2</link>
<pubDate>Wed, 29 Feb 2012 07:49:00 -0800</pubDate>
<author>bp@barryp.org (Barry Pederson)</author>
<description><![CDATA[<p><a href="/blog/entries/debian-gnukfreebsd-freebsd-jail">Previously</a> 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 <a href="http://erdgeist.org/arts/software/ezjail/">ezjail</a> FreeBSD jails, so everything starts automatically, and you can use the <code>ezjail</code> commands to stop/restart the jail.  </p>
<p>Here are a few more notes about how things got setup for my jail I named <code>debian</code>:</p>
<h2>Kernel Modules</h2>
<p>In <code>/boot/loader.conf</code>, I added these lines:</p>
<pre><code>fdescfs_load="YES"
linprocfs_load="YES"
linsysfs_load="YES"
tmpfs_load="YES"</code></pre>
<h2>Mounting Filesystems</h2>
<p>Created <code>/etc/fstab.debian</code> and populated with:</p>
<pre><code>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</code></pre>
<h2>ezjail Config</h2>
<p>Created <code>/usr/local/etc/ezjail/debian</code> with these contents:</p>
<pre><code>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"</code></pre>
<p><em>I also tried adding an IPv6 address to the jail, and that seems to work OK</em></p>
<p>So you can now stop/start with jail with</p>
<pre><code>service ezjail.sh stop debian
service ezjail.sh start debian</code></pre>
<h2>Connect to the jail console</h2>
<p>If you create a symlink for <code>login</code> (so that from the jail's POV there's a <code>/usr/bin/login</code>, like there would be on a FreeBSD jail)</p>
<pre><code>cd /jails/debian/usr/bin/
ln -s ../../bin/login .</code></pre>
<p>then you can use the <code>ezjail-admin</code> command to get a console in the jail, with:</p>
<pre><code>ezjail-admin console debian</code></pre>
<p>Otherwise, I've been using my own script to get a console (which assumes <code>bash</code> is installed in the jail), named <code>/usr/local/sbin/jlogin</code></p>
<pre><code>#!/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</code></pre>
<p>That runs as:</p>
<pre><code>jlogin debian</code></pre>]]></description>
</item>
<item>
<title>Debian GNU/kFreeBSD in a FreeBSD Jail</title>
<link>/blog/entries/debian-gnukfreebsd-freebsd-jail</link>
<pubDate>Sun, 26 Feb 2012 18:04:00 -0800</pubDate>
<author>bp@barryp.org (Barry Pederson)</author>
<description><![CDATA[<p>I've been a FreeBSD user for quite some time, going back to 3.3 or so, and for the last serveral years have also been working a lot with Ubuntu Linux.  So when I ran across <a href="https://wiki.debian.org/Debian_GNU/kFreeBSD">Debian GNU/kFreeBSD</a>, which provides a Debian environment on top of a FreeBSD kernel, I was somewhat intrigued.  It got even more interesting when I found a <a href="https://blog.vx.sk/archives/22-Updated-Tutorial-Debian-GNUkFreeBSD-in-a-FreeBSD-jail.html">tutorial on setting up GNU/kFreeBSD in a jail</a>.  The notion of having a Debian environment on my home FreeBSD server without having to get something like VirtualBox running was just too good to pass up.</p>
<p>I got it running fairly decently, but along the way ran into some small problems - and thought I'd jot down what they were and what the fixes were.</p>
<h2>FreeBSD Update</h2>
<p>At first, I was using FreeBSD 8.2-RELEASE, and used <code>debootstrap</code> to install Debian Squeeze, as the tutorial showed.  Once inside the jail, things sort of worked, but most commands, <code>aptitude</code> especially, would die with: </p>
<pre><code>User defined signal 1</code></pre>
<p>It turns out you need a newer kernel than 8.2 to run kFreeBSD in a chroot, as is <a href="https://wiki.debian.org/Debian_GNU/kFreeBSD_FAQ#Q._Can_I_run_Debian_GNU.2BAC8-kFreeBSD_in_a_chroot_under_FreeBSD.3F">mentioned in the FAQ</a>. I upgraded my FreeBSD kernel/world to 8.3-PRERELEASE (2012-02-22), and the &quot;signal 1&quot; problem went away.</p>
<h2>Debian Update</h2>
<p>The next problem was that <code>aptitude</code> would still die, with:</p>
<pre><code>Uncaught exception: Unable to read from stdin: Operation not permitted</code></pre>
<p>After reading about <a href="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=472518,">this bug</a> in cwidget, it seemed an upgrade to Wheezy was needed to fix the problem - and sure enough that problem went away.</p>
<h2>kbdcontrol and /dev/console</h2>
<p>The upgrade to Wheezy didn't go entirely smoothly, mainly due to the <code>kbdcontrol</code> package (required by <code>sysvinit</code>) being unable to access <code>/dev/console</code> in the jail.    I wasn't worried about keeping things in the jail isolated for security reasons, so I went ahead and added <code>/dev/console</code> on-the-fly to the running jail by running outside the jail:</p>
<pre><code>devfs -m /jails/debian/dev rule add path 'console*' unhide
devfs -m /jails/debian/dev rule applyset</code></pre>
<p>After that, the <code>kbdcontrol</code> package was able to be upgraded, and I seem to have a Wheezy FreeBSD jail now.  Very cool.</p>
<p><strong>UPDATE</strong>: A <a href="/blog/entries/debian-gnukfreebsd-freebsd-jail-part-2">followup</a> talks more about the actual file changes made to run as an ezjail</p>]]></description>
</item>
</channel>
</rss>