<?xml version="1.0"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:bgn="http://blogreen.org" xmlns:res="http://blogreen.org/TR/Resources" bgn:template-name="rss" version="2.0"><channel><title>FreeBSD</title><link>http://romain.blogreen.org/categories/freebsd/</link><description>An advanced operating system for modern server, desktop, and embedded computer platforms.</description><link xmlns="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://romain.blogreen.org/categories/freebsd/rss-full.xml"/><item><title>Updating a ZFS Mirror</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml">A few days ago, while I was on the phone, my machine experienced a kernel panic.  The backtrace pointed a problem somewhere in the swap management code.  I was on a hurry at that time and rebooted the machine without taking the time dig in the problem deeper.</p><p xmlns="http://www.w3.org/1999/xhtml">On the next day, I eventually realised that an hard disk was logically missing on the system and the ZFS mirror it was belonging to was working in a degraded mode.  This disk holding a swap partition, the panic quite makes sense: some data was stored there and could not be paged-out anymore.</p><pre xmlns="http://www.w3.org/1999/xhtml" class="highlight-keyword"># zpool list
NAME   SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
data   294G  68,2G   226G    23%  1.25x  <strong>DEGRADED</strong>  -
tank  1,81T   300G  1,52T    16%  1.06x  ONLINE  -</pre><pre xmlns="http://www.w3.org/1999/xhtml" class="highlight-keyword"># zpool status data
  pool: data
 state: <strong>DEGRADED</strong>
<strong>status: One or more devices could not be opened.  Sufficient replicas exist for
        the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
   see: http://www.sun.com/msg/ZFS-8000-2Q</strong>
  scan: none requested
config:

NAME                                            STATE     READ WRITE CKSUM
data                                            DEGRADED     0     0     0
  mirror-0                                      DEGRADED     0     0     0
    gptid/36711e52-a69e-11de-8adf-0018f38af467  ONLINE       0     0     0
    15152536002702365387                        <strong>UNAVAIL</strong>      0     0     0  <strong>was /dev/gptid/602da1ae-c474-11de-960d-0008a14dbca1</strong>

errors: No known data errors</pre><p xmlns="http://www.w3.org/1999/xhtml">This disk already had problems in the past and I even had to <a href="http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/158630">improve <tt>sysutils/smartmontools</tt> periodic script to take into account SMART attributes that have been failing at some point in the past but have recovered since that time</a> on that disk.  This time, the disk is <em>really</em> dead, so no other choice than changing it.  Hopefully, I have a brunch of spare heard disks on the shelve, so I took two 500 GB disks to replace the two 320 GB of the degraded ZFS pool.</p><p xmlns="http://www.w3.org/1999/xhtml">I first replaced the broken disk with a new one, identified it using <tt>geom(8)</tt> and partitioned using basically the same settings I used when <a href="http://romain.blogreen.org/blog/2009/10/updating-freebsd-7-i386-to-8-amd64/">installing FreeBSD on full-ZFS</a>:</p><pre xmlns="http://www.w3.org/1999/xhtml"># geom disk list ada1
Geom name: ada1
Providers:
1. Name: ada1
   Mediasize: 500107862016 (465G)
   Sectorsize: 512
   Mode: r2w2e3
   descr: ST3500418AS
   ident: (null)
   fwsectors: 63
   fwheads: 16

# geom part create -s GPT ada1
ada1 created
# geom part add -s 128 -t freebsd-boot ada1
ada1p1 added
# geom part add -s 4G -t freebsd-swap ada1
ada1p2 added
# geom part add -t freebsd-zfs ada1
ada1p3 added
# geom part show ada1
=&gt;       34  976773101  ada1  GPT  (465G)
         34        128     1  freebsd-boot  (64k)
        162    8388608     2  freebsd-swap  (4.0G)
    8388770  968384365     3  freebsd-zfs  (461G)

# geom part bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1
bootcode written to ada1</pre><p xmlns="http://www.w3.org/1999/xhtml">I then replaced the unavailable ZFS partition with the new one:</p><pre xmlns="http://www.w3.org/1999/xhtml"># zpool replace data 15152536002702365387 ada1p3
Make sure to wait until resilver is done before rebooting.

If you boot from pool 'data', you may need to update
boot code on newly attached disk 'ada1p3'.

Assuming you use GPT partitioning and 'da0' is your new boot disk
you may use the following command:

gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0</pre><p xmlns="http://www.w3.org/1999/xhtml">… waited a few moments for resilvering to finish:</p><pre xmlns="http://www.w3.org/1999/xhtml" class="highlight-keyword">% zpool status data
  pool: data
 state: DEGRADED
<strong>status: One or more devices is currently being resilvered.  The pool will
	continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
  scan: resilver in progress since Mon Jan  2 19:26:44 2012
    330M scanned out of 68,2G at 4,07M/s, 4h44m to go
    329M resilvered, 0,47% done</strong>
config:

	NAME                                            STATE     READ WRITE CKSUM
	data                                            DEGRADED     0     0     0
	  mirror-0                                      DEGRADED     0     0     0
	    gptid/36711e52-a69e-11de-8adf-0018f38af467  ONLINE       0     0     0
	    <strong>replacing-1</strong>                                 UNAVAIL      0     0     0
	      15152536002702365387                      UNAVAIL      0     0     0  was /dev/gptid/602da1ae-c474-11de-960d-0008a14dbca1
	      ada1p3                                    ONLINE       0     0     0  <strong>(resilvering)</strong>

errors: No known data errors</pre><p xmlns="http://www.w3.org/1999/xhtml">… then shut the system down, replaced the working 320 GB disk by a new 500 GB one and booted into FreeBSD again:</p><pre xmlns="http://www.w3.org/1999/xhtml" class="highlight-keyword">% zpool status data
  pool: data
 state: <strong>DEGRADED</strong>
<strong>status: One or more devices could not be opened.  Sufficient replicas exist for
	the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
   see: http://www.sun.com/msg/ZFS-8000-2Q</strong>
  scan: resilvered 68,2G in 1h58m with 0 errors on Mon Jan  2 21:25:42 2012
config:

	NAME                     STATE     READ WRITE CKSUM
	data                     DEGRADED     0     0     0
	  mirror-0               DEGRADED     0     0     0
	  3635039039460500206    <strong>UNAVAIL</strong>      0     0     0  was /dev/gptid/36711e52-a69e-11de-8adf-0018f38af467
	    ada1p3               ONLINE       0     0     0

errors: No known data errors</pre><p xmlns="http://www.w3.org/1999/xhtml">Same story with the other disk:</p><pre xmlns="http://www.w3.org/1999/xhtml">geom part create -s GPT ada0
ada0 created
# geom part add -s 128 -t freebsd-boot ada0
ada0p1 added
# geom part add -s 4G -t freebsd-swap ada0
ada0p2 added
# geom part add -t freebsd-zfs ada0
ada0p3 added
# geom part show ada0
=&gt;       34  976773101  ada0  GPT  (465G)
         34        128     1  freebsd-boot  (64k)
        162    8388608     2  freebsd-swap  (4.0G)
    8388770  968384365     3  freebsd-zfs  (461G)

# geom part bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
bootcode written to ada0
# zpool replace data 3635039039460500206 ada0p3
Make sure to wait until resilver is done before rebooting.

If you boot from pool 'data', you may need to update
boot code on newly attached disk 'ada0p3'.

Assuming you use GPT partitioning and 'da0' is your new boot disk
you may use the following command:

	gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0</pre><p xmlns="http://www.w3.org/1999/xhtml">When done, I saw that the available space on the <tt>data</tt> zpool was still the same:</p><pre xmlns="http://www.w3.org/1999/xhtml" class="highlight-keyword"># zpool list
NAME   SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
data   <strong>294G</strong>  65,3G   229G    22%  1.19x  ONLINE  -
tank  1,81T   300G  1,52T    16%  1.08x  ONLINE  -</pre><p xmlns="http://www.w3.org/1999/xhtml">This is due to the <tt>autoexpand</tt> property set to <em>off</em> by default and that should be set to <em>on</em> before replacing disks if this feature is desired.</p><pre xmlns="http://www.w3.org/1999/xhtml"># zpool set autoexpand=on data</pre><p xmlns="http://www.w3.org/1999/xhtml">Hopefully, it is possible to use the <tt>zpool(8)</tt>'s <tt>online</tt> command to make ZFS take into account the extra space available for the pools:</p><pre xmlns="http://www.w3.org/1999/xhtml"># zpool online -e data ada0p3</pre><pre xmlns="http://www.w3.org/1999/xhtml" class="highlight-keyword"># zpool list
NAME   SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
data   <strong>460G</strong>  65,3G   395G    14%  1.20x  ONLINE  -
tank  1,81T   300G  1,52T    16%  1.06x  ONLINE  -</pre>]]></description><link>http://romain.blogreen.org/blog/2012/01/updating-a-zfs-mirror/</link><category>FreeBSD</category><category>Sysadmin</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2012/01/updating-a-zfs-mirror/</guid><pubDate>Wed, 04 Jan 2012 11:27:08 GMT</pubDate></item><item><title>TeXLive 2011 on FreeBSD</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml">A few weeks ago, I updated the <a href="https://code.google.com/p/freebsd-texlive/">freebsd-texlive project</a> to make TeXLive 2011 (the latest verison) available as ports for <a href="http://www.freebsd.org/">FreeBSD</a>.</p><p xmlns="http://www.w3.org/1999/xhtml">In order to help users who don't want to install the whole TeXLive collection (~2000 ports), <a href="http://freebsd-texlive.googlecode.com/svn/trunk/Tools/scripts/texlive-port-seek">a basic script</a> has been developed to ease-up finding which port provides some file required by a given package.</p><p xmlns="http://www.w3.org/1999/xhtml">As usual, feedback is welcomed!</p>]]></description><link>http://romain.blogreen.org/blog/2011/08/texlive-2011-on-freebsd/</link><category>FreeBSD</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2011/08/texlive-2011-on-freebsd/</guid><pubDate>Fri, 26 Aug 2011 02:10:00 GMT</pubDate></item><item><title>Typesetting Korean with TeXLive</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml">Today, I received a request for <a href="http://code.google.com/p/freebsd-texlive/issues/detail?id=15">adding support for ko.teX to the FreeBSD TeXLive ports</a>. I created 3 ports for this purpose: <a href="http://freebsd-texlive.googlecode.com/svn/branches/ports/print/kotex-util/">print/kotex-util</a>, <a href="http://freebsd-texlive.googlecode.com/svn/branches/ports/print/kotex-macros/">print/kotex-macros</a> and <a href="http://freebsd-texlive.googlecode.com/svn/branches/ports/print/kotex-fonts-all/">kotex-fonts-all</a>.</p><p xmlns="http://www.w3.org/1999/xhtml">I did some basic testing locally, but I don't read Korean, thus I could not test beyond the (minimalistic) examples. I am therefore looking for FreeBSD TeXLive users who are able to write Korean to help testing this package.  If you are one of them, please give it a try and report any success or failures <a href="http://code.google.com/p/freebsd-texlive/issues/detail?id=15">on the issue page</a>.</p><p xmlns="http://www.w3.org/1999/xhtml">To install these experimental ports, the easiest way is using <tt>devel/subversion</tt>:</p><pre xmlns="http://www.w3.org/1999/xhtml">% svn co http://freebsd-texlive.googlecode.com/svn/branches/ports/print/kotex-util/
% cd kotex-util
% make
% sudo make install
% cd ..
% svn co http://freebsd-texlive.googlecode.com/svn/branches/ports/print/kotex-macros/
% cd kotex-macros
% make
% sudo make install
% cd ..
% svn co http://freebsd-texlive.googlecode.com/svn/branches/ports/print/kotex-fonts-all/
% cd kotex-fonts-all
% make
% sudo make install
% cd ..</pre><p xmlns="http://www.w3.org/1999/xhtml">Thanks!</p>]]></description><link>http://romain.blogreen.org/blog/2011/02/typesetting-korean-with-texlive/</link><category>FreeBSD</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2011/02/typesetting-korean-with-texlive/</guid><pubDate>Sun, 06 Feb 2011 12:13:31 GMT</pubDate></item><item><title>TeXLive 2010 on FreeBSD</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml">I definitively have a lack of time at the moment.  Since this blog last entry is about <q>Hey guys, I have just pushed TeXLive 2009 in the <a href="http://code.google.com/p/freebsd-texlive/">freebsd-texlive</a> project</q>, I guess I have to take the time to write this short post:</p><p xmlns="http://www.w3.org/1999/xhtml">One month ago, I pushed TeXLive 2010 to the <a href="http://code.google.com/p/freebsd-texlive/">freebsd-texlive</a> repository.  Moreover, because <a href="http://www.freshports.org/ports-mgmt/portshaker/">portshaker</a> is now in the FreeBSD ports tree, <a href="http://code.google.com/p/freebsd-texlive/wiki/Installing">installing bleeding-edge TeXLive on FreeBSD</a> has never been so easy!</p>]]></description><link>http://romain.blogreen.org/blog/2010/11/texlive-2010-on-freebsd/</link><category>FreeBSD</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2010/11/texlive-2010-on-freebsd/</guid><pubDate>Mon, 01 Nov 2010 12:13:31 GMT</pubDate></item><item><title>TeXLive 2009 on FreeBSD</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml">I recently updated the <a href="https://code.google.com/p/freebsd-texlive/">freebsd-texlive project</a> to make TeXLive 2009 (the latest verison) available as ports for <a href="http://www.freebsd.org/">FreeBSD</a>.</p><p xmlns="http://www.w3.org/1999/xhtml">I used <a href="http://romain.blogreen.org/Blog/2009/05/TeXLive_for_FreeBSD_updated">a script for update TeXLive 2008 on a regular basis</a>, but since these new ports feature <tt>pkg-plist</tt> files, I had to setup an update jail.  So updates for FreeBSD TeXLive ports will be generated daily at 5:30 CET.</p><p xmlns="http://www.w3.org/1999/xhtml">I am also thinking about pushing the <tt>portshaker(8)</tt> utility in the FreeBSD ports tree in order to make it easier to track this project along with others (e.g. BSD#).</p><p xmlns="http://www.w3.org/1999/xhtml">Feedback is welcomed!</p>]]></description><link>http://romain.blogreen.org/blog/2010/04/texlive-2009-on-freebsd/</link><category>FreeBSD</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2010/04/texlive-2009-on-freebsd/</guid><pubDate>Mon, 12 Apr 2010 09:14:00 GMT</pubDate></item><item><title>ZFS: unsupported ZFS version 14 (should be 13)</title><description><![CDATA[<h2 xmlns="http://www.w3.org/1999/xhtml">How I got there?</h2><p xmlns="http://www.w3.org/1999/xhtml">After updating to the latest development version of GNOME thanks' to <a href="http://www.marcuscom.com:8080/cgi-bin/cvsweb.cgi">MarcusCom ports</a> I wanted to log out and back in but X refused to restart because of the in-heavy-development <a href="http://nouveau.freedesktop.org/wiki/">Nouveau video driver</a>.  I run in this problem every once a while and a full reboot solve this problem.  However, the system did not boot:</p><pre xmlns="http://www.w3.org/1999/xhtml">ZFS: unsupported ZFS version 14 (should be 13)
ZFS: unsupported ZFS version 14 (should be 13)
NO ZFS pools located? can't boot</pre><p xmlns="http://www.w3.org/1999/xhtml">Okay, I recall running the following to update my full-ZFS system from ZFS 13 to 14 a while ago:</p><pre xmlns="http://www.w3.org/1999/xhtml">zpool upgrade -a</pre><p xmlns="http://www.w3.org/1999/xhtml">I completly  forgot about updating the GPT bootloader accordingly and thus it was unable to use the version of ZFS on my disks.</p><h2 xmlns="http://www.w3.org/1999/xhtml">The FreeBSD 8.0-STABLE livefs</h2><p xmlns="http://www.w3.org/1999/xhtml">The FreeBSD projects provides snapshots of -STABLE version of the Operating System (I am running FreeBSD 8.0-STABLE) and the livefs disk contains the fixit environement which would allow me to solve my problems.</p><p xmlns="http://www.w3.org/1999/xhtml">I so used my laptop to look for such an ISO image and burn it, unfortunately, the bootp and dns servers are run by the machine that was down.  Hopefully, I had a web browser oppenned on this system and it had the address of google's servers in it's cache.  I could search for my ISP DNS and add them to <tt>/etc/resolv.conf</tt>. I was then able to download the image and burn it.</p><h2 xmlns="http://www.w3.org/1999/xhtml">Fixing</h2><p xmlns="http://www.w3.org/1999/xhtml">By default, the livefs will not have ZFS support unless you ask for it before starting. In other word, at the boot menu, <em>Escape to loader prompt</em> and type:</p><pre xmlns="http://www.w3.org/1999/xhtml">OK <strong>load zfs</strong>
OK <strong>boot</strong></pre><p xmlns="http://www.w3.org/1999/xhtml">When the <tt>sysinstall(8)</tt> menu appears, select <em>Fixit</em> / <em>CDROM/DVD</em>. At the <tt>Fixit#</tt> prompt, you will have to search for your zfs pools, mount your filesystems, locate the new version of the bootloader and install it.  This is basically a transcript of what I did (<a href="http://romain.blogreen.org/blog/2009/10/updating-freebsd-7-i386-to-8-amd64/">I previously described my setup in this blog</a>):</p><pre xmlns="http://www.w3.org/1999/xhtml">Fixit# zpool import -f data <em># at this point I had to leave and return in the Fixit environement</em>
                            <em># because by ZFS root was hiding the livefs root.</em>
Fixit# zfs set mountpoint=/mnt data
Fixit# gpart bootcode -p /mnt/boot/gptzfsboot -i 1 ad10
Fixit# gpart bootcode -p /mnt/boot/gptzfsboot -i 1 ad12
Fixit# zfs set mountpoint=legacy data
Fixit# zfs umount -a
Fixit# logout</pre><p xmlns="http://www.w3.org/1999/xhtml">Note to myself: in the future <strong>do not forget</strong> to update the bootloader when updating my ZFS filesystems.</p>]]></description><link>http://romain.blogreen.org/blog/2010/02/zfs-unsupported-zfs-version-14-should-be-13/</link><category>FreeBSD</category><category>Sysadmin</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2010/02/zfs-unsupported-zfs-version-14-should-be-13/</guid><pubDate>Sat, 27 Feb 2010 16:27:00 GMT</pubDate></item><item><title>The state of Mono 2.6 on FreeBSD</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml">Long time no post... Well, I an writing a serie of articles about <a href="http://en.wikipedia.org/wiki/Near_Field_Communication">NFC</a> and it takes me a lot of time, not mentioning I still do many other things in parallel.  If you are interested in this area, stay tuned ;-)</p><p xmlns="http://www.w3.org/1999/xhtml">So apart NFC, what's new with <a href="http://www.mono-project.com">Mono</a> on <a href="http://www.FreeBSD.org">FreeBSD</a>?  First, you wight have seen that <a href="http://www.mono-project.com/Release_Notes_Mono_2.6">mono 2.6 has been released</a> for a while and is still not available in FreeBSD ports.  The main reasons are:</p><ul xmlns="http://www.w3.org/1999/xhtml">
<li><a href="https://bugzilla.novell.com/show_bug.cgi?id=528830">a thread concurrency problem</a> which is still not solved but <a href="http://code.google.com/p/bsd-sharp/source/browse/trunk/lang/mono/files/patch-mono_metadata_appdomain.c">an ugly workaround</a> have been found;</li>
<li>a bug (well, a weird implementation) of the new <a href="http://www.mono-project.com/Soft_Debugger">built-in soft-mode debugger</a> that makes it totally useless on amd64.  A workaround have been found and in the meantime, the code has been updated upstream and will be part of mono-2.6.2 which will probably be released at the end of the month;</li>
<li>the <a href="http://www.mono-project.com/Moonlight">moonlight</a> tools (e.g. the <tt>smcs.exe</tt> compiler) are still part of mono (read <em>the code source is in <tt>mono-2.6.tar.bz2</tt></em>) but installed by moonlight (read <em>the Makefiles with install targets are in <tt>moonlight-2.0.tar.bz2</tt></em>).  This leads to some juggling which is in progress (read: I can build and install it on my system, Firefox segfaults when I browse a website with Silverlight contents, and configure fails in Tinderbox because it cannot find bison, which is however installed according to the logs).</li>
</ul><p xmlns="http://www.w3.org/1999/xhtml">I will not mention here the <tt>mono-basic-2.6.tar.bz2</tt> source tarball that exists besides the <tt>moonlight-2.0.tar.bz2</tt> tarball in the <a href="http://ftp.novell.com/pub/mono/sources/moon/2.0/"><tt>moon</tt>(light) source directory</a> and the <tt>mono-basic-2.6.tar.bz2</tt> source tarball in  the <a href="http://ftp.novell.com/pub/mono/sources/mono-basic/"><tt>mono-basic</tt> directory</a> having different dates &amp; checksums… Lot of fun to come I guess.</p><p xmlns="http://www.w3.org/1999/xhtml">Once these various problems have been fixed, you can expect mono-2.6 to reach the ports, promptly followed by the last version of the MonoDevelop IDE which is quite lovely.</p><p xmlns="http://www.w3.org/1999/xhtml">Last but not least, <a href="http://www.freebsd.org/news/newsflash.html#event20100126:01">I am now a ports committer</a> and <a href="http://blog.xbsd.org/2010/01/26/new-ports-committer-romain-tartiere">flz@ is my mentor</a>.</p>]]></description><link>http://romain.blogreen.org/blog/2010/02/the-state-of-mono-26-on-freebsd/</link><category>FreeBSD</category><category>Mono</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2010/02/the-state-of-mono-26-on-freebsd/</guid><pubDate>Tue, 16 Feb 2010 15:57:00 GMT</pubDate></item><item><title>Unbreaking Mono on FreeBSD 6.4</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml">A few days ago <a href="http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/140916">ports/140916: lang/mono (2.4.2.3) installation fails</a> was opened. The reported problem had already been reported a few time but with insufficient feedback so far and I was not able to diagnose the problem, not mentioning providing a fix. But this time, the reporter could spot that the problem was happening for him only with FreeBSD-6.4.  I did the test on a fresh FreeBSD-6.4 install and could trigger the error:</p><pre xmlns="http://www.w3.org/1999/xhtml">arthur# portsnap fetch
[...]
arthur# portsnap extract
[...]
arthur# cd /usr/ports/lang/mono
arthur# make -V PKGNAME
mono-2.4.2.3_1
arthur# make
[...]
if test -w ../mcs; then :; else chmod -R +w ../mcs; fi
cd ../mcs &amp;&amp; gmake NO_DIR_CHECK=1 PROFILES='net_1_1 net_2_0 net_3_5 net_2_1' CC='cc' all-profiles
gmake[3]: Entering directory `/usr/ports/lang/mono/work/mono-2.4.2.3/mcs'
gmake profile-do--net_1_1--all profile-do--net_2_0--all profile-do--net_3_5--all profile-do--net_2_1--all
gmake[4]: Entering directory `/usr/ports/lang/mono/work/mono-2.4.2.3/mcs'
gmake PROFILE=basic all
gmake[5]: Entering directory `/usr/ports/lang/mono/work/mono-2.4.2.3/mcs'
gmake[6]: *** [build/deps/basic-profile-check.exe] Error 1
gmake[6]: Entering directory `/usr/ports/lang/mono/work/mono-2.4.2.3/mcs'
*** The compiler 'false' doesn't appear to be usable.
*** Trying the 'monolite' directory.
gmake[7]: Entering directory `/usr/ports/lang/mono/work/mono-2.4.2.3/mcs'
gmake[8]: *** [build/deps/basic-profile-check.exe] Error 138
gmake[8]: Entering directory `/usr/ports/lang/mono/work/mono-2.4.2.3/mcs'
*** The contents of your 'monolite' directory may be out-of-date
*** You may want to try 'make get-monolite-latest'
gmake[8]: *** [do-profile-check-monolite] Error 1
gmake[8]: Leaving directory `/usr/ports/lang/mono/work/mono-2.4.2.3/mcs'
gmake[7]: *** [do-profile-check] Error 2
gmake[7]: Leaving directory `/usr/ports/lang/mono/work/mono-2.4.2.3/mcs'
gmake[6]: *** [do-profile-check-monolite] Error 2
gmake[6]: Leaving directory `/usr/ports/lang/mono/work/mono-2.4.2.3/mcs'
gmake[5]: *** [do-profile-check] Error 2
gmake[5]: Leaving directory `/usr/ports/lang/mono/work/mono-2.4.2.3/mcs'
gmake[4]: *** [profile-do--basic--all] Error 2
gmake[4]: Leaving directory `/usr/ports/lang/mono/work/mono-2.4.2.3/mcs'
gmake[3]: *** [profiles-do--all] Error 2
gmake[3]: Leaving directory `/usr/ports/lang/mono/work/mono-2.4.2.3/mcs'
gmake[2]: *** [all-local] Error 2
gmake[2]: Leaving directory `/usr/ports/lang/mono/work/mono-2.4.2.3/runtime'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/usr/ports/lang/mono/work/mono-2.4.2.3'
gmake: *** [all] Error 2
*** Error code 1

Stop in /usr/ports/lang/mono.
*** Error code 1

Stop in /usr/ports/lang/mono.</pre><p xmlns="http://www.w3.org/1999/xhtml">A first look leads us on a wrong way (lane?): <em>*** The compiler 'false' doesn't appear to be usable</em>. This message is actually <strong>not</strong> an error message: the mono C# compiler (<tt>mcs(1)</tt>) is written in C# so some bootstrapping may be required if no version of mono is present on the system.  The mono port adds <tt>EXTERNAL_MCS=false</tt> to <tt>MAKE_ARGS</tt> so that the mono port will be build exactly the same way regardless of an available <tt>mcs(1)</tt> in the path.</p><p xmlns="http://www.w3.org/1999/xhtml">Hopefully, I tested on an old machine and could see that <q>something was running for a couple seconds before failing</q>. Ctrl+T in <tt>tcsh(1)</tt> told me more:</p><pre xmlns="http://www.w3.org/1999/xhtml">load: 0.08  cmd: mono 10910 [ksesigwait] 0.13u 0.10s 0% 24492k
load: 0.08  cmd: mono 10910 [ksesigwait] 0.13u 0.10s 0% 24964k</pre><p xmlns="http://www.w3.org/1999/xhtml">The good news is that some <q>mono</q> application is running. But wait, what is this <em>ksesigwait</em> state? A first look at the <a href="http://fxr.watson.org/">FreeBSD Kernel Cross Reference</a> reveals that this state is defined in <tt>kern/kern_kse.c</tt>; the man page is <tt><a href="http://www.FreeBSD.org/cgi/man.cgi?query=kse&amp;manpath=FreeBSD+6.4-RELEASE">kse(2)</a></tt>; <a href="http://en.wikipedia.org/wiki/Kernel_Scheduled_Entities">Wikipedia states</a> <em>KSEs were mandatory at introduction; made optional at kernel build time in the 7.0 release and removed from the 8.0 release with a compatibility library</em>.</p><p xmlns="http://www.w3.org/1999/xhtml">The second good news is that a 22MB <tt>mono.core</tt> file is written in the mcs directory.</p><pre xmlns="http://www.w3.org/1999/xhtml">arthur# gdb -q /usr/ports/lang/mono/work/mono-2.4.2.3/mono/mini/mono mono.core
Core was generated by `mono'.
Program terminated with signal 10, Bus error.
Reading symbols from /usr/local/lib/libgthread-2.0.so.0...done.
Loaded symbols for /usr/local/lib/libgthread-2.0.so.0
Reading symbols from /usr/local/lib/libglib-2.0.so.0...done.
Loaded symbols for /usr/local/lib/libglib-2.0.so.0
Reading symbols from /usr/local/lib/libintl.so.8...done.
Loaded symbols for /usr/local/lib/libintl.so.8
Reading symbols from /usr/local/lib/libiconv.so.3...done.
Loaded symbols for /usr/local/lib/libiconv.so.3
Reading symbols from /usr/local/lib/libpcre.so.0...done.
Loaded symbols for /usr/local/lib/libpcre.so.0
Reading symbols from /lib/libm.so.4...done.
Loaded symbols for /lib/libm.so.4
Reading symbols from /lib/libpthread.so.2...done.
Loaded symbols for /lib/libpthread.so.2
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x2856bf2a in signalcontext () from /lib/libc.so.6
[New Thread 0x8319c00 (sleeping)]
[New Thread 0x8319800 (sleeping)]
[New Thread 0x8319600 (LWP 100098)]
[New Thread 0x82fd000 (runnable)]
[New LWP 100058]
(gdb) thread apply all bt

Thread 5 (LWP 100058):
#0  0x2856bf2a in signalcontext () from /lib/libc.so.6
#1  0x28527fc4 in pthread_mutexattr_init () from /lib/libpthread.so.2
#2  0x28303480 in ?? ()

Thread 4 (Thread 0x82fd000 (runnable)):
#0  0x285eb0ac in __vfprintf () from /lib/libc.so.6
#1  0x2855ff90 in vasprintf () from /lib/libc.so.6
[...]
#33814 0x081464b8 in mono_runtime_invoke (method=0x82fd81c, obj=0x0, params=0xbfbfe510, exc=0x0) at object.c:2401
#33815 0x0814785b in mono_runtime_exec_main (method=0x82fd81c, args=0x28657f60, exc=0x0) at object.c:3301
#33816 0x0814736c in mono_runtime_run_main (method=0x82fd81c, argc=2, argv=0xbfbfe74c, exc=0x0) at object.c:3089
#33817 0x080cdf7d in mono_jit_exec (domain=0x28653ee0, assembly=0x833c880, argc=3, argv=0xbfbfe748) at driver.c:924
#33818 0x080ce0e8 in main_thread_handler (user_data=0xbfbfe690) at driver.c:972
#33819 0x080cfc3a in mono_main (argc=6, argv=0xbfbfe73c) at driver.c:1647
#33820 0x08058f90 in main (argc=6, argv=0xbfbfe73c) at main.c:34

Thread 3 (Thread 0x8319600 (LWP 100098)):
#0  0x2852f5f3 in pthread_testcancel () from /lib/libpthread.so.2
#1  0x28527fc4 in pthread_mutexattr_init () from /lib/libpthread.so.2
#2  0x28303480 in ?? ()

Thread 2 (Thread 0x8319800 (sleeping)):
#0  0x28528097 in pthread_mutexattr_init () from /lib/libpthread.so.2
#1  0x28521ade in _nanosleep () from /lib/libpthread.so.2
#2  0x28521c42 in nanosleep () from /lib/libpthread.so.2
#3  0x081e32ca in collection_thread (unused=0x0) at collection.c:34
#4  0x28520449 in pthread_create () from /lib/libpthread.so.2
#5  0x285deecb in _ctx_start () from /lib/libc.so.6

Thread 1 (Thread 0x8319c00 (sleeping)):
#0  0x28528097 in pthread_mutexattr_init () from /lib/libpthread.so.2
#1  0x2852822b in pthread_mutexattr_init () from /lib/libpthread.so.2
#2  0x2852c839 in _pthread_cond_wait () from /lib/libpthread.so.2
#3  0x2852cd82 in pthread_cond_wait () from /lib/libpthread.so.2
#4  0x081e86d8 in _wapi_handle_timedwait_signal_handle (handle=0x1d05, timeout=0x0, alertable=0, poll=0) at handles.c:1605
#5  0x081e846e in _wapi_handle_wait_signal_handle (handle=0x1d05, alertable=0) at handles.c:1548
#6  0x08205f2e in WaitForSingleObjectEx (handle=0x1d05, timeout=4294967295, alertable=0) at wait.c:205
#7  0x081608a0 in finalizer_thread (unused=0x0) at gc.c:1061
#8  0x081806f0 in start_wrapper (data=0x8326380) at threads.c:623
#9  0x08200367 in thread_start_routine (args=0x832c230) at threads.c:286
#10 0x08223adf in GC_start_routine (arg=0x2865aec0) at pthread_support.c:1382
#11 0x28520449 in pthread_create () from /lib/libpthread.so.2
#12 0x285deecb in _ctx_start () from /lib/libc.so.6
#0  0x2852f5f3 in pthread_testcancel () from /lib/libpthread.so.2</pre><p xmlns="http://www.w3.org/1999/xhtml">Yes, you read it well, the thread 4 backtrace is 33820 frame long! Looks like we have a stack overflow... Since the problem occurs on FreeBSD 6 (where KSE is <em>enabled</em> by default) and not on FreeBSD 7 (where KSE is <em>disabled</em> by default) nor FreeBSD 8 (No KSE at all), it is likely to be related to the thread implementation.</p><p xmlns="http://www.w3.org/1999/xhtml">Let's launched one more time <tt>gmake(1)</tt> and hit Ctrl+Z to suspend all when mono was filling-in it's stack in order to have some hints about the exact command being executed. Reducing it to a simple test is trivial, e.g.:</p><pre xmlns="http://www.w3.org/1999/xhtml">arthur# pwd
/usr/ports/lang/mono/work/mono-2.4.2.3/mcs
arthur# env MONO_PATH="$PWD/class/lib/monolite" ../mono/mini/mono --config ../runtime/etc/mono/config ./class/lib/monolite/mcs.exe
Bus error (core dumped)
arthur# </pre><p xmlns="http://www.w3.org/1999/xhtml">Now we know what is being run. Let's get some info about this binary file:</p><pre xmlns="http://www.w3.org/1999/xhtml">arthur# ldd ../mono/mini/mono
../mono/mini/mono:
	libgthread-2.0.so.0 =&gt; /usr/local/lib/libgthread-2.0.so.0 (0x28304000)
	libglib-2.0.so.0 =&gt; /usr/local/lib/libglib-2.0.so.0 (0x28309000)
	libintl.so.8 =&gt; /usr/local/lib/libintl.so.8 (0x283c9000)
	libiconv.so.3 =&gt; /usr/local/lib/libiconv.so.3 (0x283d2000)
	libpcre.so.0 =&gt; /usr/local/lib/libpcre.so.0 (0x284c7000)
	libm.so.4 =&gt; /lib/libm.so.4 (0x284fc000)
	libpthread.so.2 =&gt; /lib/libpthread.so.2 (0x28512000)
	libc.so.6 =&gt; /lib/libc.so.6 (0x28537000)</pre><p xmlns="http://www.w3.org/1999/xhtml"><tt>pthread(3)</tt> list all thread libraries available on the system:</p><ul xmlns="http://www.w3.org/1999/xhtml">
<li>POSIX Threads Library (libpthread, -lpthread)</li>
<li>1:1 Threading Library (libthr, -lthr)</li>
<li>Reentrant C Library (libc_r, -lc_r)</li>
</ul><p xmlns="http://www.w3.org/1999/xhtml">On my FreeBSD 8.0-STABLE machine, <tt>ldd(1)</tt> reports (mono-2.6 instead of 2.4):</p><pre xmlns="http://www.w3.org/1999/xhtml">marvin# ldd `which mono`
/usr/local/bin/mono:
	libgthread-2.0.so.0 =&gt; /usr/local/lib/libgthread-2.0.so.0 (0x8008b4000)
	libglib-2.0.so.0 =&gt; /usr/local/lib/libglib-2.0.so.0 (0x8009b8000)
	libicui18n.so.38 =&gt; /usr/local/lib/libicui18n.so.38 (0x800b74000)
	libintl.so.8 =&gt; /usr/local/lib/libintl.so.8 (0x800dca000)
	libiconv.so.3 =&gt; /usr/local/lib/libiconv.so.3 (0x800ed3000)
	libpcre.so.0 =&gt; /usr/local/lib/libpcre.so.0 (0x8010cd000)
	libm.so.5 =&gt; /lib/libm.so.5 (0x8011fd000)
	libthr.so.3 =&gt; /lib/libthr.so.3 (0x80131c000)
	libc.so.7 =&gt; /lib/libc.so.7 (0x801434000)
	libicuuc.so.38 =&gt; /usr/local/lib/libicuuc.so.38 (0x80166e000)
	libicudata.so.38 =&gt; /usr/local/lib/libicudata.so.38 (0x80189f000)
	libstdc++.so.6 =&gt; /usr/lib/libstdc++.so.6 (0x80248e000)
	libgcc_s.so.1 =&gt; /lib/libgcc_s.so.1 (0x802699000)</pre><p xmlns="http://www.w3.org/1999/xhtml">So let's try to use <em>libthr</em> on FreeBSD 6. This can be achieved using <tt>libmap.conf(5)</tt>: instead of <tt>/lib/libpthread.so(.2)</tt> we want to use <tt>/usr/lib/libthr.so(.2)</tt>:</p><pre xmlns="http://www.w3.org/1999/xhtml">arthur# cat &gt;&gt; /etc/libmap.conf &lt;&lt; EOT
libpthread.so.2  libthr.so.2
libpthread.so    libthr.so
EOT</pre><p xmlns="http://www.w3.org/1999/xhtml">then...</p><pre xmlns="http://www.w3.org/1999/xhtml">arthur# make
[...]
arthur# make tests
[...]
363 test(s) passed. 0 test(s) did not pass.
[...]
arthur# echo $?
0</pre><p xmlns="http://www.w3.org/1999/xhtml">\o/</p>]]></description><link>http://romain.blogreen.org/blog/2009/12/unbreaking-mono-on-freebsd-64/</link><category>FreeBSD</category><category>Mono</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2009/12/unbreaking-mono-on-freebsd-64/</guid><pubDate>Wed, 23 Dec 2009 02:29:00 GMT</pubDate></item><item><title>OpenRD console access on FreeBSD.</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml">This morning, I received the <a href="http://www.open-rd.org">Open-RD</a> I bought a few days ago and started playing with my new device. One  of the first thing I wanted to access was (of course) the system console.  While the default setup provides a <acronym title="Secure Shell">SSH</acronym> daemon and even GDM and a full desktop, my goal is to have FreeBSD on this device and move the services I run at home from my personal computer to this low-consumption computer (and I don't intend to switch to GNU/Linux).</p><p xmlns="http://www.w3.org/1999/xhtml">Since the console is <em>usually</em> available on the serial port, I looked for some cable to connect the OpenRD to my computer.  Unfortunately, I didn't have the required cable. I then spent about two hour with various serial cables, cables looking like serial cables but which where not serial cables, parallel SUB-D25 connectors, a serial SUB-D25 cross-over cable and a soldering iron to build a null-modem SUB-D9 serial cable. Unfortunately, when I connected my computer to the OpenRD, I was still not able to access the console using <tt>cu(1)</tt>.</p><p xmlns="http://www.w3.org/1999/xhtml">After reading a bit of documentation, I realised I missed the fact that the console was available on USB and not <em>via</em> the serial port.  However, FreeBSD did not recognised the chip the OpenRD uses to provide serial over USB support.</p><p xmlns="http://www.w3.org/1999/xhtml">Using <tt>usbconfig(8)</tt>, I could get the vendor ID and product ID the <tt>uftdi(4)</tt> driver was lacking.  I patches the source code and a few minutes later could enjoy a set of new devices when I plug the OpenRD on my computer:</p><pre xmlns="http://www.w3.org/1999/xhtml">% ls /dev/cuaU*
/dev/cuaU0
/dev/cuaU0.init
/dev/cuaU0.lock
/dev/cuaU1
/dev/cuaU1.init
/dev/cuaU1.lock</pre><p xmlns="http://www.w3.org/1999/xhtml">I can now access the OpenRD console using <tt>cu(1)</tt>:</p><pre xmlns="http://www.w3.org/1999/xhtml">% cu -l /dev/cuaU1 -s 115200</pre><p xmlns="http://www.w3.org/1999/xhtml">\o/ I can boot a FreeBSD 8.0-STABLE arm kernel!</p><p xmlns="http://www.w3.org/1999/xhtml">I filled-in the <a href="http://www.freebsd.org/cgi/query-pr.cgi?pr=140951">usb/140951</a> problem report in the FreeBSD GNATS with the patch. If you own an OpenRD and want to have access to the console, the patch is just waiting for you.</p>]]></description><link>http://romain.blogreen.org/blog/2009/11/openrd-console-access-on-freebsd/</link><category>FreeBSD</category><category>Sysadmin</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2009/11/openrd-console-access-on-freebsd/</guid><pubDate>Fri, 27 Nov 2009 22:49:00 GMT</pubDate></item><item><title>Introducing ZFS support in portshaker(8)</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml"><a href="http://www.ohloh.net/p/portshaker"><tt>portshaker(8)</tt></a> is a tool designed for merging partial ports trees into the FreeBSD ports tree. In other words, it implements some kind of overlay for the FreeBSD ports.</p><p xmlns="http://www.w3.org/1999/xhtml">When merging port trees, <tt>portshaker(8)</tt> first clones the upstream FreeBSD ports tree to the target location. For this purpose, <tt>portshaker(8)</tt> used to rely on <tt>rsync(1)</tt> because the <em>target</em> ports tree was supposed to be quite near to the <em>source</em> ports tree.  With an UFS file-system, it took my computer circa 10 minutes to merge the 390 Mib of files.</p><p xmlns="http://www.w3.org/1999/xhtml">I recently <a href="http://romain.blogreen.org/blog/2009/10/updating-freebsd-7-i386-to-8-amd64/">switched to full ZFS</a>, and this gave the clone process a boost: less than four minutes where required to perform the clone action for the first time, and thanks to caching, a single minute was enought to clone a second time.</p><p xmlns="http://www.w3.org/1999/xhtml">But ZFS provides cloning capabilities, thus, I added support for the ZFS file-system into <tt>portshaker(8)</tt>. Enabling this feature is as simple as adding the following to <tt>/usr/local/etc/portshaker.conf</tt>:</p><pre xmlns="http://www.w3.org/1999/xhtml">use_zfs="yes"</pre><p xmlns="http://www.w3.org/1999/xhtml">There is however a prerequisite for this to work: the <em>target</em> ports tree's parent directory and the <em>source</em> directory have to be ZFS filesystems.  For example, on my computer, the FreeBSD upstream ports are stored in <tt>/var/cache/portshaker/freebsd</tt> and I merge my ports to the usual <tt>/usr/ports</tt> directory. All these directories are ZFS filesystems:</p><pre xmlns="http://www.w3.org/1999/xhtml">romain@marvin ~ % zfs list /usr/ports /var/cache/portshaker /var/cache/portshaker/freebsd
NAME                                USED  AVAIL  REFER  MOUNTPOINT
data/usr/ports                     57,1M  80,9G   402M  /usr/ports
data/var/cache/portshaker           514M  80,9G  48,6M  /var/cache/portshaker
data/var/cache/portshaker/freebsd   427M  80,9G   390M  /var/cache/portshaker/freebsd</pre><p xmlns="http://www.w3.org/1999/xhtml">When merging, <tt>portshaker(8)</tt> snapshots the FreeBSD ports and clone them to the <em>target</em> ports tree.  This requires only a few seconds to achieve.</p>]]></description><link>http://romain.blogreen.org/blog/2009/11/introducing-zfs-support-in-portshaker/</link><category>FreeBSD</category><category>Sysadmin</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2009/11/introducing-zfs-support-in-portshaker/</guid><pubDate>Fri, 13 Nov 2009 23:09:00 GMT</pubDate></item></channel></rss>

