<?xml version="1.0" encoding="utf-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Fun with ones and zeros - debian</title>
<subtitle>Barry&#039;s notes on computer software and hardware</subtitle>
<link href="/blog/tags/debian"></link>
<updated>2026-06-11T20:48:44-07:00</updated>
<id>urn:uuid:aaedf0b1-eec9-a1f1-b2f9-ade099170fd6</id>
<entry>
<title>Debian GNU/kFreeBSD in a FreeBSD Jail - part 2</title>
<link href="/blog/entries/debian-gnukfreebsd-freebsd-jail-part-2"></link>
<id>urn:uuid:491620cc-56cf-188e-41dc-4ad604e2402e</id>
<updated>2012-02-29T07:49:00-08:00</updated>
<author><name>Barry Pederson</name>
<email>bp@barryp.org</email>
</author>
<content type="html">&lt;p&gt;&lt;a href=&quot;/blog/entries/debian-gnukfreebsd-freebsd-jail&quot;&gt;Previously&lt;/a&gt; I wrote about getting Debian GNU/kFreeBSD working in a jail.  I&#039;ve worked on it a bit more, polishing things up so I&#039;ve got it working pretty seamlessly with my existing &lt;a href=&quot;http://erdgeist.org/arts/software/ezjail/&quot;&gt;ezjail&lt;/a&gt; FreeBSD jails, so everything starts automatically, and you can use the &lt;code&gt;ezjail&lt;/code&gt; commands to stop/restart the jail.  &lt;/p&gt;
&lt;p&gt;Here are a few more notes about how things got setup for my jail I named &lt;code&gt;debian&lt;/code&gt;:&lt;/p&gt;
&lt;h2&gt;Kernel Modules&lt;/h2&gt;
&lt;p&gt;In &lt;code&gt;/boot/loader.conf&lt;/code&gt;, I added these lines:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;fdescfs_load=&quot;YES&quot;
linprocfs_load=&quot;YES&quot;
linsysfs_load=&quot;YES&quot;
tmpfs_load=&quot;YES&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Mounting Filesystems&lt;/h2&gt;
&lt;p&gt;Created &lt;code&gt;/etc/fstab.debian&lt;/code&gt; and populated with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;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&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;ezjail Config&lt;/h2&gt;
&lt;p&gt;Created &lt;code&gt;/usr/local/etc/ezjail/debian&lt;/code&gt; with these contents:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;export jail_debian_hostname=&quot;debian&quot;
export jail_debian_ip=&quot;127.0.0.6&quot;
export jail_debian_interface=&quot;lo0&quot;
export jail_debian_rootdir=&quot;/jails/debian&quot;
export jail_debian_mount_enable=&quot;YES&quot;
export jail_debian_devfs_enable=&quot;YES&quot;
export jail_debian_devfs_ruleset=&quot;devfsrules_jail&quot;
export jail_debian_fdescfs_enable=&quot;YES&quot;
export jail_debian_exec_start=&quot;/etc/init.d/rc 3&quot;
export jail_debian_flags=&quot;-l -u root&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;I also tried adding an IPv6 address to the jail, and that seems to work OK&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So you can now stop/start with jail with&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;service ezjail.sh stop debian
service ezjail.sh start debian&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Connect to the jail console&lt;/h2&gt;
&lt;p&gt;If you create a symlink for &lt;code&gt;login&lt;/code&gt; (so that from the jail&#039;s POV there&#039;s a &lt;code&gt;/usr/bin/login&lt;/code&gt;, like there would be on a FreeBSD jail)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd /jails/debian/usr/bin/
ln -s ../../bin/login .&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;then you can use the &lt;code&gt;ezjail-admin&lt;/code&gt; command to get a console in the jail, with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ezjail-admin console debian&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Otherwise, I&#039;ve been using my own script to get a console (which assumes &lt;code&gt;bash&lt;/code&gt; is installed in the jail), named &lt;code&gt;/usr/local/sbin/jlogin&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/sh
#
# log into a jail, running bash
#
JID=`jls | grep &quot; $1 &quot; | awk &#039;{print $1}&#039;`
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&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That runs as:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;jlogin debian&lt;/code&gt;&lt;/pre&gt;</content>
</entry>
<entry>
<title>Debian GNU/kFreeBSD in a FreeBSD Jail</title>
<link href="/blog/entries/debian-gnukfreebsd-freebsd-jail"></link>
<id>urn:uuid:bccedc17-dd64-0b07-238e-9bea52240b6b</id>
<updated>2012-02-26T18:04:00-08:00</updated>
<author><name>Barry Pederson</name>
<email>bp@barryp.org</email>
</author>
<content type="html">&lt;p&gt;I&#039;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 &lt;a href=&quot;https://wiki.debian.org/Debian_GNU/kFreeBSD&quot;&gt;Debian GNU/kFreeBSD&lt;/a&gt;, which provides a Debian environment on top of a FreeBSD kernel, I was somewhat intrigued.  It got even more interesting when I found a &lt;a href=&quot;https://blog.vx.sk/archives/22-Updated-Tutorial-Debian-GNUkFreeBSD-in-a-FreeBSD-jail.html&quot;&gt;tutorial on setting up GNU/kFreeBSD in a jail&lt;/a&gt;.  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.&lt;/p&gt;
&lt;p&gt;I got it running fairly decently, but along the way ran into some small problems - and thought I&#039;d jot down what they were and what the fixes were.&lt;/p&gt;
&lt;h2&gt;FreeBSD Update&lt;/h2&gt;
&lt;p&gt;At first, I was using FreeBSD 8.2-RELEASE, and used &lt;code&gt;debootstrap&lt;/code&gt; to install Debian Squeeze, as the tutorial showed.  Once inside the jail, things sort of worked, but most commands, &lt;code&gt;aptitude&lt;/code&gt; especially, would die with: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;User defined signal 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It turns out you need a newer kernel than 8.2 to run kFreeBSD in a chroot, as is &lt;a href=&quot;https://wiki.debian.org/Debian_GNU/kFreeBSD_FAQ#Q._Can_I_run_Debian_GNU.2BAC8-kFreeBSD_in_a_chroot_under_FreeBSD.3F&quot;&gt;mentioned in the FAQ&lt;/a&gt;. I upgraded my FreeBSD kernel/world to 8.3-PRERELEASE (2012-02-22), and the &amp;quot;signal 1&amp;quot; problem went away.&lt;/p&gt;
&lt;h2&gt;Debian Update&lt;/h2&gt;
&lt;p&gt;The next problem was that &lt;code&gt;aptitude&lt;/code&gt; would still die, with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Uncaught exception: Unable to read from stdin: Operation not permitted&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After reading about &lt;a href=&quot;https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=472518,&quot;&gt;this bug&lt;/a&gt; in cwidget, it seemed an upgrade to Wheezy was needed to fix the problem - and sure enough that problem went away.&lt;/p&gt;
&lt;h2&gt;kbdcontrol and /dev/console&lt;/h2&gt;
&lt;p&gt;The upgrade to Wheezy didn&#039;t go entirely smoothly, mainly due to the &lt;code&gt;kbdcontrol&lt;/code&gt; package (required by &lt;code&gt;sysvinit&lt;/code&gt;) being unable to access &lt;code&gt;/dev/console&lt;/code&gt; in the jail.    I wasn&#039;t worried about keeping things in the jail isolated for security reasons, so I went ahead and added &lt;code&gt;/dev/console&lt;/code&gt; on-the-fly to the running jail by running outside the jail:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;devfs -m /jails/debian/dev rule add path &#039;console*&#039; unhide
devfs -m /jails/debian/dev rule applyset&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After that, the &lt;code&gt;kbdcontrol&lt;/code&gt; package was able to be upgraded, and I seem to have a Wheezy FreeBSD jail now.  Very cool.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: A &lt;a href=&quot;/blog/entries/debian-gnukfreebsd-freebsd-jail-part-2&quot;&gt;followup&lt;/a&gt; talks more about the actual file changes made to run as an ezjail&lt;/p&gt;</content>
</entry>
</feed>