<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Felipe Alfaro Solana &#187; NetBSD</title>
	<atom:link href="http://www.felipe-alfaro.org/blog/category/netbsd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.felipe-alfaro.org/blog</link>
	<description>A little bit of technology, security and networking with Linux, FreeBSD and Mac OS X, plus some personal opinions.</description>
	<lastBuildDate>Sun, 23 Oct 2011 16:46:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Compiling audio/mt-daapd under NetBSD with Zeroconf support</title>
		<link>http://www.felipe-alfaro.org/blog/2007/02/09/compiling-audiomt-daapd-under-netbsd-with-zeroconf-support/</link>
		<comments>http://www.felipe-alfaro.org/blog/2007/02/09/compiling-audiomt-daapd-under-netbsd-with-zeroconf-support/#comments</comments>
		<pubDate>Fri, 09 Feb 2007 01:02:26 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[iTunes]]></category>
		<category><![CDATA[NetBSD]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/2007/02/09/compiling-audiomt-daapd-under-netbsd-with-zeroconf-support/</guid>
		<description><![CDATA[NetBSD ports collection includes audio/mt-daapd, a nice and straightforward implementation of Apple&#8217;s DAAP protocol for streaming music to iTunes. The only problem is that audio/mt-daapd is not compiled with Zeroconf support by default. In NetBSD, net/howl provides an implementation of Apple&#8217;s Zeroconf (also known as Rendevous or Bonjour). In order to compile audio/mt-daapd under NetBSD [...]]]></description>
			<content:encoded><![CDATA[<p>NetBSD ports collection includes <code>audio/mt-daapd</code>, a nice and straightforward implementation of Apple&#8217;s DAAP protocol for streaming music to iTunes. The only problem is that <code>audio/mt-daapd</code> is not compiled with Zeroconf support by default. In NetBSD, <code>net/howl</code> provides an implementation of Apple&#8217;s Zeroconf (also known as Rendevous or Bonjour).</p>
<p>In order to compile <code>audio/mt-daapd</code> under NetBSD with Zeroconf support, I first had to compile and install <code>net/howl</code>:</p>
<div>
<pre>
# cd /usr/pkgsrc/net/howl
# make install
</pre>
</div>
<p>Once <code>net/howl</code> is installed, I had to modify the <code>Makefile</code> file for <code>audio/mt-daapd</code> such as that howl support is enabled. This involves passing <code>--enable-howl</code> to the <code>configure</code> script and pointing it to the non-standard directory where the howl include files are &#8212; <code>/usr/pkg/include/howl</code>.</p>
<p>So, I edited <code>/usr/pkgsrc/audio/mt-daapd/Makefile</code> and after the line that reads:</p>
<div>
<pre>
GNU_CONFIGURE=  yes
</pre>
</div>
<p>I inserted:</p>
<div>
<pre>
CONFIGURE_ARGS+= --enable-howl
CONFIGURE_ARGS+= --with-howl-includes=${LOCALBASE}/include/howl
</pre>
</div>
<p>Before the line that reads:</p>
<div>
<pre>
.include "../../mk/pthread.buildlink3.mk"
</pre>
</div>
<p>I added:</p>
<div>
<pre>
.include "../../net/howl/buildlink3.mk"
</pre>
</div>
<p>Then,</p>
<div>
<pre>
# cd /usr/pkgsrc/audio/mt-daapd
# make install
</pre>
</div>
<p>I had to make some changes in order to get <code>howl and </code><code>mt-daapd</code> start automatically during boot.</p>
<p>I added the following lines to <code>/etc/rc.conf</code>:</p>
<div>
<pre>
howl=YES
daapd=YES
daapd_flags="-c /etc/mt-daapd.conf"
</pre>
</div>
<p>Next, I copied <code>/usr/pkg/share/examples/mt-daapd/mt-daapd.conf</code> to <code>/etc/mt-daapd.conf</code> and customized it &#8212; for example, to change the server name, specified by the <code>servername</code> directive.</p>
<p>I also had to create the <code>/etc/rc.d/mt-daapd</code> rc script to get <code>mt-daapd</code> started automatically during boot. It looks like this:</p>
<div>
<pre>
#!/bin/sh
#
# $NetBSD: howl.sh,v 1.2 2006/01/01 18:27:53 tron Exp $
#

# PROVIDE: daapd
# REQUIRE: howl
# REQUIRE: NETWORKING

. /etc/rc.subr

name="daapd"
rcvar=$name
command="/usr/pkg/sbin/mt-daapd"
sig_stop=KILL

load_rc_config $name
run_rc_command "$1"
</pre>
</div>
<p>A sample configuration file that I&#8217;m using for <code>mt-daapd</code> &#8212; <code>/etc/mdaapd.conf</code> &#8212; looks like this:</p>
<div>
<pre>
web_root         /usr/pkg/share/mt-daapd/admin-root
port             3689
admin_pw         mt-daapd
db_dir           /var/cache/mt-daapd
mp3_dir          /mnt/mp3
servername       NetBSD
runas            mtdaapd
playlist         /usr/pkg/etc/mt-daapd.playlist
#password        mp3
extensions       .mp3,.m4a,.m4p
#logfile         /var/log/mt-daapd.log
#rescan_interval 300
# always_scan    0
# process_m3u    0
# scan_type      0
# compress       0
</pre>
</div>
<p>Finally, either start both <code>howl</code> and <code>mt-daapd</code>, or reboot:</p>
<div>
<pre>
# /etc/rc.d/howl start
# /etc/rc.d/mt-daapd start
</pre>
</div>
<p>To test whether <code>mt-daapd</code> is working you can run the following command as root under Mac OS X:</p>
<div>
<pre>
# mDNS -B _daap._tcp
</pre>
</div>
<p>or the following command on Linux:</p>
<div>
<pre>
# mDNSBrowse _daap._tcp
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2007/02/09/compiling-audiomt-daapd-under-netbsd-with-zeroconf-support/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NetBSD 3.1 as a domU/guest on Xen</title>
		<link>http://www.felipe-alfaro.org/blog/2007/02/04/netbsd-31-under-xen-303/</link>
		<comments>http://www.felipe-alfaro.org/blog/2007/02/04/netbsd-31-under-xen-303/#comments</comments>
		<pubDate>Sun, 04 Feb 2007 13:52:00 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[NetBSD]]></category>
		<category><![CDATA[XEN]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/2007/02/04/netbsd-31-under-xen-303/</guid>
		<description><![CDATA[Xen is one of the coolest pieces of software I have ever used. It allows me to partition my box into manageable pieces, for increased security and increased resource utilization. I have been playing extensively with Xen for more than a year and have also written some posts about it. NetBSD is a lean, mean, [...]]]></description>
			<content:encoded><![CDATA[<p>Xen is one of the coolest pieces of software I have ever used. It allows me to partition my box into manageable pieces, for increased security and increased resource utilization. I have been playing extensively with Xen for more than a year and have also written some posts about it.</p>
<p>NetBSD is a lean, mean, fast free, open source operating system and is nicely supported under Xen, has nice features like the PF packet filter and the pkgsrc ports-like collection and runs in nearly every single hardware architecture on earth. Because of this, I decided to run NetBSD 3.1 on Xen. NetBSD can run either as the privileged domain (called dom0) or as an unprivileged guest (called domU) domain. Since I was already running Linux under Xen as a domU, I am mostly interested in running NetBSD 3.1 as a domU guest on Xen. dom0 can be either Red Hat Enterprise Linux 5.0 or Fedora Core 6, but feel free to use any other Linux distribution as most of them are Xen-ready.</p>
<p>As far as I know, there are some restrictions between the Xen hypervisor + dom0 kernel and domU kernel:</p>
<ul>
<li>You cannot mix PAE-enabled and non-PAE kernels.
<p>For example, you cannot run a PAE-enabled dom0 kernel and/or PAE-enabled hypervisor and a non-PAE dom0/domU kernel.</p>
<p>This is currently a problem since Fedora Core 6 and Red Hat Enterprise Linux 5.0 both ship with a PAE-enabled Xen hypervisor and Xen-enabled kernels, but NetBSD does not currently ship a PAE-compatible, Xen-enabled kernel.
</li>
<li>You cannot mix 64-bit and 32-bit kernels.
<p>You cannot run a 64-bit Xen hypervisor and 64-bit dom0 kernel and a 32-bit domU kernel.
</li>
</ul>
<p>Since both Fedora Core 6 and Red Hat Enterprise Linux 5.0 ship by default with a PAE-enabled (36-bit addressable memory space) Xen hypervisor and dom0 Xen-enabled Linux kernel, the first thing that I had to do in order to run NetBSD 3.1 as domU under Xen was to recompile the Linux kernel and the Xen hypervisor with PAE support completely disabled. This is described next.</p>
<h2>Build Xen hypervisor and dom0 kernel without PAE</h2>
<p>You can skip to the next section if you already have a non-PAE, working Xen installation.</p>
<p>The first thing I had to do is to downl the SRPM (source RPM) for the latest Linux kernel, for example <a href="http://redhat.download.fedoraproject.org/pub/fedora/linux/core/updates/6/SRPMS/kernel-2.6.19-1.2895.fc6.src.rpm">kernel-2.6.19-1.2895.fc6.src.rpm</a>, then install it by running:</p>
<pre>
# rpm -i kernel-2.6.19-1.2895.fc6.src.rpm
</pre>
<p>In file <code>/usr/src/redhat/SPECS/kernel-2.6.spec</code> replace the following:</p>
<div>
<pre>
%ifarch i686
%define buildpae 1
# we build always xen HV with pae
%define xen_flags verbose=y crash_debug=y pae=y
%endif
</pre>
</div>
<p>with:</p>
<div>
<pre>
%ifarch i686
%define buildpae 0
# we build always xen HV with pae
%define xen_flags verbose=y crash_debug=y
%endif
</pre>
</div>
<p>This will cause the Xen hypervisor to be built without PAE support. Additionally, no PAE-enabled extra kernels will be built. The Xen kernel, however, uses its specific configuration file that has to be changed in order to disable PAE support. To disable PAE support for the Xen kernel, I reconfigured the kernel with no PAE support by running:</p>
<div>
<pre>
# rpmbuild -bp /usr/src/redhat/SPECS/kernel-2.6.spec
# cd /usr/src/redhat/BUILD/kernel-2.6.19/linux-2.6.19.i386
# cp configs/kernel-2.6.19-i686-xen.config .config
# make menuconfig
</pre>
</div>
<p>Make sure PAE is disabled by navigating to <code>Processor type and features</code>, then <code>High Memory Support</code> is set to either <code>off</code> or <code>4GB</code> (but not <code>64GB</code>).</p>
<p>Next, I copied the updated configuration file back to <code>/usr/src/redhat/SOURCES</code>, where it belongs. Also, we need to insert <code># i386</code> at the beginning of the file so that the RPM build process can derive the exact processor architecture from the config file when building the RPMs:</p>
<div>
<pre>
# cat &lt;(echo "# i386") .config &gt; ../../../SOURCES/kernel-2.6.19-i686-xen.config
</pre>
</div>
<p>The processor architecture is supplied to <code>make</code> during the build process in the form of <code>ARCH=i386</code>.</p>
<p>Now, let&#8217;s build the RPMs:</p>
<div>
<pre>
# rpmbuild -ba --target i686 ../../../SPECS/kernel-2.6.spec
</pre>
</div>
<p>We need to specify <code>i686</code> as the target architecture since Fedora and Red Hat don&#8217;t use <code>i386</code> anymore for kernels themselves &#8212; <code>i386</code> is now only used for some common RPMs like <code>kernel-headers</code>.</p>
<p>Once the RPMs have been built, check the files under <code>/usr/src/redhat/RPMS/i686</code>. At least there should be a file called <code>kernel-xen-2.6.19-1.2895.i686.rpm</code>. This RPM contains several files, but the ones that we are interested in are:</p>
<ul>
<li>/boot/config-2.6.19-1.2895xen
<p>Contains the kernel configuration. Make sure either <code>CONFIG_X86_PAE</code> is set to <code>n</code> or is undefined.</li>
<li>/boot/vmlinuz-2.6.19-1.2895xen
<p>The Linux Xen-enabled kernel.</li>
<li>/boot/xen.gz-2.6.19-1.2895
<p>The Xen hypervisor. In the most recent versions of Fedora Core and Red Hat Enterprise Linux, the Xen hypervisor and the Xen-enabled kernel are packaged in the same RPM. This is the right thing to do since both are tightly coupled.</li>
</ul>
<p>Install the new Xen kernel and hypervisor:</p>
<div>
<pre>
# rpm -ivh --force /usr/src/redhat/RPMS/i686/kernel-xen-2.6.19-1.2895.i686.rpm
</pre>
</div>
<p>Reboot:</p>
<div>
<pre>
# reboot
</pre>
</div>
<p>I assume the system will boot correctly and into the new Xen hypervisor and Xen-enabled Linux kernel. You can check that by running:</p>
<div>
<pre>
# uname -a
Linux xen 2.6.19-1.2895xen #1 SMP Sat Feb 3 16:56:34 CET 2007 i686 i686 i386 GNU/Linux
</pre>
</div>
<p>The next step is installing NetBSD 3.1 as a domU. This is covered next.</p>
<h2>Installing NetBSD 3.1</h2>
<p>The first step is preparing the Xen&#8217;s domU configuration file and its corresponding storage backend. Xen can use file-backed storage for a domU or block-backed storage (i.e. a disk partition or logical volume). Typically, block-backed storage is faster than file-backed storage, so I set up a 10GiB logical volume for NetBSD:</p>
<div>
<pre>
# lvcreate -n netbsd xen -L 10G
</pre>
</div>
<p>I also used NetBSD&#8217;s Internet-based installation since it&#8217;s the easiest way to get a working NetBSD installation and the NetBSD community have built Xen-enabled NetBSD kernels:</p>
<ul>
<li>netbsd-INSTALL_XEN3_DOMU
<p>A Xen-based, domU kernel used to install NetBSD.</li>
<li>netbsd-XEN3_DOMU
<p>A Xen-based, domU kernel used to run the installed system.</li>
</ul>
<p>Both files can be downloaded from <a href="ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-3.1/i386/binary/kernel">/pub/NetBSD/NetBSD-3.1/i386/binary/kernel</a>. Download and uncompress both of them:</p>
<div>
<pre>
# wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-3.1/i386/binary/kernel/netbsd-*XEN3_DOMU.gz
# zcat netbsd-INSTALL_XEN3_DOMU.gz > /boot/netbsd-INSTALL_XEN3_DOMU
# zcat netbsd-XEN3_DOMU.gz > /boot/netbsd-XEN3_DOMU
</pre>
</div>
<p>If you are running SELinux, you will need to relabel these files properly or <code>xm</code> will be unable to load them into memory:</p>
<div>
<pre>
# chcon root system_u:object_r:boot_t /boot/netbsd*
</pre>
</div>
<p>Next, create the Xen configuration file for NetBSD. In my case, it looked like this:</p>
<div>
<pre>
# cat /etc/xen/auto/netbsd
kernel = "/boot/netbsd-INSTALL_XEN3_DOMU"
memory = 256
name = "netbsd"
vif = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0' ]
disk = [ 'phy:/dev/xen/netbsd,hda,w' ]
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'
</pre>
</div>
<p>Now, we will install NetBSD by starting the domain:</p>
<div>
<pre>
# xm create -c /etc/xen/auto/netbsd
</pre>
</div>
<p>This will start the new domain and will attach to its console. You can follow the <a href="http://www.netbsd.org/guide/en/chap-exinst.html">Example Installation</a> NetBSD document to assist you in installing NetBSD and also <a href="http://wiki.xensource.com/xenwiki/NetBSDdomU">Xensource NetBSDdomU</a> Wiki page.</p>
<p>Once the installer has finished, do not reboot. At the end of the installation process, you&#8217;ll be brought back to the main install screen. Select <code>e: Utility menu</code>, then <code>a: Run /bin/sh</code>, then type the following at the shell:</p>
<div>
<pre>
mount /dev/xbd0a /mnt
cp -pR /dev/rxbd* /mnt/dev
cp -pR /dev/xbd* /mnt/dev
halt -p
</pre>
</div>
<p>This will copy the required special device files and shut down the guest. Now, you will have to modify the domain config file in order to use the standard NetBSD domU kernel, <code>/boot/netbsd-XEN3_DOMU</code>. Edit <code>/etc/xen/auto/netbsd</code> and replace:</p>
<div>
<pre>
kernel = "/boot/netbsd-INSTALL_XEN3_DOMU"
</pre>
</div>
<p>with:</p>
<div>
<pre>
kernel = "/boot/netbsd-XEN3_DOMU"
</pre>
</div>
<p>And boot the domain again:</p>
<div>
<pre>
# xm create -c /etc/xen/auto/netbsd
</pre>
</div>
<p>During boot, you will see some errors like:</p>
<p><code><br />
wsconscfg: /dev/ttyEcfg: Device not configured<br />
</code></p>
<p>This is due to the NetBSD guest only having access to one physical console. To kill those errors, edit <code>/etc/ttys</code> from within the NetBSD guest and turn off all terminals except <code>"console"</code>, like:</p>
<div>
<pre>
console "/usr/libexec/getty Pc"         vt100   on  secure
ttyE0   "/usr/libexec/getty Pc"         vt220   off secure
ttyE1   "/usr/libexec/getty Pc"         vt220   off secure
ttyE2   "/usr/libexec/getty Pc"         vt220   off secure
ttyE3   "/usr/libexec/getty Pc"         vt220   off secure
...
</pre>
</div>
<p>Also, comment out all screens in <code>/etc/wscons.conf</code>:</p>
<div>
<pre>
#screen 0       -       vt100
#screen 1       -       vt100
#screen 2       -       vt100
#screen 3       -       vt100
#screen 4       -       -
#screen 4       80x25bf vt100
</pre>
</div>
<p>That&#8217;s all. Now we have a fully functional NetBSD 3.1 domU guest running on Xen <img src='http://www.felipe-alfaro.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h2>References</h2>
<p>The information and instructions on this post are based on:</p>
<ol>
<li><a href="http://wiki.xensource.com/xenwiki/NetBSDdomU">NetBSDdomU</a> &#8212; How to install NetBSD as a domU on a Linux host.</li>
<li><a href="http://www.netbsd.org/guide/en/chap-exinst.html">Example Installation</a> &#8212; NetBSD example installation.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2007/02/04/netbsd-31-under-xen-303/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

