<?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>phaq &#187; FreeBSD</title>
	<atom:link href="http://phaq.phunsites.net/category/faq/operating-systems/freebsd/feed/" rel="self" type="application/rss+xml" />
	<link>http://phaq.phunsites.net</link>
	<description>my daily IT madness</description>
	<lastBuildDate>Sun, 05 Feb 2012 21:06:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Install Icinga with MySQL and IDOUtils on FreeBSD</title>
		<link>http://phaq.phunsites.net/2012/01/28/install-icinga-with-mysql-and-idoutils-on-freebsd/</link>
		<comments>http://phaq.phunsites.net/2012/01/28/install-icinga-with-mysql-and-idoutils-on-freebsd/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 17:24:23 +0000</pubDate>
		<dc:creator>gdelmatto</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=920</guid>
		<description><![CDATA[It&#8217;s not hard to install Icinga on FreeBSD, at least if you&#8217;re satisfied with default options. Should you however require Icinga with IDOUtils and MySQL support, then you need to take additional steps. Note: This howto requires a patch to your FreeBSD ports tree. The patch has been submitted to the FreeBSD port maintainers. I [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not hard to install <a href="http://www.icinga.org" target="_blank">Icinga</a> on FreeBSD, at least if you&#8217;re satisfied with default options.<br />
Should you however require Icinga with IDOUtils and MySQL support, then you need to take additional steps.</p>
<p><span id="more-920"></span></p>
<p><b>Note: This howto requires a <a href="http://phaq.phunsites.net/files/2012/01/patch_icinga_1.5.1_idoutils_fbs_port.txt">patch</a> to your FreeBSD ports tree. The patch has been submitted to the FreeBSD port maintainers. I hope that it will eventually end up in the ports tree.</b></p>
<p>My initial readings about this was on the official Icinga docs covering <a href="http://docs.icinga.org/latest/en/quickstart-idoutils-freebsd.html" target="_blank">installing Icinga on FreeBSD with IDOUtils</a>.<br />
However, as it turned out, the docs our a bit outdated, and yet do not reflect a way of doing the install using ports.</p>
<p>So here&#8217;s just a short primer on what I did do install Icinga from ports, imposing as little additional work four you, my fellow reader, as well <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Now let&#8217;s turn to Icinga, which has a port on it&#8217;s own, which you&#8217;ll find it at <strong>/usr/ports/net-mgtm/icinga</strong>. First change to that directory.</p>
<pre>cd /usr/ports/net-mgtm/icinga</pre>
<p>Now download the <a href="http://phaq.phunsites.net/files/2012/01/patch_icinga_1.5.1_idoutils_fbs_port.txt">patch file</a> I made into your ports directory.<br />
The patch will inject a new rc-script for ido2db and enable your port to build IDOutils.</p>
<pre>[root@localhost /usr/ports/net-mgmt/icinga]# fetch http://phaq.phunsites.net/files/2012/01/patch_icinga_1.5.1_idoutils_fbs_port.txt</pre>
<p>Then apply the patch like this:</p>
<pre>[root@localhost /usr/ports/net-mgmt/icinga]# patch -p0 &lt; patch_icinga_1.5.1_idoutils_fbs_port.txt
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- Makefile.org	2012-01-28 16:36:46.000000000 +0000
|+++ Makefile	2012-01-28 17:51:38.000000000 +0000
--------------------------
Patching file Makefile using Plan A...
Hunk #1 succeeded at 27.
Hunk #2 succeeded at 109.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- /dev/null	2012-01-28 18:00:51.000000000 +0000
|+++ files/ido2db.in	2012-01-28 18:00:30.000000000 +0000
--------------------------
(Creating file files/ido2db.in...)
Patching file files/ido2db.in using Plan A...
Hunk #1 succeeded at 1.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- files/pkg-message.in.org	2012-01-28 17:48:37.000000000 +0000
|+++ files/pkg-message.in	2012-01-28 17:49:38.000000000 +0000
--------------------------
Patching file files/pkg-message.in using Plan A...
Hunk #1 succeeded at 4.
done</pre>
<p>Now you&#8217;re ready to configure the port:</p>
<pre>[root@localhost /usr/ports/net-mgmt/icinga]# make config</pre>
<p>Note the now <strong>IDOUtils</strong> option that now has appeared. Check it to enable IDOUtils.</p>
<p><a href="http://phaq.phunsites.net/files/2012/01/idoutils_config_screen.png" rel="lightbox[920]"><img class="aligncenter size-medium wp-image-929" src="http://phaq.phunsites.net/files/2012/01/idoutils_config_screen-300x180.png" alt="" width="300" height="180" /></a></p>
<p>Then compile and install as usual. The port will install also all required dependies, two of them being mysql55-client and libdbi-drivers, both to be found at /usr/ports/databases.</p>
<pre>[root@localhost /usr/ports/net-mgmt/icinga]# make install clean</pre>
<p>Afterwards, you should end up with a few additional files, which would not be installed with the stock FreeBSD port.</p>
<pre>[root@localhost /usr/ports/net-mgmt/icinga]# ls -l /usr/local/bin/ido*
-rwxrwxr--  1 root  wheel  238326 Jan 28 16:53 /usr/local/bin/ido2db
-rwxrwxr--  1 root  wheel   80419 Jan 28 16:53 /usr/local/bin/idomod.o

[root@mgmp-bs01 /usr/ports/net-mgmt/icinga]# ls -l /usr/local/etc/rc.d/ido2db
-r-xr-xr-x  1 root  wheel  738 Jan 28 18:00 /usr/local/etc/rc.d/ido2db</pre>
<p>Now you can enable Icinage and IDO2DB in /etc/rc.conf by adding these lines:</p>
<pre>icinga_enable="YES"
ido2db_enable="YES"</pre>
<p>Of course, you still need to perform the usual Icinga configuration steps, which are not covered in this post.<br />
Please check with the <a href="http://docs.icinga.org/latest/en" target="_blank">official docs</a> for this procedure.</p>
<p>If your configuration is proper, you should notice this in your logs indicating that IDOMOD (IDOUtils) is really working.</p>
<pre>[1327773651] Icinga 1.5.1 starting... (PID=95448)
[1327773651] Local time is Sat Jan 28 18:00:51 UTC 2012
[1327773651] LOG VERSION: 2.0
[1327773651] idomod: IDOMOD 1.5.1 (09-09-2011) Copyright (c) 2005-2008 Ethan Galstad (nagios@nagios.org), Copyright (c) 2009-2011 Icinga Development Team (http://www.icinga.org))
[1327773651] idomod: Successfully connected to data sink.  26 queued items to flush.
[1327773651] idomod: Successfully flushed 26 queued items to data sink.
[1327773651] Event broker module '/usr/local/bin/idomod.o' initialized successfully.
[1327773651] Finished daemonizing... (New PID=95450)</pre>
<p>That&#8217;s it, you conquered the beast!</p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2012/01/28/install-icinga-with-mysql-and-idoutils-on-freebsd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing &#8220;Cannot find autoconf&#8221; error while building PHP extension from a FreeBSD port</title>
		<link>http://phaq.phunsites.net/2011/06/10/fixing-cannot-find-autoconf-error-while-building-php-extension-from-a-freebsd-port/</link>
		<comments>http://phaq.phunsites.net/2011/06/10/fixing-cannot-find-autoconf-error-while-building-php-extension-from-a-freebsd-port/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 11:38:04 +0000</pubDate>
		<dc:creator>gdelmatto</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=648</guid>
		<description><![CDATA[Today I had to add the PHP &#8216;bcmath&#8217; extension to my FreeBSD host. Actually, that&#8217;s a fairly easy one-liner: [root@localhost ~]# cd /usr/ports/math/php5-bcmath &#38;&#38; make clean install However, I ended up with a crude error message: Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. Bummer! So [...]]]></description>
			<content:encoded><![CDATA[<p>Today I had to add the PHP &#8216;bcmath&#8217; extension to my FreeBSD host.<br />
Actually, that&#8217;s a fairly easy one-liner:</p>
<p><code><br />
[root@localhost ~]# cd /usr/ports/math/php5-bcmath &amp;&amp; make clean install<br />
</code></p>
<p>However, I ended up with a crude error message:</p>
<p><b>Cannot find autoconf. Please check your autoconf installation and the<br />
$PHP_AUTOCONF environment variable. Then, rerun this script.</b></p>
<p>Bummer! So let&#8217;s see how to fix this.<br />
<span id="more-648"></span></p>
<p>Here&#8217;s the complete output from the failed build:</p>
<p><code><br />
[root@localhost /usr/ports/math/php5-bcmath]# make<br />
===&gt;  Vulnerability check disabled, database not found<br />
===&gt;  License check disabled, port has not defined LICENSE<br />
===&gt;  Extracting for php5-bcmath-5.3.3_2<br />
=&gt; SHA256 Checksum OK for php-5.3.3.tar.bz2.<br />
===&gt;  Patching for php5-bcmath-5.3.3_2<br />
===&gt;   php5-bcmath-5.3.3_2 depends on file: /usr/local/bin/phpize - found<br />
===&gt;   php5-bcmath-5.3.3_2 depends on file: /usr/local/bin/autoconf-2.68 - found<br />
===&gt;  PHPizing for php5-bcmath-5.3.3_2<br />
Configuring for:<br />
PHP Api Version:         20090626<br />
Zend Module Api No:      20090626<br />
Zend Extension Api No:   220090626<br />
Cannot find autoconf. Please check your autoconf installation and the<br />
$PHP_AUTOCONF environment variable. Then, rerun this script.</p>
<p>*** Error code 1</p>
<p>Stop in /usr/ports/math/php5-bcmath.<br />
</code></p>
<p>From this we see, that error occurs during <b>phpize</b>, which tries to configure/build the extension matching up the currently installed PHP.</p>
<p>Looking into <b>phpize</b>, which is actually a plain script, we find these lines:</p>
<p><code><br />
[root@noc2 /usr/ports/math/php5-bcmath]# grep -E -e 'PHP_AUTO(CONF|HEADER)' /usr/local/bin/phpize<br />
  test -z "$PHP_AUTOCONF" &amp;&amp; PHP_AUTOCONF=autoconf-2.62<br />
  test -z "$PHP_AUTOHEADER" &amp;&amp; PHP_AUTOHEADER=autoheader-2.62<br />
  if test ! -x "$PHP_AUTOCONF" &amp;&amp; test ! -x "`$php_shtool path $PHP_AUTOCONF`"; then<br />
\$PHP_AUTOCONF environment variable. Then, rerun this script.<br />
  if test ! -x "$PHP_AUTOHEADER" &amp;&amp; test ! -x "`$php_shtool path $PHP_AUTOHEADER`"; then<br />
\$PHP_AUTOHEADER environment variable. Then, rerun this script.<br />
  $PHP_AUTOCONF   || exit 1<br />
  $PHP_AUTOHEADER || exit 1<br />
</code></p>
<p>So <b>phpize</b> actually checks for existence of the PHP_AUTOCONF and PHP_AUTOHEADER environment variables.<br />
If these are missing, it will use some defaults for the autoconf/autoheader tools. The default were derived during the initial build which at that time were <b>autoconf-2.62</b> and <b>autoheader-2.62</b>.</p>
<p>Checking installed ports reveals that there&#8217;s a newer version installed, which is why <b>phpize</b> fails so terribly.</p>
<p><code><br />
[root@noc2 /usr/ports/math/php5-bcmath]# pkg_info|grep autoconf<br />
autoconf-2.68       Automatically configure source code on many Un*x platforms<br />
autoconf-wrapper-20071109 Wrapper script for GNU autoconf<br />
</code></p>
<p>To permanently fix this, you can do either of the following:</p>
<ol>
<li>simply change the PHP_AUTOCONF and PHP_AUTOHEADER variables in <b>/usr/local/bin/phpize</b> to reflect the currently installed version</li>
<li>additionally install the old autoconf version besides the new one</li>
<li>Invoke the build like this:<br />
<code><br />
PHP_AUTOCONF=autoconf PHP_AUTOHEADER=autoheader make configure<br />
</code>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2011/06/10/fixing-cannot-find-autoconf-error-while-building-php-extension-from-a-freebsd-port/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>World IPv6 Day and how to connect FreeBSD through a Teredo Tunnel</title>
		<link>http://phaq.phunsites.net/2011/06/08/world-ipv6-day-and-how-to-connect-freebsd-through-a-teredo-tunnel/</link>
		<comments>http://phaq.phunsites.net/2011/06/08/world-ipv6-day-and-how-to-connect-freebsd-through-a-teredo-tunnel/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 08:08:11 +0000</pubDate>
		<dc:creator>gdelmatto</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=644</guid>
		<description><![CDATA[It has finally arrived, the World IPv6 Day! So you don&#8217;t have native IPv6 network access? No problem, just use a Teredo Tunnel to get connected. Here&#8217;s a very short primer on doing so on FreeBSD. Firstly install the miredo package from the ports tree. [root@GPWS ~]# cd /usr/ports/net/miredo/ [root@GPWS /usr/ports/net/miredo]# make clean install Alternatively, [...]]]></description>
			<content:encoded><![CDATA[<p>It has finally arrived, the <a href="http://www.worldipv6day.org/" target="_blank">World IPv6 Day</a>!</p>
<p>So you don&#8217;t have native IPv6 network access? No problem, just use a Teredo Tunnel to get connected.<br />
Here&#8217;s a very short primer on doing so on FreeBSD.<br />
<span id="more-644"></span></p>
<p>Firstly install the <b>miredo</b> package from the ports tree.</p>
<p><code><br />
[root@GPWS ~]# cd /usr/ports/net/miredo/<br />
[root@GPWS /usr/ports/net/miredo]# make clean install<br />
</code></p>
<p>Alternatively, install the binary package:</p>
<p><code><br />
[root@GPWS ~]# pkg_add -r miredo<br />
</code></p>
<p>Enable <b>miredo</b> in your rc.conf:</p>
<p><code><br />
[root@GPWS ~]# echo miredo_enable=YES &gt;&gt; /etc/rc.conf<br />
</code></p>
<p>Make sure to have a proper /usr/local/etc/miredo.conf.<br />
Here&#8217;s my very minimalistic config:</p>
<p><code><br />
#! /usr/local/sbin/miredo -f -c<br />
#<br />
RelayType client<br />
InterfaceName   teredo<br />
#BindPort            3545<br />
#BindAddress     192.168.2.1<br />
ServerAddress teredo.ipv6.microsoft.com<br />
</code></p>
<p>Note: Depending on your setup, e.g. with multiple interfaces, you may need to specify a BindAddress to use the proper network interface.<br />
So to speak, you may need to specify also a specific port for some NAT setups.</p>
<p>Now fire up miredo:</p>
<p><code><br />
[root@GPWS ~]# /usr/local/etc/rc.d/miredo start<br />
</code></p>
<p>You should end up with a new network interface by the name of &#8216;teredo&#8217;:</p>
<p><code><br />
[root@GPWS ~]# ifconfig teredo<br />
teredo: flags=43 metric 0 mtu 1500<br />
        options=80000<br />
        inet6 fe80::ffff:ffff:ffff%teredo prefixlen 64 scopeid 0xb<br />
        inet6 2001:0:5ef5:79fb:4e9:5e1b:2ba5:360b prefixlen 128<br />
        nd6 options=3<br />
        Opened by PID 93528<br />
</code></p>
<p>You should now be able to <b>ping6</b> any IPv6-enabled host on the internet.</p>
<p><code><br />
[root@GPWS ~]# ping6 www.google.ch<br />
PING6(56=40+8+8 bytes) 2001:0:5ef5:79fb:4e9:5e1b:2ba5:360b --&gt; 2a00:1450:8001::93<br />
16 bytes from 2a00:1450:8001::93, icmp_seq=0 hlim=57 time=90.062 ms<br />
16 bytes from 2a00:1450:8001::93, icmp_seq=1 hlim=57 time=18.996 ms<br />
16 bytes from 2a00:1450:8001::93, icmp_seq=2 hlim=57 time=18.810 ms<br />
^C<br />
--- www.l.google.com ping6 statistics ---<br />
3 packets transmitted, 3 packets received, 0.0% packet loss<br />
round-trip min/avg/max/std-dev = 18.810/42.623/90.062/33.545 ms<br />
</code></p>
<p>Happy surfing!</p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2011/06/08/world-ipv6-day-and-how-to-connect-freebsd-through-a-teredo-tunnel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up Redmine on FreeBSD</title>
		<link>http://phaq.phunsites.net/2011/05/08/setting-up-redmine-on-freebsd/</link>
		<comments>http://phaq.phunsites.net/2011/05/08/setting-up-redmine-on-freebsd/#comments</comments>
		<pubDate>Sun, 08 May 2011 21:57:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[HowTo's]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=618</guid>
		<description><![CDATA[&#8220;Redmine is a flexible project management web application. Written using Ruby on Rails framework, it is cross-platform and cross-database.&#8221; (redmine.org) Here&#8217;s my short primer on setting up Redmine on FreeBSD. In my case, I just wanted a rather simplistic and stripped-down environment, which was the reason to choose Redmine. While it can perfectly integrate with [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;Redmine is a flexible project management web application. Written using Ruby on Rails framework, it is cross-platform and cross-database.&#8221; (redmine.org)</p>
<p>Here&#8217;s my short primer on setting up Redmine on FreeBSD.<br />
<span id="more-618"></span><br />
In my case, I just wanted a rather simplistic and stripped-down environment, which was the reason to choose Redmine.<br />
While it can perfectly integrate with Apache, Nginx and other web-servers, I preferred to use the minimalistic &#8220;thin&#8221; web-server.<br />
I do as well use self-compiled port in favor to binary packages. Feel free to use binary packages if you like <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<h3>Installing the software</h3>
<p>Redmine requires a database server. Either MySQL or PostgreSQL or sqlite.<br />
If chose to use MySQL and installed it from the ports using defaults:</p>
<p><code><br />
[root@localhost ~] cd /usr/ports/databases/mysql51-server; make build install<br />
</code></p>
<p>Then install Redmine from /usr/ports/www/redmine.</p>
<p><code><br />
[root@localhost ~] cd /usr/ports/www/redmine; WITHOUT_X11=true make config build install<br />
</code></p>
<p>It&#8217;s important to fire up the &#8220;config dialog&#8221; to include the &#8220;thin&#8221; web-server:</p>
<div align="center">
<a href="http://www.redmine.org/projects/redmine/wiki/Guide" target="_blank"><a href="http://phaq.phunsites.net/files/2011/05/redmine_opts.png" rel="lightbox[618]"><img src="http://phaq.phunsites.net/files/2011/05/redmine_opts-300x167.png" alt="" title="redmine_opts" width="300" height="167" class="aligncenter size-medium wp-image-619" /></a>
</div>
<h3>Enable service configuration</h3>
<p>Enable the services in your /etc/rc.conf.</p>
<p><code><br />
mysql_enable="YES"                      # enable MySQL server<br />
redmine_enable="YES"                    # enable redmine server<br />
redmine_flags="-a 0.0.0.0 -p 3000 -e production --ssl --ssl-key-file=/usr/local/www/redmine/config/server.key --ssl-cert-file=/usr/local/www/redmine/config/server.crt"<br />
</code></p>
<p>I choose to enable SSL in the configuration above. If you don&#8217;t need SSL, then change the &#8220;redmine_flags&#8221; line to read as follows:</p>
<p><code><br />
redmine_flags="-a 0.0.0.0 -p 3000 -e production"<br />
</code></p>
<h3>Prepare MySQL</h3>
<p>Now start mysql server:</p>
<p><code><br />
[root@localhost ~] /usr/local/etc/rc.d/mysql-server start<br />
</code></p>
<p>Fire up the mysql console.<br />
If this happens to be the first time you use MySQL, then you won&#8217;t have a password yet. It may be a good idea then, to first assign new passwords and remove the default database stuff. Do this </p>
<p><code><br />
delete from user where user='';<br />
delete from db where user='';<br />
drop database test;<br />
flush privileges;<br />
</code></p>
<p>Now create the database and user for use with Redmine:</p>
<p><code><br />
create database redmine character set utf8;<br />
create database redmine_devel;<br />
create database redmine_test;<br />
create user 'redmine'@'localhost' identified by 'A_secRET_passw0RD';<br />
grant all privileges on redmine.* to 'redmine'@'localhost';<br />
grant all privileges on redmine_devel.* to 'redmine'@'localhost';<br />
grant all privileges on redmine_test.* to 'redmine'@'localhost';<br />
</code></p>
<h3>Prepare Redmine</h3>
<p>For Redmine you&#8217;ll need to edit some configuration files at /usr/local/www/redmine/config first.<br />
First copy the &#8220;database.yml.example&#8221; file to &#8220;database.yml&#8221;.</p>
<p><code><br />
[root@localhost ~]# cd /usr/local/www/redmine/config<br />
[root@locahost /data/local/www/redmine/config]# cp database.yml.example database.yml<br />
</code></p>
<p>Now edit the &#8220;database.yml&#8221; file to your correct database settings:</p>
<pre>
production:
  adapter: mysql
  database: redmine
  host: localhost
  username: redmine
  password: A_secRET_passw0RD
  encoding: utf8

development:
  adapter: mysql
  database: redmine_development
  host: localhost
  username: redmine
  password: A_secRET_passw0RD
  encoding: utf8

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql
  database: redmine_test
  host: localhost
  username: redmine
  password: A_secRET_passw0RD
  encoding: utf8
</pre>
<p>Now create the session store and import the initial database as follows:</p>
<p><code><br />
[root@localhost /data/local/www/redmine/config]# rake generate_session_store<br />
[root@localhost /data/local/www/redmine/config]# RAILS_ENV=production rake db:migrate<br />
</code></p>
<p>To enable mail processing, you need to copy &#8220;email.yml.example&#8221; to &#8220;email.yml&#8221;:</p>
<p><code><br />
[root@locahost /data/local/www/redmine/config]# cp email.yml.example email.yml<br />
</code></p>
<p>Then edit &#8220;email.yml&#8221; to your proper email settings. The following example is for SMTP delivery through an external host:</p>
<pre>
production:
  delivery_method: :smtp
  smtp_settings:
    address: SMTP.DOMAIN.TLD
    port: 25
    domain: SMTP.DOMAIN.TLD
    authentication: :login
    user_name: "smtp_user_name"
    password: "some_password"

development:
  delivery_method: :smtp
  smtp_settings:
    address: SMTP.DOMAIN.TLD
    port: 25
    domain: SMTP.DOMAIN.TLD
    authentication: :login
    user_name: "smtp_user_name"
    password: "some_password"
</pre>
<h3>Optional: Enable SSL mode</h3>
<p>I enabled SSL for the &#8220;thin&#8221; web-server in /etc/rc.conf. If you choose to not use SSL, skip this step.</p>
<p>To enable SSL, you need to create the SSL private key and a certificate.<br />
I&#8217;m giving just the command list here, as this procedure is otherwise very well documented over there at the <a href="http://www.modssl.org/docs/2.8/ssl_faq.html" target="_blank">mod_ssl FAQ</a>.</p>
<p><code><br />
openssl genrsa -des3 -out server.key.cryped 1024<br />
openssl rsa -in server.key.crypted -out server.key<br />
openssl req -new -key server.key -out server.csr<br />
openssl req -new -x509 -days 365 -key server.key -out server.crt<br />
</code></p>
<p>The above procedure would essentially create a password-protected key (step 1), which would then get the password removed (step 2). I&#8217;d then create a signing request in the 3rd step and have a self-signed certificate created (last command).<br />
The removal of the password is essential to start the web-server without prompting for a password.</p>
<p>Now, there was just one little cave-at I came along. On my setup, Redmine would not properly run in SSL mode in some cases create redirect url containing http:// instead of https://.<br />
I suspect this is a problem caused by the &#8220;thin&#8221; web-server, which would not properly state that it runs in SSL mode to the application. Obviously, wenn running &#8220;thin&#8221; in SSL mode, it would no longer word in &#8220;http plain&#8221; mode, so this causes some errors.</p>
<p>For example, when logging on to your host using https://HOSTNAME:3000, you&#8217;d get redirected to http://HOSTNAME:3000/login?back_url=http://HOSTNAME:3000&#8243;.<br />
Now, as this obviously won&#8217;t work, there&#8217;s a little change required in the &#8220;/usr/local/www/redmine/vendor/rails/actionpack/lib/action_controller/request.rb&#8221; file.</p>
<p>Look out for this text block:</p>
<pre>
    # Is this an SSL request?
    def ssl?
      @env['HTTPS'] == 'on' || @env['HTTP_X_FORWARDED_PROTO'] == 'https'
    end
</pre>
<p>Then change it to look like this:</p>
<pre>
    # Is this an SSL request?
    def ssl?
        true
    end
</pre>
<p>This will force Redmine into thinking it&#8217;s permanently SSL enabled, thus it will always generate proper https:// URLs.<br />
This particular issue would propably not come up when using Apache or Nginx in SSL forwarding mode.</p>
<h3>Start using Redmine</h3>
<p>Now you&#8217;re basically done. Start accessing Redmine through https://YOURHOSTNAME:3000 (or http://YOURHOSTNAME:3000, in case you left SSL disabled).</p>
<p>And don&#8217;t forget to change your default username/password settings upon first login.</p>
<p>I recommed the <a href="http://www.redmine.org/projects/redmine/wiki/Guide" target="_blank">Redmine User&#8217;s Guide</a> for further reading <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2011/05/08/setting-up-redmine-on-freebsd/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Adding a SCSI disk enclosure to a FreeBSD host in online mode</title>
		<link>http://phaq.phunsites.net/2010/12/19/adding-a-scsi-disk-enclosure-to-a-freebsd-host-in-online-mod/</link>
		<comments>http://phaq.phunsites.net/2010/12/19/adding-a-scsi-disk-enclosure-to-a-freebsd-host-in-online-mod/#comments</comments>
		<pubDate>Sun, 19 Dec 2010 22:13:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=430</guid>
		<description><![CDATA[Currently playing around with my Netra T1 105 and a Sun StorEdge Multipack enclosure, I wondered if I really could add the whole enclosure while the host is online. I used to do hot-plugging before, but I&#8217;ve never done this with a whole enclosure at once. Well worth a try? Some things to be considered [...]]]></description>
			<content:encoded><![CDATA[<p>Currently playing around with my Netra T1 105 and a Sun StorEdge Multipack enclosure, I wondered if I really could add the whole enclosure while the host is online.</p>
<p>I used to do hot-plugging before, but I&#8217;ve never done this with a whole enclosure at once. Well worth a try?<br />
<span id="more-430"></span><br />
Some things to be considered for my scenario:</p>
<ul>
<li>The Sun StorEdge Multipack auto-assigns SCSI-IDs ascending through it&#8217;s internal slots. Depending on the mode switch, it&#8217;ll assign IDs 1 through 6 or 9 through 15. On the Netra T1 105 only IDs 1 through 7 are supported. This is no big deal, unless you already have two disks plugged into the internals bays (they take IDs 0 and 1).<br />So you can add a maximum of 5 additional disks (IDs 2 through 6). This actually means that you can only add disks to bays 2 through 6, leaving bay 1 empty. If you keep a disk inside, it&#8217;ll get ID 1, which won&#8217;t work out as this is already taken by an internal bay hard drive.</li>
<li>Also important is that the enclosure is not powered-up. Attach it to the SCSI bus first, before you power on.</li>
</ul>
<p>After powering on the enclosure it&#8217;ll take a few moments to initialize and spin-up the drives.</p>
<p>I recommend waiting for the SCSI ID LED to light up, before you proceed.<br />
Before you rescan the bus, check which devices you see.</p>
<p><code><br />
[root@rohan ~]# camcontrol devlist<br />
IBM DDYST1835SUN18G S96H         at scbus0 target 0 lun 0 (da0,pass0)<br />
IBM DDYST1835SUN18G S96H         at scbus0 target 1 lun 0 (da1,pass1)<br />
</code></p>
<p>The you can either add each new divice one by one, issuing a &#8220;scan&#8221; command for the respective SCSI-ID:</p>
<p><code><br />
[root@rohan ~]# camcontrol rescan scbus0:2:0<br />
[root@rohan ~]# camcontrol devlist<br />
IBM DDYST1835SUN18G S96H         at scbus0 target 0 lun 0 (da0,pass0)<br />
IBM DDYST1835SUN18G S96H         at scbus0 target 1 lun 0 (da1,pass1)<br />
FUJITSU MAN3184M SUN18G 1502     at scbus0 target 2 lun 0 (da2,pass2)<br />
</code></p>
<p>Or you could try to rescan to whole bus at once:</p>
<p><code><br />
[root@rohan ~]# camcontrol rescan scbus0<br />
Re-scan of bus 0 was successful<br />
[root@rohan ~]# camcontrol devlist<br />
IBM DDYST1835SUN18G S96H         at scbus0 target 0 lun 0 (da0,pass0)<br />
IBM DDYST1835SUN18G S96H         at scbus0 target 1 lun 0 (da1,pass1)<br />
FUJITSU MAN3184M SUN18G 1502     at scbus0 target 2 lun 0 (da2,pass2)<br />
FUJITSU MAJ3182M SUN18G 0804     at scbus0 target 3 lun 0 (da3,pass3)<br />
IBM DDYST1835SUN18G S96H         at scbus0 target 4 lun 0 (da4,pass4)<br />
SEAGATE ST318203LSUN18G 034A     at scbus0 target 5 lun 0 (da5,pass5)<br />
SEAGATE ST318203LSUN18G 034A     at scbus0 target 6 lun 0 (da6,pass6)<br />
</code></p>
<p>Conclusion: If you first connect to the bus and then power-up the enclosure so all disks can properly initialize, adding the enclosure and it&#8217;s disks while online is definitely possible. Of course, you should only be doing this with hot-plug ready equipment, which supports auto-termination.</p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2010/12/19/adding-a-scsi-disk-enclosure-to-a-freebsd-host-in-online-mod/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Sparse Files for FreeBSD jails?</title>
		<link>http://phaq.phunsites.net/2010/12/09/use-sparse-files-for-freebsd-jails/</link>
		<comments>http://phaq.phunsites.net/2010/12/09/use-sparse-files-for-freebsd-jails/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 15:58:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[jails]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=110</guid>
		<description><![CDATA[Thinking about FreeBSD jails and an elder post of mine about putting jails within loopback-mounted disk images to enforce disk quota, I asked myself if I should use sparse files or pre-allocated files as virtual disk image for jail-based userland separation. A sparse file designates a special file of a given size (e.g. 20 gigs), [...]]]></description>
			<content:encoded><![CDATA[<p>Thinking about FreeBSD jails and an <a href="http://phaq.phunsites.net/2006/06/22/implementing-filesystem-allocation-limits-on-freebsd-jails/">elder post of mine</a> about putting jails within loopback-mounted disk images to enforce disk quota, I asked myself if I should use sparse files or pre-allocated files as virtual disk image for jail-based userland separation.<br />
<span id="more-110"></span><br />
A sparse file designates a special file of a given size (e.g. 20 gigs), which is neither using nor reserving the whole disk space at once. It won&#8217;t effectively allocate disk blocks until data is written to the sparse file.</p>
<p>This comes in handy in creating disk images, which can be a very time consuming task.</p>
<p>Let&#8217;s look at the numbers of creating a 20gig file, which fills up available disk space at once but takes about five minutes to do so. Not to forget about the I/O load the task produces, which affects performance.</p>
<pre>
[root@localhost vz]# time dd if=/dev/zero of=test1.img bs=1024k count=20480
20480+0 records in
20480+0 records out
21474836480 bytes (21 GB) copied, 321.902 seconds, 66.7 MB/s

real    5m21.903s
user    0m0.021s
sys     0m55.282s
</pre>
<p>Creating a 20gig sparse file is done almost immediately, with the difference that disk blocks are not allocated right away.</p>
<pre>
[root@localhost ~]# dd of=test2.img bs=1024k count=0 seek=20480
0+0 records in
0+0 records out
0 bytes (0 B) copied, 1.4744e-05 seconds, 0.0 kB/s

real    0m0.002s
user    0m0.000s
sys     0m0.002s
</pre>
<p>Some possible drawbacks when using sparse files:</p>
<ul>
<li>Peformance degredation when having multiple sparse files to which data is written randomly. This may end up in heavy fragmentation as the sparse files are likely not to be written contiguously in that case, which in term causes slow read access performance</li>
<li>Race conditions when creating many sparse files which would exceed the available disk space (e.g. 20 sparse files of 20 gigs each, but the disk is only 200 gigs in size). To handle this, a special monitoring script would be needed to consider logical vs. physical space allocation.</li>
</ul>
<p>Up until today, I always used pre-allocated disk images, but at the expense of non-usable disk space.<br />
I think that sparse files might be a good choice actually, at least as long as there&#8217;s not much random data written to it, so the payload stays mostly identical over longer periods of time.<br />
For sure, a sparse file used as image for a jail-based database server is definitely a bad idea.<br />
Nevertheless, I&#8217;m keen to try and see, if this might be a considered options for some real-live scenarios.</p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2010/12/09/use-sparse-files-for-freebsd-jails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache 2.2 pretends on missing IPv6 support in FreeBSD</title>
		<link>http://phaq.phunsites.net/2010/10/14/apache-2-2-pretends-on-missing-ipv6-support-in-freebsd/</link>
		<comments>http://phaq.phunsites.net/2010/10/14/apache-2-2-pretends-on-missing-ipv6-support-in-freebsd/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 13:55:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeBSD]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=170</guid>
		<description><![CDATA[Today I faced a very issue with Apache 2.2 in FreeBSD. Despite having it compiled with IPV6 support enabled, it pretended in missing IPv6 support, throwing this error message at me. Syntax error on line 336 of /usr/local/etc/apache22/httpd.conf: The specified IP address is invalid. The line in question contained a &#8220;limit&#8221; clause like this: allow [...]]]></description>
			<content:encoded><![CDATA[<p>Today I faced a very issue with Apache 2.2 in FreeBSD.</p>
<p>Despite having it compiled with IPV6 support enabled, it pretended in missing IPv6 support, throwing this error message at me.<br />
<span id="more-170"></span><br />
<code>Syntax error on line 336 of /usr/local/etc/apache22/httpd.conf:<br />
The specified IP address is invalid.<br />
</code></p>
<p>The line in question contained a &#8220;limit&#8221; clause like this:</p>
<p><code>allow from ::1</code></p>
<p>This behaviour is very odd indeed, as one would expect that compiling Apache 2.2 with IPv6 should effectively permit the afore mentioned configuration statement.</p>
<p>The reason for this behaviour lies much deeper and is not directly related to the Apache 2.2 port itself, but to one of it&#8217;s core dependencies, the APR (Apache Portable Runtime).</p>
<p>Depending on which ports you compile and install, chances are that a few may require the APR library to work properly.<br />
One amongst them is subversion (svn).<br />
If you don&#8217;t pay attention to the port configuration dialogs (usually seen by invoking &#8220;make config&#8221;), chances are likely you choose wrong values or just go with the defaults, so you may end up with an APR without IPv6 support.</p>
<p>To check if your APR has IPv6 support enable, just invoke this command:</p>
<p><code>localhost:/# pkg_info apr*<br />
Information for apr-gdbm-db42-1.3.3.1.3.4_1:</p>
<p>Comment:<br />
Apache Portability Library</p>
<p>Required by:<br />
subversion-1.5.5_1</p>
<p>Description:<br />
The Apache Portable Runtime is a library of C data structures and routines,<br />
forming a system portability layer that covers as many operating systems as<br />
possible, including Unices, Win32, BeOS, and OS/2.</p>
<p>This port also includes the APR-Util package, which contains some useful<br />
utilities built on top of APR.</p>
<p>WWW: http://apr.apache.org/<br />
</code></p>
<p>The package name gives a clear statement if it supports IPv6 or not. If it does, it&#8217;ll read something like this:</p>
<p><strong>apr-ipv6-gdbm-db42-1.3.3.1.3.4_1</strong></p>
<p>If it does NOT, it&#8217;ll read something like this:</p>
<p><strong>apr-gdbm-db42-1.3.3.1.3.4_1</strong></p>
<p>So, if you insist in managing your port build options manually, make sure to always do a &#8220;make config WITH_IPV6=yes&#8221; first.<br />
This is your best bet to catch all ports, as most of them support the WITH_IPV6 flag.</p>
<p>You&#8217;re better off however, if you add the flag to <strong>/etc/make.conf<strong> like this:</p>
<p><code><br />
WITH_IPV6=		yes<br />
</code></p>
<p>In either way, you make sure that your APR will always support IPv6, even if it happens to get installed before Apache.</p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2010/10/14/apache-2-2-pretends-on-missing-ipv6-support-in-freebsd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Strange compilation error on MySQL</title>
		<link>http://phaq.phunsites.net/2009/07/16/strange-compilation-error-on-mysql/</link>
		<comments>http://phaq.phunsites.net/2009/07/16/strange-compilation-error-on-mysql/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 13:01:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/2009/07/16/strange-compilation-error-on-mysql/</guid>
		<description><![CDATA[Yesterday I started digging around for a solution to create per-user or per-database statistics on MySQL, one of the more important peaces I was missing from it for a long time. Luckily enough, some guys over there had already done some work on this topic, so I wouldn&#8217;t have to start over from scratch It [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I started digging around for a solution to create per-user or per-database statistics on MySQL, one of the more important peaces I was missing from it for a long time.</p>
<p>Luckily enough, some guys<a href="http://www.byte.nl/blog/tag/mysql-statistics/" target="_blank"> over there</a> had already done some work on this topic, so I wouldn&#8217;t have to start over from scratch <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><span id="more-119"></span></p>
<p>It took me only little time to port over the patch from MySQL 5.0.51 to the more current 5.0.83 release within the FreeBSD ports tree, however not soon after starting a build I would encounter this error message:</p>
<pre>
[root@bld-bsd-224-221 /usr/ports/databases/mysql50-server]# make build
[ - some output omitted - ]
/bin/sh ../ylwrap sql_yacc.yy y.tab.c sql_yacc.cc y.tab.h sql_yacc.h y.output sql_yacc.output --  -d -d --debug --verbose
-d: not found
*** Error code 1
</pre>
<p>At first I thought the port was corrupted so I refetched the package and reapplied the patch, to no avail.<br />
So I tried again using the original port without having the patch applied, which worked flawlessly.</p>
<p>At second glance I checked for the file list from above command and noticed that it included the file named sql_yacc.yy, one of which had been altered by the previously applied patch.<br />
My conclusion was that the file had been wrongly patched, containing a syntax error or such alike.<br />
I then extracted the unpatched package once more to do a clean rebuild without patches.<br />
I checked the compilation output for the above command line, only to note that it wasn&#8217;t actually there!</p>
<p>The question was: Why would the command line &#8220;/bin/sh ../ylwrap sql_yacc.yy &#8230;.&#8221; not get invoked when doing a build on a clean, unpatched package?<br />
I double-checked my patches to see if the command was introduced by itself, which was not the case. That single command actually belongs to the stock MySQL Makefile.</p>
<p>At that stage I decided to just add a single whitespace to the file sql_yacc.yy and run the command manually:</p>
<pre>
[root@bld-bsd-224-221 /usr/ports/databases/mysql50-server/work/mysql-5.0.83/sql]# make
/bin/sh ../ylwrap sql_yacc.yy y.tab.c sql_yacc.cc y.tab.h sql_yacc.h y.output sql_yacc.output --  -d -d --debug --verbose
-d: not found
*** Error code 1
</pre>
<p>Interestingly enough that command actually only seems to get involved when the contents of the sql_yacc.yy file is altered.<br />
As such the error was indeed not caused by the patch itself.</p>
<p>So I digged deeper in analyzing the &#8220;ylwrap&#8221; script file, which is included with the MySQL package. Oh well, at that time I really felt like an idiot!<br />
When I realized that this seemed to by a wrapper script for YACC I also noticed the double-hyphen, which is really an indicator for subsequent command line arguments to be passed on to a sub-process.<br />
Having said that I supposed there was actually missing something in between here: &#8220;&#8211; {HERE} -d -d&#8221;<br />
Could it be that it&#8217;s missing the command name of the YACC sub-processor?</p>
<p>Well, do I have YACC installed?</p>
<pre>

bld-bsd-224-221.genotec.ch:/usr/ports/databases/mysql50-server# which yacc
/usr/bin/yacc
</pre>
<p>Well, I do &#8230; the only catch is: MySQL depends on bison, not on YACC.<br />
To make things worse, neither the FreeBSD port Makefile nor the MySQL configure script check on that dependency, most likely as it is *usually* not required.</p>
<p>Good catch, after having installed bison from the ports tree MySQL compiled like a charm even with all my patches applied <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2009/07/16/strange-compilation-error-on-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is RAID1 possible on an USB stick?</title>
		<link>http://phaq.phunsites.net/2007/10/26/is-raid1-possible-on-an-usb-stick/</link>
		<comments>http://phaq.phunsites.net/2007/10/26/is-raid1-possible-on-an-usb-stick/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 18:48:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[HA]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/2007/10/26/is-raid1-possible-on-an-usb-stick/</guid>
		<description><![CDATA[Last week we had a discussion at the office wether it would possible to span a RAID across USB sticks. That question came up as a joke while I was working on some RAID system for evaluation purposes. Well, my friend doubted it when I replied that it would definitely work out with a FreeBSD [...]]]></description>
			<content:encoded><![CDATA[<p>Last week we had a discussion at the office wether it would possible to span a RAID across USB sticks.<br />
That question came up as a joke while I was working on some RAID system for evaluation purposes.<br />
Well, my friend doubted it when I replied that it would definitely work out with a FreeBSD software RAID using gmirror (geom vinum as a matter of fact works, too).</p>
<p>Proof?<br />
<span id="more-109"></span><br />
Here it is, a &#8216;dmesg&#8217; from my Sony Vaio PCG-C1MGP bootet off two gmirrored 256 MB USB sticks:</p>
<pre>
Copyright (c) 1992-2007 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 6.2-RELEASE #0: Fri jan 12 10:40:27 UTC 2007
root@dessler.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Transmeta(tm) Crusoe(tm) Processor TM5800 (727.84-MHz 586-class CPU)
  Origin = "GenuineTmx86" Id = 0x543  Stepping = 3
  Features=0x80893f
real memory  = 251658240 (240 MB)
avail memory = 232452096 (221 MB)
kbd1 at kbdmux9
ath_hal: 0.9.17.2 (AR5210, AR5211, AR5212, RF5111, RF5112, RF2413, RF5413)
acpi0:  on motherboard
Timecounter "ACPI-safe" frequency 3579545 Hz quality 1000
acpi_ec0:  port 0x62,0x66 on acpi0
acpi_timer0: &lt;32-bit timer at 3.579545MHz&gt; port 0x8008-0x800b on acpi0
acpi_lid0:  on acpi0
acpu_button0:
 on acpi0
[ output omitted ]
umass0: Sony USB Memory Stick Slot, rev 1.10/1.83 addr2
umass1: vendor 0x4146 USB Mass Storage Device, rev 2.00/1.00, addr 2
umass2: vendor 0x4146 USB Mass Storage Device, rev 2.00/1.00, addr 3
[ output omitted ]
da0 at umass-sim1 bus 1 target 0 lun 0
da0: &lt;-pretec 256 MB 1.10&gt; Removable Direct Access SCSO device
da0: 1.000MB/s transfers
da0: 242 MB (4964000 512 byte sectors: 64H 32S/T 242C)
da1 at umass-sim1 bus 2 target 0 lun 0
da1: &lt;-pretec 256 MB 1.10&gt; Removable Direct Access SCSO device
da1: 1.000MB/s transfers
da1: 242 MB (4964000 512 byte sectors: 64H 32S/T 242C)
GEOM_MIRROR: Device gm0 created (id=1986392903).
GEOM_MIRROR: Device gm0: provider da0 detected.
GEOM_MIRROR: Device gm0: provider da1 detected.
GEOM_MIRROR: Device gm0: provider da0 activated.
GEOM_MIRROR: Device gm0: provider da1 activated.
GEOM_MIRROR: Device gm0: provider mirror/gm0 launched.
Trying to mount root from ufs:/dev/mirror/gm0s1a
</pre>
<p>Of course it&#8217;s not incredibly fast, but it works afterall, that was the whole point about it <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
Where could it be used? Possibly projects like <a href="http://www.freenas.org/" target="_blank">FreeNAS</a>, which support USB installs, could benefit from doing RAID1 on the sticks while also storing sensitive configuration data on them.<br />
I could also imagine to take backups this way, e.g. keep one working copy on the active stick on the computer, while swapping in spare sticks which then automatically rebuild the mirror.</p>
<p>I suppose this also works with linux &#8216;md&#8217; software raid, and netbsd&#8217;s RAIDframe, though I&#8217;ve not tested it.</p>
<p>What about Windows? Definitely not with stock functionality. However as there&#8217;s also a way to patch in software RAID1 functionality into Windows 2000/XP Professional, one never knows &#8230; <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2007/10/26/is-raid1-possible-on-an-usb-stick/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ufs_dirbad panic with mangled entries in ufs</title>
		<link>http://phaq.phunsites.net/2007/07/01/ufs_dirbad-panic-with-mangled-entries-in-ufs/</link>
		<comments>http://phaq.phunsites.net/2007/07/01/ufs_dirbad-panic-with-mangled-entries-in-ufs/#comments</comments>
		<pubDate>Sun, 01 Jul 2007 10:56:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeBSD]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/2007/07/01/ufs_dirbad-panic-with-mangled-entries-in-ufs/</guid>
		<description><![CDATA[FreeBSD&#8217;s ufs usually does an excellent job in preventing file system corruption. But even the best system happens to mess up once in a while. One thing you may eventually stumble accross are so called mangled entries, which are usually not fixable with fsck and result in kernel panics upon access. Now these are usually [...]]]></description>
			<content:encoded><![CDATA[<p>FreeBSD&#8217;s ufs usually does an excellent job in preventing file system corruption. But even the best system happens to mess up once in a while.</p>
<p>One thing you may eventually stumble accross are so called mangled entries, which are usually not fixable with fsck and result in kernel panics upon access.<br />
<span id="more-64"></span><br />
Now these are usually a sign of severe file system corruption, often caused by hardware faults like bad memory modules, a faulty disk controller or even a deffective hard drive.</p>
<p>Consider checking and replacing your hardware if you encounter mangled entries on a frequent and recurring occasion.<br />
You may actually succeed in fixing it following the steps outlined below, however it is very likely to happen again if you have faulty hardware. So in the end you&#8217;ll end up curing the side-effects and not the actual reason, which may in turn lead to other, even more critical problems.</p>
<p>On the other hand, if you happen to have a corrupted file system like this very, very seldomly (as in &#8220;about once in a decade&#8221;, it happened to myself only three times in 10 years that I&#8217;ve worked on some 200-300 servers in total) you may risk fixing it by means of the file system debugger.</p>
<p>I define this as a &#8220;minor corruption&#8221; to which the following usually applies:</p>
<ul>
<li>happens very, very seldomly</li>
<li>happens as a result of a server deadlock/crash/power failure/etc</li>
<li>limited to one or maybe two directory or file entries</li>
<li>is not found by fsck eventually</li>
<li>is not fixed by fsck</li>
<li>causes the server to panic when accessing given file or directory</li>
</ul>
<h4>When the error happens</h4>
<p>A typical error message thrown at you in this case may look like this (some output omitted):</p>
<pre>
/mnt/da1s1a: bad dir ino 16392 AT OFFSET 512: MANGLED ENTRY
panic: ufs_dirbad: bad dir</pre>
<p>The message gives some essential information about the file system concerned (the actual mountpoint, not the device name itself) amd the inode of the directory or file.</p>
<h4>First steps in recovery</h4>
<p>So the next best thing to do in this situation is to reboot into single user mode.<br />
From there have fsck inspect the device first.</p>
<pre>
# fsck -y /dev/da1s1a
** /dev/da1s1a
** Last Mounted on /mnt/da1s1a
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counters
** Phase 5 - Check Cyl groups
60040 files, 464657 used, 423186 free (43252 frags, 47493 blocks, 4.9% fragmentation)

***** FILE SYSTEM MARKED CLEAN *****</pre>
<p>Now since mangled entries are usually not fixed by fsck, the term &#8220;FILE SYSTEM MARKED CLEAN&#8221; should not be trusted in.</p>
<p>You may risk to bring your system back up without any further work, however if it panics again with the same message (mind the inode number), you are likely to have unfixable (by means of fsck) corruption.</p>
<h4>Optional but recommend: Try to crash the machine again</h4>
<p>Personally I always try in crashing the system before I touch the file system with the debugger, however not without taking a current backup first if at all possible.</p>
<p>The reasons for doing so is simple:</p>
<ul>
<li>Trying to crash the machine will prove that the corruption still exists</li>
<li>Finding the bad entry through manual search may indicate why and where it happened eventually</li>
<li>It may reveal additional corruption</li>
<li>It may proove that it cannot be fixed by fsck at all, no matter how often you run it</li>
</ul>
<p>Finding the corrupted entry is easiest by walking the directory structure.</p>
<p>For this a simple command line like this usually works well enough. It should be run from single user mode and on the read-only mounted target device only to minimize all impacts.</p>
<pre>
# find / -type d -exec ls -ld {} ;</pre>
<p>This will usually cause the system to panic again when accessing the corrupted directory.<br />
If it does not, this method may:</p>
<pre>
# find / -type d -exec stat {} ;</pre>
<p>If this still doesn&#8217;t work, you may mount the device read-write so the afore mentioned commands can actually touch the file system to update file access times.</p>
<p>And if even that fails, try to create a dummy file inside each directory will do for sure:</p>
<pre>
# find / -type d -exec touch {}/mydummyfilenamewhichshouldnotexist ;</pre>
<p>Now it must be noted that doing this on a already corrupted read-write file system _is_ dangerous.</p>
<p>I cannot stress this enough:</p>
<p>Don&#8217;t take the risk if you don&#8217;t have a backup!<br />
Don&#8217;t take the risk if you&#8217;re not aware of the consequences!<br />
Don&#8217;t take the risk if you&#8217;re a newbie!</p>
<p>A panic in this situation could make it even worse!</p>
<h4>So, the system panics again&#8230;</h4>
<p>Let&#8217;s assume the system panics again with the same error message.</p>
<p>If you were lucky enough you even saw which directory was last accessed before the panic.<br />
This may be valuable to know if you run some certain type of application and could reveal yet unknown application errors or even vulnerabilities like temporary file creation race conditions.</p>
<pre>/mnt/da1s1a: bad dir ino 16392 AT OFFSET 512: MANGLED ENTRY
panic: ufs_dirbad: bad dir</pre>
<p>So you now have proof that there is (still) an unfixed corruption on the file system.<br />
You also have proof that it happened at the same inode than before.<br />
If it&#8217;s not the same inode, then you know for sure that there&#8217;s either another corruption or faulty hardware which causes excessive errors.</p>
<p>For the latter case remember what I wrote before about faulty hardware.</p>
<h4>Right, now how to fix it?</h4>
<p>To fix it go back to single user mode and re-run fsck just to make sure. Keep your device mounted read-only.</p>
<p>Then start the file system debugger, fsdb:</p>
<pre>
# fsdb /dev/ad1s1a
** /dev/ad1s1a
Editing file system '/dev/ad1s1a'
Last mounted on /mnt/ad1s1a
[output omitted]
fsdb (inum: 2)&gt;</pre>
<p>Now go to the inode which was mentioned during kernel panic to get some additional information.</p>
<pre>
fsdb (inum: 2)&gt; inode 16392
current inode: directory
I=16392 MODE=40755 SIZE=512
           BTIME=Oct 23 11:47:24 2006 [0 nsec]
           MTIME=Oct 23 11:47:24 2006 [0 nsec]
           CTIME=Oct 23 11:47:24 2006 [0 nsec]
           ATIME=Oct 23 11:47:24 2006 [0 nsec]
OWNER=root GRP=WHEEL LINKCNT=2 FLAGS=0 BLKCNT=4 GEN=157338b7
fsdb (inum: 16392)&gt;</pre>
<p>Even if it results in data loss, clearing the inode is the way to go to get rid of this.</p>
<pre>
fsdb (inum: 16392)&gt; clri 16392</pre>
<p>Then exit the debugger:</p>
<pre>
fsdb (inum: 16392)&gt; quit

**** FILE SYSTEM STILL DIRTY *****
*** FILE SYSTEM MARKED DIRTY
*** BE SURE TO RUN FSDK TO CLEAN UP ANY DAMAGE
*** IF IT WAS MOUNTED, RE-MOUNT WITH -u -o reload</pre>
<p>Run fsck as told:</p>
<pre>
** /dev/da1s1a
** Last Mounted on /mnt/da1s1a
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
UNALLOCATED  I=16392 OWNER=root MODE=0
SIZE=512 MTIME Oct 23 11:47:24 2006
NAME=/dsj????

REMOVE=YES

** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counters
LINK COUNT DIR I=2  OWNER=root MODE=40755
SIZE=512 MTIME=Oct 23 11:47:24 2006  COUNT 21 SHOULD BE 20
ADJUST? yes

** Phase 5 - Check Cyl groups
FREE BLK COUNT(S) WRONG IN SUPERBLK
SALVAGE? yes

SUMMARY INFORMATION BAD
SAVLAGE? yes

BLK(S) MISSING IN BIT MAPS
SALVAGE? yes

60039 files, 464655 used, 423188 free (43248 frags, 47492 blocks, 4.9% fragmentation)

***** FILE SYSTEM MARKED CLEAN *****

***** FILE SYSTEM WAS MODIFIED *****</pre>
<h4>This is it?</h4>
<p>Basically yes.</p>
<p>However I recommend rebooting the system once more into single user mode to rerun &#8216;find&#8217;.<br />
This will reveal if there is (no) further corruption. Also the reboot will ensure that the operating system can re-read the disklabel and file system properly. This is especially important after messing around with the file system debugger.<br />
For this reason do run fsck once more just to make sure the file system is really clean.</p>
<p>Also try keeping to these premises:</p>
<ul>
<li>one corruption may happen once in a while and really mean nothing</li>
<li>two is still possible but must be looked at critically</li>
<li>three is a bad sign, there&#8217;s usually more to come</li>
</ul>
<p>Remember: The file system is at the heart of your server. Messing it up could compromise your data, your users and even your job. So care for it!</p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2007/07/01/ufs_dirbad-panic-with-mangled-entries-in-ufs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

