<?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>pixelchaos.net &#187; HowTo</title>
	<atom:link href="http://www.pixelchaos.net/category/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pixelchaos.net</link>
	<description>random bits for your terminal</description>
	<lastBuildDate>Tue, 29 Sep 2009 11:38:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Bacula 3.0.1 for Mac OS X</title>
		<link>http://www.pixelchaos.net/2009/07/14/bacula-3-0-1-for-mac-os-x/</link>
		<comments>http://www.pixelchaos.net/2009/07/14/bacula-3-0-1-for-mac-os-x/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 12:56:55 +0000</pubDate>
		<dc:creator>jcl</dc:creator>
				<category><![CDATA[Bacula]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://www.pixelchaos.net/?p=168</guid>
		<description><![CDATA[I wont be doing a build of Bacula for Mac OS X again any time soon, if at all, for a number of reasons;

I no longer have access to Mac OS X 10.4 running on an Intel chip
I am actively transitioning to BackupPC

Below youll find the method I have been using to construct all the [...]]]></description>
			<content:encoded><![CDATA[<p>I wont be doing a build of Bacula for Mac OS X again any time soon, if at all, for a number of reasons;</p>
<ol>
<li>I no longer have access to Mac OS X 10.4 running on an Intel chip</li>
<li>I am actively transitioning to BackupPC</li>
</ol>
<p>Below youll find the method I have been using to construct all the .pkg installers youll find on this site. If you have any questions about the process please post them in the comments.</p>
<p><span id="more-168"></span></p>
<p>You will need at least three installations of Mac OS X &#8211; one 10.4 on PPC, one 10.4 on Intel, and one 10.5 on any architecture. On each 10.4 installation, download the bacula source code, decompress it, and run the following command to compile it in a way that plays nice with the rest of Mac OS X</p>
<pre class="brush: plain;">
./configure --prefix=/usr/local --sysconfdir=/usr/local/etc \
--mandir=/usr/local/share/man --enable-client-only \
--with-openssl --with-tcp-wrappers --disable-dependency-tracking \
--with-working-dir=/var/bacula/working
make
</pre>
<p>With that done, copy the compiled binaries from each architecture to your Mac OS X 10.5 installation to build the pkg installer. The files in question are;</p>
<ul>
<li>src/filed/bacula-fd</li>
<li>src/filed/bacula-fd.conf</li>
<li>src/console/bconsole</li>
<li>src/console/bconsole.conf</li>
</ul>
<p>I use the architecture type to give them unique names&#8230; bacula-fd-ppc and bacula-fd-intel for example. After thats done, use lipo to combine the two binaries into one fat multi-arch binary</p>
<pre class="brush: plain;">
lipo -create bacula-fd-intel bacula-fd-ppc -output bacula-fd
</pre>
<p>Now do the same for bconsole</p>
<pre class="brush: plain;">
lipo -create bconsole-intel bconsole-ppc -output bconsole
</pre>
<p>Having done that you now need to set up a mock directory structure to place the binaries into. You can then use PackageMaker on Mac OS X to build the pkg installer from that mock directory. My directory looks like this;</p>
<pre class="brush: plain;">
Library
Library/LaunchDaemons
Library/LaunchDaemons/bacula-fd.plist
usr
usr/local
usr/local/bin
usr/local/bin/bconsole
usr/local/etc
usr/local/etc/bacula-fd.conf
usr/local/etc/bconsole.conf
usr/local/sbin
usr/local/sbin/bacula-fd
usr/local/share
usr/local/share/man
usr/local/share/man/man8
usr/local/share/man/man8/bacula-fd.8.gz
usr/local/share/man/man8/bconsole.8.gz
var
var/bacula
var/bacula/working
</pre>
<p>You can see where I&#8217;ve placed bacula-fd and bconsole as well as their conf files. There are some gzipped man pages in there too, which you can grab out of the compiled source tree and gzip manually. Finally there is a .plist file which is required to make auto startup/shutdown of bacula-fd happen on Mac OS X.</p>
<p>The last important bit to note is that I use some modified .conf files which have special placeholders for host names. I then use pre-inst and post-inst scripts in PackageMaker to look for previous versions of packages, insert the current hostname into the .conf files, etc. I have included my source tree and PackageMaker files and scripts below for the last version I released (2.4.4) for your reference.</p>
<p>After all the above is done and the directory structure is all set up you should be able to just fire up PackageMaker, change a few variables in it (set permissions, set version numbers, make sure proper pre and post-inst scripts are being used, etc.) and then build the pkg installer.</p>
<p>Enjoy :)</p>
<p><a href='http://www.pixelchaos.net/wp-content/uploads/2009/07/bacula_244_macosx_source.zip' >bacula_244_macosx_source.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelchaos.net/2009/07/14/bacula-3-0-1-for-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>list all files with resource forks on Mac OS X</title>
		<link>http://www.pixelchaos.net/2009/06/06/list-all-files-with-resource-forks-on-mac-os-x/</link>
		<comments>http://www.pixelchaos.net/2009/06/06/list-all-files-with-resource-forks-on-mac-os-x/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 11:01:53 +0000</pubDate>
		<dc:creator>jcl</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://www.pixelchaos.net/?p=166</guid>
		<description><![CDATA[This is mostly just a note to myself. If you ever have the need to find all files that contain HFS resource forks on Mac OS X, just use this bit of find magic:
find . -type f -exec test -s {}/..namedfork/rsrc \; -print
]]></description>
			<content:encoded><![CDATA[<p>This is mostly just a note to myself. If you ever have the need to find all files that contain HFS resource forks on Mac OS X, just use this bit of find magic:</p>
<pre class="brush: bash;">find . -type f -exec test -s {}/..namedfork/rsrc \; -print</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelchaos.net/2009/06/06/list-all-files-with-resource-forks-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>working with initrd.img files</title>
		<link>http://www.pixelchaos.net/2009/05/28/working-with-initrdimg-files/</link>
		<comments>http://www.pixelchaos.net/2009/05/28/working-with-initrdimg-files/#comments</comments>
		<pubDate>Thu, 28 May 2009 13:41:56 +0000</pubDate>
		<dc:creator>jcl</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.pixelchaos.net/?p=104</guid>
		<description><![CDATA[You may have occasion to edit the contents of an initrd.img file. If so, here is how:
Extract the contents of the image
gunzip &#60; your-initrd.img &#124; cpio -i --make-directories
Now make your edits and then repackage the initrd
find . &#124; cpio -o -H newc &#124; gzip -9 &#62; your-new-initrd.img
]]></description>
			<content:encoded><![CDATA[<p>You may have occasion to edit the contents of an initrd.img file. If so, here is how:</p>
<p>Extract the contents of the image</p>
<pre class="brush: plain;">gunzip &lt; your-initrd.img | cpio -i --make-directories</pre>
<p>Now make your edits and then repackage the initrd</p>
<pre class="brush: plain;">find . | cpio -o -H newc | gzip -9 &gt; your-new-initrd.img</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelchaos.net/2009/05/28/working-with-initrdimg-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>install debian directly onto an AoE root filesystem</title>
		<link>http://www.pixelchaos.net/2009/05/25/install-debian-directly-onto-an-aoe-root-filesystem/</link>
		<comments>http://www.pixelchaos.net/2009/05/25/install-debian-directly-onto-an-aoe-root-filesystem/#comments</comments>
		<pubDate>Tue, 26 May 2009 02:23:16 +0000</pubDate>
		<dc:creator>jcl</dc:creator>
				<category><![CDATA[AoE]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[HowTo]]></category>

		<guid isPermaLink="false">http://www.pixelchaos.net/?p=131</guid>
		<description><![CDATA[Something that just about no one out there seems to be doing (yet) is trying to install Debian directly onto network block devices. The Debian installer doesnt support it (yet), grub doesnt support it (usually), and its just generally not an easy thing to do.
Now, there are quite a few ways around this problem. You [...]]]></description>
			<content:encoded><![CDATA[<p>Something that just about no one out there seems to be doing (yet) is trying to install Debian directly onto network block devices. The Debian installer doesnt support it (yet), grub doesnt support it (usually), and its just generally not an easy thing to do.</p>
<p>Now, there are quite a few ways around this problem. You can install to a &#8216;real&#8217; computer and migrate the installation to a network block device. You can use debootstrap in place of the actual Debian installation system. You can use a combination of these two methods, NFS root filesystems, TFTP hacks, etc. All of these solutions are lacking in my opinion. I want to run the &#8216;real&#8217; debian installer against a network block device and boot my physical hardware using only the built in PXE booting capability of the BIOS.</p>
<p>Taking all these issues as a personal challenge, I&#8217;ve outlined below how to go about using the regular old Debian Lenny installer directly against an AoE block device.<br />
<span id="more-131"></span></p>
<p>First of all, youll need the full installer disc 1 for Lenny. We need one of the .deb&#8217;s thats on that CD. The netinst or businesscard installers will not work with the steps below. (NOTE: If you want to be really creative, I suppose you could download the .deb from within the installer system via wget or even get it before hand and put it on a thumb drive or something&#8230;)</p>
<p>1. Boot the lenny install cd just to the point that /cdrom is mounted. For me, that was the &#8220;Configure the network&#8221; prompt.</p>
<p>2. Switch to a virtual terminal by hitting alt-f2.</p>
<p>3. Unpack the .deb that contains the aoe kernel module</p>
<pre class="brush: plain;">udpkg --unpack /cdrom/pool/main/l/linux-2.6/linux-image-2.6.26-2-486_2.6.26-15_i386.deb</pre>
<p>4. Now load the kernel module we just unpacked</p>
<pre class="brush: plain;">insmod /lib/modules/2.6.26-2-486/kernel/drivers/block/aoe/aoe.ko</pre>
<p>5. Now we create a symlink to the AoE block device. Its important that we use a symlink at this point in the process since it will cause the installer to set up a lot of paths in the correct fashion.</p>
<pre class="brush: plain;">ln -s /dev/etherd/eX.X /dev/sda</pre>
<p>6. Hit alt-f1 and continue with installation until the point that grub fails to install, then switch back to terminal 2.</p>
<p>7. Now chroot into the mostly installed system</p>
<pre class="brush: plain;">chroot /target</pre>
<p>8. Install the aoetools package</p>
<pre class="brush: plain;">apt-get -y install aoetools</pre>
<p>9. Listed below are two scripts that youll need to get into your chroot environment. They are used to build a new custom initrd image. I find it easiest to put them on a webserver somewhere and wget them.</p>
<pre class="brush: plain;">wget http://www.pixelchaos.net/aoe/hooks/aoetools -O /etc/initramfs-tools/hooks/aoetools
chmod 755 /etc/initramfs-tools/hooks/aoetools
wget http://www.pixelchaos.net/aoe/scripts/local-top/aoetools -O /etc/initramfs-tools/scripts/local-top/aoetools
chmod 755 /etc/initramfs-tools/scripts/local-top/aoetools</pre>
<p>10. Now we regenerate the initrd image</p>
<pre class="brush: plain;">update-initramfs -u -k all</pre>
<p>11. Now that all the above is done, we can manually install grub &#8211; which the debian installer was unable to do.</p>
<pre class="brush: plain;">apt-get -y install grub
mkdir /boot/grub
cp -r /usr/lib/grub/i386-pc/. /boot/grub</pre>
<p>12. Now we can remove our old symlink and create some hard links instead. This is required to allow grub to modify the MBR of our block device.</p>
<pre class="brush: plain;">rm /dev/sda
ln /dev/etherd/eX.X /dev/sda
ln /dev/etherd/eX.Xp1 /dev/sda1
ln /dev/etherd/eX.Xp5 /dev/sda5</pre>
<p>13. Now update grubs device.map</p>
<pre class="brush: plain;">echo &quot;(hd0) /dev/sda&quot; &gt; /boot/grub/device.map</pre>
<p>14. Now run &#8220;grub&#8221; and issue the following commands</p>
<pre class="brush: plain;">device (hd0) /dev/sda
root (hd0,0)
setup (hd0)</pre>
<p>15. Now issue the &#8220;update-grub&#8221; command which will generate /boot/grub/menu.lst for the first time</p>
<p>16. Remember that grub has been using the hard link to /dev/sda this whole time. Change the root=/dev/sda1 line in /boot/grub/menu.lst to root=/dev/etherd/eX.Xp1, then issue the &#8220;update-grub&#8221; command again to commit the change to the boot stanzas.</p>
<p>17. For the sake of completeness, lets change grubs device.map back to its original contents.</p>
<pre class="brush: plain;">echo &quot;(hd0) /dev/etherd/eX.X&quot; &gt; /boot/grub/device.map</pre>
<p>18. Get out of the chroot environment by issuing the &#8220;exit&#8221; command.</p>
<p>19. Go back to installer and choose &#8220;Continue without boot loader&#8221; to finish the installation and reboot the computer.</p>
<p>Thats it! Assuming you have properly set up a gPXE boot environment everything should &#8220;just work&#8221;. Setting up gPXE is outside the scope of this document but some good notes are available on the etherboot web site (see the links below).</p>
<p>Please note that there is one caveat to this whole process. Grub does not support installation onto AoE block devices. There very well may be some issues the next time you try to upgrade your kernel if some post-inst script calls grub-install against your root device. Keep that in mind.</p>
<p><strong>aoe-hooks script</strong></p>
<pre class="brush: bash;">
#!/bin/sh

set  -e

PREREQ=&quot;&quot;

prereqs()
{
echo &quot;$PREREQ&quot;
}

case $1 in
prereqs)
prereqs
exit 0
;;
esac

. /usr/share/initramfs-tools/hook-functions

[ -x /sbin/aoe-discover ] &amp;&amp; copy_exec /sbin/aoe-discover /sbin
manual_add_modules aoe
</pre>
<p><strong>aoe-local-top script</strong></p>
<pre class="brush: bash;">
#!/bin/sh

set -e

PREREQ=&quot;udev&quot;

prereqs()
{
echo &quot;$PREREQ&quot;
}

case $1 in
prereqs)
prereqs
exit 0
;;
esac

case $ROOT in
/dev/etherd/e*)
INTERFACES=`sed -ne '/eth.*:/{s/:.*$//;p;}' &lt; /proc/net/dev`
for i in $INTERFACES; do
echo Bringing up interface $i for AoE
ifconfig $i up
done
# Make sure udev has processed all events from adding the NIC
# modules before loading aoe
[ -x /sbin/udevsettle ] &amp;&amp; /sbin/udevsettle --timeout=30
modprobe aoe
# Wait until aoe device files have been generated.
[ -x /sbin/udevsettle ] &amp;&amp; /sbin/udevsettle --timeout=30
aoe-discover
;;
esac
</pre>
<p><strong>references</strong><br />
<a href="http://maht0x0r.blogspot.com/2009/03/installing-debian-5-for-migration-to.html" target="_blank">http://maht0&#215;0r.blogspot.com/2009/03/installing-debian-5-for-migration-to.html</a><br />
<a href="http://www.etherboot.org/wiki/sanboot/debian_and_ubuntu" target="_blank">http://www.etherboot.org/wiki/sanboot/debian_and_ubuntu</a><br />
<a href="http://mike.neir.org/wiki/articles/AoE_Root_Fedora" target="_blank">http://mike.neir.org/wiki/articles/AoE_Root_Fedora</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelchaos.net/2009/05/25/install-debian-directly-onto-an-aoe-root-filesystem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>openais: an alternative to clvm with cman</title>
		<link>http://www.pixelchaos.net/2009/04/23/openais-an-alternative-to-clvm-with-cman/</link>
		<comments>http://www.pixelchaos.net/2009/04/23/openais-an-alternative-to-clvm-with-cman/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 17:24:29 +0000</pubDate>
		<dc:creator>jcl</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Xen]]></category>

		<guid isPermaLink="false">http://www.pixelchaos.net/?p=106</guid>
		<description><![CDATA[I&#8217;ve been battling lately with a lot of problems with cman, part of Red Hat Cluster Suite. Specifically, the fencing tool (fenced) is pretty much junk when you try to start using it with Xen dom0&#8217;s. After much searching and gnashing of teeth I happened upon this mailing list post. The promise there is that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been battling lately with a lot of problems with cman, part of Red Hat Cluster Suite. Specifically, the fencing tool (fenced) is pretty much junk when you try to start using it with Xen dom0&#8217;s. After much searching and gnashing of teeth I happened upon <a href="http://xen.markmail.org/message/xrrvmcl7bq6p4pvk?q=clvm+openais">this</a> mailing list post. The promise there is that you could take clvm and compile it against openais and get a cluster aware LVM which doesnt require the rest of Red Hat Cluster Suite (and its crappy documentation, crappy fencing, and general all around crappiness). A little more searching turned up <a href="http://h2o.glou.fr/post/2009/04/20/clvm-openais-on-Debian/Lenny">this</a> web site from Olivier Le Cam which pretty much did 90% of the work for me.</p>
<p>After some testing I&#8217;m happy to say it appears to work smashingly. What follows is a somewhat more complete version of how to achieve the same results on Debian Lenny. Enjoy :)</p>
<p><span id="more-106"></span><br />
The first thing that needs to be done is to get the debian sources for clvm and modify then to use openais. After that we will recompile new packages from that source, then set up openais on our cluster nodes.</p>
<p>Install all the dependencies we need to compile clvm</p>
<pre class="brush: plain;">
root@host:~# apt-get build-dep clvm
root@host:~# apt-get install libopenais-dev
</pre>
<p>Now download the source files and cd into our working directory</p>
<pre class="brush: plain;">
root@host:~# cd /usr/src/
root@host:/usr/src# apt-get source clvm
root@host:/usr/src# cd lvm2-2.02.39
</pre>
<p>Now we&#8217;ll modify a few files in the source:</p>
<ul>
<li> The first is debian/clvm.init. You&#8217;ll need to remove any references to cman or cluster.conf. You can download an already edited version <a href='http://www.pixelchaos.net/wp-content/uploads/2009/04/clvm.init'>here</a>.</li>
<li>The next is debian/control. Modify the dependies (lvm2 without the version number, openais in place of cman) and modify the comments accordingly. A pre-edited version is <a href='http://www.pixelchaos.net/wp-content/uploads/2009/04/control'>here</a>.</li>
<li> The last file is debian/rules. Replace cman by openais in the configure options, and add the PATH where to find the openais libs. Again, a pre-made version is <a href='http://www.pixelchaos.net/wp-content/uploads/2009/04/rules'>here</a>.</li>
</ul>
<p>For clarities sake, here is the actual code block from debian/rules:</p>
<pre class="brush: plain;">
$(STAMPS_DIR)/setup-deb: SOURCE_DIR = $(BUILD_DIR)/source
$(STAMPS_DIR)/setup-deb: DIR = $(BUILD_DIR)/build-deb
$(STAMPS_DIR)/setup-deb: $(STAMPS_DIR)/source
        rm -rf $(DIR)
        cp -al $(SOURCE_DIR) $(DIR)
        cd $(DIR); \
        ./configure CFLAGS=&quot;$(CFLAGS)&quot; \
		LDFLAGS=&quot;-L/usr/lib/openais&quot; \
                $(CONFIGURE_FLAGS) \
                --with-optimisation=&quot;&quot; \
                --with-clvmd=openais \
                --enable-readline
        touch $@
</pre>
<p>The last thing to do is update the internal version number of the clvm package and add some comments to the changelog:</p>
<pre class="brush: plain;">
root@host:/usr/src/lm2-2.02.39# dch -i
</pre>
<p>Now go ahead and compile the package:</p>
<pre class="brush: plain;">
root@host:/usr/src/lm2-2.02.39# dpkg-buildpackage -rfakeroot -uc -b
</pre>
<p>After the compliation completes you should have some shiny new .deb files in /usr/src. The one we are interested in is clvm_2.02.39-7.1_i386.deb (the actual version of yours may vary depending on what you put in the debian changelog in the previous step).</p>
<p>So now that weve got our custom version of clvm compiled, its time to move on the cluster nodes. On each node in the cluster, do the following&#8230;</p>
<p>Install openais and add a user for it:</p>
<pre class="brush: plain;">
root@node:~# apt-get install openais
root@node:~# mkdir -p /etc/ais
root@node:~# adduser --no-create-home --disabled-password --disabled-login --gecos openAIS ais
</pre>
<p>Now create the following config in /etc/ais/openais.conf. This is the most basic config you can have. All you need to do is set 192.168.1.0 to be your actual network address.</p>
<pre class="brush: plain;">
totem {
        version: 2
        secauth: off
        threads: 0
        interface {
                ringnumber: 0
                bindnetaddr: 192.168.1.0
                mcastaddr: 226.94.1.1
                mcastport: 5405
        }
}
</pre>
<p>openais does not include a proper debian init sript so you can download one <a href="http://www.pixelchaos.net/wp-content/uploads/2009/04/openais.init">here</a> and save it as /etc/init.d/openais. After that is done, add it to the proper runlevels by issuing:</p>
<pre class="brush: plain;">
root@node:~# update-rc.d openais start 62 S . start 50 0 6 .
</pre>
<p>Now we can install our custom deb and turn on LVM clustering</p>
<pre class="brush: plain;">
root@node:~# dpkg -i clvm_2.02.39-7.1_i386.deb
root@node:~# sed -i 's/^    locking_type = 1$/    locking_type = 3/' /etc/lvm/lvm.conf
</pre>
<p>Thats it! Reboot your cluster nodes and they should all be cluster aware now :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelchaos.net/2009/04/23/openais-an-alternative-to-clvm-with-cman/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>diskless booting with PXE and NFS</title>
		<link>http://www.pixelchaos.net/2009/02/15/diskless-booting-with-pxe-and-nfs/</link>
		<comments>http://www.pixelchaos.net/2009/02/15/diskless-booting-with-pxe-and-nfs/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 15:10:42 +0000</pubDate>
		<dc:creator>jcl</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://www.pixelchaos.net/?p=89</guid>
		<description><![CDATA[For a long time now I&#8217;ve wanted to set up all my mythfrontends to be diskless nodes that boot via PXE using an NFS share as their root filesystem. I finally got around to doing this. I was even able to just migrate my existing installations directly into the PXE boot environment. Here is how [...]]]></description>
			<content:encoded><![CDATA[<p>For a long time now I&#8217;ve wanted to set up all my mythfrontends to be diskless nodes that boot via PXE using an NFS share as their root filesystem. I finally got around to doing this. I was even able to just migrate my existing installations directly into the PXE boot environment. Here is how I accomplished it&#8230;</p>
<p><span id="more-89"></span></p>
<p>The first thing youll need is a TFTP server. This will serve out the kernel and initrd images to clients on the network.</p>
<pre class="brush: plain;">
root@pxe:~$ apt-get install tftpd-hpa
</pre>
<p>That will install a good tftp server daemon and create the tftp root for you in /var/lib/tftpboot. Some HOWTO&#8217;s on the Internet suggest installing the syslinux package as well which provides a needed file (pxelinux.0). I prefer to download the entire netboot environment for debian since this will also provide a network bootable installer for Debian on top of the other goodness we are creating today.</p>
<pre class="brush: plain;">
root@pxe:~$ cd /var/lib/tftpboot
root@pxe:~$ wget http://ftp.debian.org/debian/dists/lenny/main/installer-i386/current/images/netboot/netboot.tar.gz
root@pxe:~$ tar xzvf netboot.tar.gz
</pre>
<p>The kernel and initrd you are going to use to boot the mythbox must reside on the TFTP server. Furthermore, the initrd must be updated to support NFS root. On the mythbox I was migrating to the NFS root, it looked like this:</p>
<pre class="brush: plain;">
root@mythbox:~$ sed -i 's/BOOT=local/BOOT=nfs/'  /etc/initramfs-tools/initramfs.conf
root@mythbox:~$ /usr/sbin/mkinitramfs -o /boot/initrd.img-2.6.26-1-686_netboot
</pre>
<p>Now just copy the /boot/vmlinuz-2.6.26-1-686 and /boot/initrd.img-2.6.26-1-686_netboot to /var/lib/tftpboot/ on the TFTP server.</p>
<p>Last step for the TFTP server is to create a config file for our mythbox. If you dont create one specifically for it, it will instead boot the network installer as mentioned above. Create the file /var/lib/tftpboot/pxelinux.cfg/01-$(hardware ethernet address). Including the hardware address in the file name binds that config to the particular workstation we are working on today. In my case, the file name is 01-00-19-db-4a-6a-0e.</p>
<pre class="brush: plain;">
LABEL linux
KERNEL vmlinuz-2.6.26-1-686
APPEND root=/dev/nfs initrd=initrd.img-2.6.26-1-686_netboot nfsroot=192.168.1.108:/srv/nfs/mythbox.pixelchaos.net ip=dhcp rw
</pre>
<p>Now that our TFTP server is up and running we will next need to configure a DHCP server to provide IP addresses to netboot clients, as well as point them to the TFTP server to continue the boot process.</p>
<pre class="brush: plain;">
root@dhcp:~$ apt-get install dhcp3-server
</pre>
<p>That will install the DHCP service for you. Now we just need to add one little section to /etc/dhcp3/dhcpd.conf for the workstation we are going to netboot.</p>
<pre class="brush: plain;">
host mythbox {
hardware ethernet 00:19:db:4a:6a:0e;
fixed-address mythbox.pixelchaos.net;
filename &quot;pxelinux.0&quot;;
next-server 192.168.1.115;
}
</pre>
<p>host mythbox: mythbox is just the descriptive name for this configuration block .You can use any name you like.<br />
hardware ethernet 00:19:db:4a:6a:0e: This is the hardware ethernet address of the workstation we are netbooting.<br />
fixed-address mythbox.pixelchaos.net: This tells the DHCP server what address to assign the mythbox. You can use a FQDN (if its resolvable!) or an IP address.<br />
filename &#8220;pxelinux.0&#8243;: This is the PXE boot loader file that we installed onto our TFTP server earlier.<br />
next-server 192.168.1.115: This is the IP address of our TFTP server. It tells the mythbox where the &#8220;next server&#8221; is after it gets its IP address from the DHCP server. The &#8220;next server&#8221; can be any machine on the network. It can even be the same one running DHCP.</p>
<p>Once all that is done, restart your DHCP server.</p>
<pre class="brush: plain;">
root@dhcp:~$ /etc/init.d/dhcp3-server restart
</pre>
<p>Now for the third piece of the puzzle, our NFS root filesystem. You&#8217;ll first need to create a directory to share.</p>
<pre class="brush: plain;">
root@nfs:~$ mkdir /srv/nfs/mythbox.pixelchaos.net
</pre>
<p>Now add that directory to /etc/exports so that it gets shared via NFS with this line:</p>
<pre class="brush: plain;">
/srv/nfs/mythbox.pixelchaos.net mythbox(rw,async,no_root_squash)
</pre>
<p>The rw, async, and no_root_squash options are important. Dont omit them. At this point we can reload all our NFS exports to active this new share point.</p>
<pre class="brush: plain;">
root@nfs:~$ exportfs -rv
</pre>
<p>At this point the entire TFTP, DHCP, and NFS parts of the environment are ready to go. Now we will migrate our existing installation of Linux from the mythbox onto its new nfsroot. First we make a directory to mount the NFS share on and then mount it.</p>
<pre class="brush: plain;">
root@mythbox:~$ mkdir /mnt/nfs
root@mythbox:~$ mount -t nfs -o nolock 192.168.1.108:/srv/nfs/mythbox.pixelchaos.net /mnt/nfs
</pre>
<p>Now we run a cp command on every locally mounted partition, as well as /dev. On my mythbox it looked like this:</p>
<pre class="brush: plain;">
root@mythbox:~$ cp -axv /. /mnt/nfs/.
root@mythbox:~$ cp -axv /boot/. /mnt/nfs/boot/.
root@mythbox:~$ cp -axv /home/. /mnt/nfs/home/.
root@mythbox:~$ cp -axv /dev/. /mnt/nfs/dev/.
</pre>
<p>The last thing to do is edit two files that we copied up to /mnt/nfs. The first is /mnt/nfs/etc/network/interfaces. You&#8217;ll need to remove any lines that bring the interface up automatically. You want to remove anything like &#8220;allow-hotplug eth0&#8243; and just leave a single line like &#8220;iface eth0 inet dhcp&#8221;. The network interface will have already been brought up by netboot normally and leaving in any &#8220;hotplug&#8221; or &#8220;auto&#8221; lines will bring it up again, which has the effect of destroying it.</p>
<p>Now we remove all the old filesystems from /mnt/nfs/etc/fstab so that it looks like this:</p>
<pre class="brush: plain;">
# /etc/fstab: static file system information.
#
# &lt;file system&gt; 		&lt;mount point&gt;   	&lt;type&gt;  &lt;options&gt;       &lt;dump&gt;  &lt;pass&gt;
/dev/nfs        /               nfs     defaults 0 0
none            /tmp            tmpfs   defaults 0 0
none            /var/run        tmpfs   defaults 0 0
none            /var/lock       tmpfs   defaults 0 0
none            /var/tmp        tmpfs   defaults 0 0
none            /media          tmpfs   defaults 0 0
</pre>
<p>That should be it. Now just set the mythbox to use network booting in its BIOS and reboot.</p>
<p>Cool, huh? :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelchaos.net/2009/02/15/diskless-booting-with-pxe-and-nfs/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Prune old mythtv channels</title>
		<link>http://www.pixelchaos.net/2008/10/12/prune-old-mythtv-channels/</link>
		<comments>http://www.pixelchaos.net/2008/10/12/prune-old-mythtv-channels/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 00:19:05 +0000</pubDate>
		<dc:creator>jcl</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[MythTV]]></category>

		<guid isPermaLink="false">http://www.pixelchaos.net/?p=73</guid>
		<description><![CDATA[Looking for a way to bulk remove channels that I&#8217;ve delselected in my channel lineup at Schedules Direct, I happened upon this blog post. Seems to work great :)
For the impatient, the important bit is this:
DELETE channel,program FROM channel NATURAL LEFT JOIN program WHERE program.title IS NULL;
]]></description>
			<content:encoded><![CDATA[<p>Looking for a way to bulk remove channels that I&#8217;ve delselected in my channel lineup at Schedules Direct, I happened upon <a title="this blog post" href="http://www.ilikelinux.com/tips-and-howtos/tips-for-using-mysql-with-mythtv/trackback" target="_blank">this blog post</a>. Seems to work great :)</p>
<p>For the impatient, the important bit is this:</p>
<p><code>DELETE channel,program FROM channel NATURAL LEFT JOIN program WHERE program.title IS NULL;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelchaos.net/2008/10/12/prune-old-mythtv-channels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to mount partitioned disk image files</title>
		<link>http://www.pixelchaos.net/2008/10/01/how-to-mount-partitioned-disk-image-files/</link>
		<comments>http://www.pixelchaos.net/2008/10/01/how-to-mount-partitioned-disk-image-files/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 18:41:33 +0000</pubDate>
		<dc:creator>jcl</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.pixelchaos.net/?p=72</guid>
		<description><![CDATA[Mounting unpartitioned disk image files in Linux is easy. You just execute &#8216;mount -o loop disk.img /mnt&#8217; right?
Well, if your disk image file happens to contain partitions its a little bit trickier. Here is what you need to do:

First you attach the disk image to the first available loopback device
losetup -f -v disk.img
Next, we get [...]]]></description>
			<content:encoded><![CDATA[<p>Mounting unpartitioned disk image files in Linux is easy. You just execute &#8216;mount -o loop disk.img /mnt&#8217; right?</p>
<p>Well, if your disk image file happens to contain partitions its a little bit trickier. Here is what you need to do:</p>
<p><span id="more-72"></span></p>
<p>First you attach the disk image to the first available loopback device<br />
<code style="bash">losetup -f -v disk.img</code></p>
<p>Next, we get a listing of the partition table it contains:</p>
<p><code style="bash">fdisk -ul /dev/loop0</p>
<p>Disk /dev/loop0: 4294 MB, 4294967296 bytes<br />
133 heads, 62 sectors/track, 1017 cylinders, total 8388608 sectors<br />
Units = sectors of 1 * 512 = 512 bytes</p>
<p>      Device Boot      Start         End      Blocks   Id  System<br />
/dev/loop0p1              62     7998619     3999279   83  Linux<br />
/dev/loop0p2         7998620     8386181      193781   82  Linux swap / Solaris</code></p>
<p>Now for the juicy part. You attach one the partitions contained in the disk image to yet another loopback device by specifying the offset of the partition.</p>
<p>The -o option to losetup tells it the number of bytes to skip at the beginning of the file. To get that number, you multiply the number of bytes per unit (in this case, 512) by the &#8216;Start&#8221; value of the parititon (in this case, 62). So our -o value will be 31744.</p>
<p><code>losetup -o 31744 -f -v /dev/loop0<br />
Loop device is /dev/loop2</code></p>
<p>Looks good so far. Now mount it.</p>
<p><code>mount /dev/loop2 /mnt</code></p>
<p>Thats it. You should now be able to get at all the files on that partition.</p>
<p><strong>EDIT 2009-01-13</strong><br />
Since writing this I have discovered that you can supply the ‘offset’ argument to mount directly and bypass the entire process of using loopback devices…<br />
<code><br />
fdisk -ul disk.img # to get your offset value as noted above<br />
mount -o loop,offset=31744 disk.img /mnt # to mount a given partition on /mnt<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelchaos.net/2008/10/01/how-to-mount-partitioned-disk-image-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Set up a bluetooth keyboard in Debian Etch</title>
		<link>http://www.pixelchaos.net/2008/09/26/set-up-a-bluetooth-keyboard-in-debian-etch/</link>
		<comments>http://www.pixelchaos.net/2008/09/26/set-up-a-bluetooth-keyboard-in-debian-etch/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 11:29:55 +0000</pubDate>
		<dc:creator>jcl</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[MythTV]]></category>

		<guid isPermaLink="false">http://www.pixelchaos.net/?p=71</guid>
		<description><![CDATA[I recently purchased a new Apple Wireless Bluetooth Keyboard for use with MythTV. The choice of input device for MythTV is a very subjective thing to be sure, but I love this device because its as small as it can be without feeling cramped, its thin, light weight, and stylish.
Setting the device up to work [...]]]></description>
			<content:encoded><![CDATA[<p>I recently purchased a new Apple Wireless Bluetooth Keyboard for use with MythTV. The choice of input device for MythTV is a very subjective thing to be sure, but I love this device because its as small as it can be without feeling cramped, its thin, light weight, and stylish.</p>
<p>Setting the device up to work with Debian Etch is fairly straightforward once you know what to do</p>
<p><span id="more-71"></span></p>
<p>Obviously, you need a motherboard with built-in Bluetooth or a USB Bluetooth receiver. Once you have that, lets install the software you&#8217;ll need:</p>
<pre class="brush: plain;">apt-get install bluez-utils bluez-gnome</pre>
<p>Now we need to figure out the Bluetooth address of the keyboard:</p>
<pre class="brush: plain;">
user@host:~$ hcitool scan
Scanning ...
        00:23:41:D4:42:78       laptop
        00:27:E2:A1:3F:E5       Apple Wireless Keyboard
</pre>
<p>Now that you have the Bluetooth address of the keyboard, lets modify the following lines in /etc/default/bluetooth:</p>
<pre class="brush: plain;">
HIDD_ENABLED=1
HIDD_OPTIONS=&quot;--master --connect $(bluetooth addr) --server&quot;
</pre>
<p>Next you&#8217;ll add a new section to /etc/bluetooth/hcid.conf for the keyboard:</p>
<pre class="brush: plain;">
device $(bluetooth addr) {
    name &quot;Apple Wireless Keyboard&quot;;
    auth enable;
    encrypt enable;
}
</pre>
<p>At this point you can pair the keyboard. Since I use fluxbox on my MythTV frontend computers I manually start the required applets, etc.</p>
<ul>
1. Start window manager<br />
2. As the logged in user, run &#8220;bluetooth-applet&#8221;<br />
3. Power cycle the Bluetooth keyboard<br />
4. As root, execute &#8220;hidd &#8211;connect $(keyboard addr)<br />
5. Type a PIN number on bluetooth keyboard (i.e. 1234) then hit return<br />
6. The bluetooth applet will start flashing in the window manager.<br />
7. Click the bluetooth applet and enter the same PIN in the dialog that pops up</ul>
<p>That should be it. You now have a working wireless keyboard :-)</p>
<p>If anyone knows of a way to do this entirely on the command line, bypassing the window manager and bluetooth-applet entirely, I&#8217;d love to hear it.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelchaos.net/2008/09/26/set-up-a-bluetooth-keyboard-in-debian-etch/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>VLAN Bridging in Xen</title>
		<link>http://www.pixelchaos.net/2008/07/16/vlan-bridging-in-xen/</link>
		<comments>http://www.pixelchaos.net/2008/07/16/vlan-bridging-in-xen/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 00:47:22 +0000</pubDate>
		<dc:creator>jcl</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Xen]]></category>

		<guid isPermaLink="false">http://www.pixelchaos.net/?p=53</guid>
		<description><![CDATA[Recently I came upon the need to do all my network routing and firewalling inside a Xen domU. I am not the first to do this but I thought I&#8217;d do a little write up on it to help others trying to accomplish the same thing in Debian.
The idea here is to end up with [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I came upon the need to do all my network routing and firewalling inside a Xen domU. I am not the first to do this but I thought I&#8217;d do a little write up on it to help others trying to accomplish the same thing in Debian.</p>
<p>The idea here is to end up with (at least) two VLANs on the network with the dom0 and domU&#8217;s being able to choose one or both networks on which to exist. In the case of both, you can set up a handy domU firewall/gateway :)</p>
<p><a href='http://www.pixelchaos.net/wp-content/uploads/2008/07/xen_vlans.png'><img src="http://www.pixelchaos.net/wp-content/uploads/2008/07/xen_vlans-300x226.png" alt="" title="xen_vlans" width="300" height="226" class="aligncenter size-medium wp-image-54" /></a></p>
<p>As you can see from the diagram above, we will end up with three bridges in the dom0 with all the appropriate glue to tie everything together. Best of all, this is all assembled on the fly during bootup.</p>
<p><span id="more-53"></span></p>
<p>Now, you obviously need to have a Xen dom0 set up and running properly. Once you are at that point, adding VLAN bridging is fairly straightforward:</p>
<p>First we need to install the vlan package to get the tools for manipulating vlans. Crazy, huh?</p>
<pre class="brush: plain;">apt-get install vlan</pre>
<p>Now we set up the interfaces we will need in /etc/network/interfaces. The seasoned admins out there will note that we only bring up the eth0 interface automatically but leave it unconfigured. It will not have an IP or any of the other usual information. The other two (VLAN) interfaces are defined but are NOT brought up during boot. This is important!</p>
<p>In this example the “vlan100″ interface is the replacement for your old “eth0″ interface. Its the interface you’ll be able to reach the dom0 on from the internal VLAN. The “vlan99″ interface is defined but is left unconfigured since there will be no publicly routeable path to the dom0.</p>
<pre class="brush: plain;">auto eth0
iface eth0 inet manual
        pre-up ifconfig $IFACE up
        post-down ifconfig $IFACE down

iface vlan99 inet manual
        mtu 1500
        vlan_raw_device eth0

iface vlan100 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        dns-nameservers 192.168.1.254
        dns-search pixelchaos.net
        mtu 1500
        vlan_raw_device eth0</pre>
<p>Now we create a new network script for xen located at /etc/xen/scripts/network-multi:</p>
<pre class="brush: plain;">#!/bin/sh
#============================================================================
# Xen vlan bridge start/stop script.
# Xend calls a network script when it starts.
# The script name to use is defined in /etc/xen/xend-config.sxp
# in the network-script field.
#
# This script creates multiple bridges to segregate individual domUs to
# separate VLANs. Customize to fit your needs.
#
# Usage:
#
# network-multi (start|stop|status)
#
#============================================================================

dir=$(dirname &quot;$0&quot;)

##
# To make the tagged interface available to some DomUs, create the default
# bridge. Comment this out to only make vlan-based bridges available.
&quot;$dir/network-bridge&quot; &quot;$@&quot; vifnum=0 netdev=eth0 bridge=&quot;xbr_trunk&quot;

# Once the &quot;normal&quot; bridge is active, bring up the vlan interfaces.
# They will be attached to the virtual eth0 interface, and not the
# physical one.
ifup vlan99
ifup vlan100

# Create any vlan-based briges.
&quot;$dir/network-bridge&quot; &quot;$@&quot; vifnum=1 bridge=&quot;xbr_vl99&quot; netdev=&quot;vlan99&quot;
&quot;$dir/network-bridge&quot; &quot;$@&quot; vifnum=2 bridge=&quot;xbr_vl100&quot; netdev=&quot;vlan100&quot;

# bring up the interfaces again? why do we need to do this? they should have been brought back up by the previous network-bridge call…
ip link set vlan100 up
route add default gw 192.168.1.1 vlan100</pre>
<p>That script basically just calls the standard “network-bridge” script supplied with Xen three times &#8211; once for each VLAN we are setting up. You’ll notice some interesting bits at the end &#8211; We call “ip link” and “route” to bring the vlan100 interface up again. I’m not sure yet why the previous “network-bridge” call doesnt do that on its own… it should as far as I know but I havent dug into why it doesnt. This is just a quick hack to bring “vlan100″ back up again and fix the routes.</p>
<p>Go ahead and add the call to that script in the place of network-bridge in /etc/xen/xend-config.sxp.</p>
<p>Now we need to do one final thing to another Xen script. By default, the xen-network-common.sh script calls “ifdown” directly to take an interface down. Unfortunately, this has the undesirable side effect of destroying any VLANs associated with that interface. This causes all kinds of problems when we call our “network-multi” script so we need to patch /etc/xen/scripts/xen-network-common.sh with the following section:</p>
<pre class="brush: plain;"># do not call ifdown directly
  ifdown()  {
    ip addr flush $1
    ip link set $1 down
    true
  }</pre>
<p>To see exactly where that chunk of code goes you can download my already modified script <a href='http://www.pixelchaos.net/wp-content/uploads/2008/07/xen-network-common.sh'>here</a>, or get a diff <a href='http://www.pixelchaos.net/wp-content/uploads/2008/07/xen-network-common.patch'>here</a> if you prefer.</p>
<p>After youve done all that, reboot your dom0. You should now be up and running on the vlan100 interface. The output of &#8220;brctl show&#8221; should show this:</p>
<pre class="brush: plain;">root@atlas:~# brctl show
bridge name  bridge id          STP enabled    interfaces
xbr_trunk    8000.feffffffffff  no             vif0.0
                                               peth0
xbr_vl100    8000.feffffffffff  no             vif0.2
                                               pvlan100
xbr_vl99     8000.feffffffffff  no             vif0.1
                                               pvlan99</pre>
<p>If so, you should be all ready to go. Now edit the vif line in your config file for a given domU to link its ethernet interface to a bridge. My domU firewall is linked to two bridges so it looks like this:</p>
<pre class="brush: plain;">vif= [ 'mac=00:16:3E:44:F9:9C, bridge=xbr_vl99', 'mac=00:16:3E:41:16:51, bridge=xbr_vl100' ]</pre>
<p>Thats it! Easy, huh?</p>
<p>Many, many thanks go to <a href="http://mike.neir.org">Mike Neir</a> for holding my hand through figuring this all out since he&#8217;d already set up a functional system that is very similar. Thanks also go to <a href="http://www.firstserved.net/blog/2007/07/19/bridging-vlan-interfaces-in-xen/trackback">firstserved.net</a> for the ifdown patch and <a href="http://renial.net/weblog/2007/02/27/xen-vlan/trackback">renial.net</a> for other ideas on ways to set up VLAN bridging in Xen.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelchaos.net/2008/07/16/vlan-bridging-in-xen/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
