<?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>Sysadmin</title><link>http://romain.blogreen.org/categories/sysadmin/</link><description>Enjoying being the Bastard Operator From Hell.</description><link xmlns="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://romain.blogreen.org/categories/sysadmin/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>Thomson ST2030 Feature Key Sheet Template</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml"><a href="http://www.technicolor.com/">Technicolor</a>'s (ex. Thomson's) <a href="http://www.technicolorbroadbandpartner.com/telephony-solutions/products/product-detail.php?id=87">ST2030</a> <acronym title="Session Initiation Protocol">SIP</acronym> phone features 10 <em>feature keys</em> that can be used as <em>fast call keys</em> to reach a configured number by a single key-press.</p><p xmlns="http://www.w3.org/1999/xhtml" class="figure"><img src="http://romain.blogreen.org/images/st2030-feature-key.png" alt="[ST2030 Feature Keys location]" height="278" width="254"/><br/>Location of <em>Feature Keys</em> on the ST2030.</p><p xmlns="http://www.w3.org/1999/xhtml">I finally decided to configure these keys with proper numbers instead of browsing my directory each time I want to make a call.  But the phone only ships with a single paper sheet to hand-write the names corresponding to the configured numbers and my hand-writing is somewhat like what would produce a drunk cow with Creutzfeldt–Jakob disease.  I browsed the Internet for a sheet template to fill-in, print and cut, but was unable to find some.</p><p xmlns="http://www.w3.org/1999/xhtml">So, I took <a href="http://inkscape.org">Inkscape</a> and did one myself.  For your convenience, I make it available as the original <acronym title="Scalable Vector Graphics">SVG</acronym> file (so that you can fill-it before printing) and a <acronym title="Portable Document Format">PDF</acronym> file for those who like hand-writing:</p><ul xmlns="http://www.w3.org/1999/xhtml">
    <li><a href="http://romain.blogreen.org/files/thomson-st2030-feature-key-sheet-template.svg">Thomson ST2030 Feature Key Sheet Template <acronym title="Scalable Vector Graphics">SVG</acronym></a>;</li>
<li><a href="http://romain.blogreen.org/files/thomson-st2030-feature-key-sheet-template.pdf">Thomson ST2030 Feature Key Sheet Template <acronym title="Portable Document Format">PDF</acronym></a>.</li>
</ul><p xmlns="http://www.w3.org/1999/xhtml">If you don't have a precise idea of which numbers you call often, you can extract this information from <a href="http://www.asterisk.org/">Asterisk</a>'s log file.  In my case, my calls come from the <em>internal</em> context so I just did this to get the top-20 of the numbers I call:</p><pre xmlns="http://www.w3.org/1999/xhtml">% cat /var/log/asterisk/cdr-csv/Master.csv | grep '<strong>internal</strong>' | cut -d, -f3 | \
    sed -e 's|+33|0|' | sort | uniq -c | sort -nr | head -n 20</pre>]]></description><link>http://romain.blogreen.org/blog/2011/12/thomson-st2030-feature-key-sheet-template/</link><category>Sysadmin</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2011/12/thomson-st2030-feature-key-sheet-template/</guid><pubDate>Thu, 29 Dec 2011 15:44:32 GMT</pubDate></item><item><title>Additional note for a proper shebang</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml">I recently encountered a shell script lacking some functionality I wanted to rely on, and started editing it to provide a patch for the author.</p><p xmlns="http://www.w3.org/1999/xhtml">The first line of the script was:</p><pre xmlns="http://www.w3.org/1999/xhtml" class="sh_sh">#!/bin/bash -x</pre><p xmlns="http://www.w3.org/1999/xhtml">Those who know me might imagine how my eyes were bleeding (the other may want to read my previous entry about <a href="http://romain.blogreen.org/blog/2008/04/you-bash-users-are-driving-me-crazy/">writing portable shebang for shell scripts</a>), but this shows another problem one may encounter when porting a shell script with an invalid shebang.</p><p xmlns="http://www.w3.org/1999/xhtml">Let's assume the script has bashisms and we want to use bash to run it.  According to my previous post, you may want to write this:</p><pre xmlns="http://www.w3.org/1999/xhtml" class="sh_sh">#!/usr/bin/env bash -x</pre><p xmlns="http://www.w3.org/1999/xhtml">Unfortunately, this won't work: env(1) will look for a binary names <q>bash -x</q> in the <tt>$PATH</tt> and fail:</p><pre xmlns="http://www.w3.org/1999/xhtml">env: bash -x: No such file or directory</pre><p xmlns="http://www.w3.org/1999/xhtml">There is however a simple solution: the <tt>set</tt> builtin(1). The right syntax is:</p><pre xmlns="http://www.w3.org/1999/xhtml" class="sh_sh">#!/usr/bin/env bash
set -x</pre>]]></description><link>http://romain.blogreen.org/blog/2011/04/additional-note-for-a-proper-shebang/</link><category>Sysadmin</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2011/04/additional-note-for-a-proper-shebang/</guid><pubDate>Sat, 02 Apr 2011 13:43:00 GMT</pubDate></item><item><title>gpg: OpenPGP card not available: IPC write error</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml">If you reach this page searching the internet for this error and did not find anything usefull, it might be because the error you want to search is actually <q><em>Unknown</em> IPC command</q>.</p><p xmlns="http://www.w3.org/1999/xhtml">Basically, you may not have <tt>gpg-agent(1)</tt> running.  The man page gives a few pointer on how to run it, here is my way to do so, in <tt>${HOME}/.zshenv</tt>:</p><pre xmlns="http://www.w3.org/1999/xhtml" class="sh_sh">if ! pgrep -U `id -u` gpg-agent &gt;/dev/null 2&gt;&amp;1; then
    eval `gpg-agent --daemon --write-env-file "${HOME}/.gpg-agent-info"`
else
    eval `cat "${HOME}/.gpg-agent-info"`
    export GPG_AGENT_INFO
fi</pre><p xmlns="http://www.w3.org/1999/xhtml">Hope this will help someone :-)</p>]]></description><link>http://romain.blogreen.org/blog/2010/04/gpg-openpgp-card-not-available-ipc-write-error/</link><category>Sysadmin</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2010/04/gpg-openpgp-card-not-available-ipc-write-error/</guid><pubDate>Fri, 09 Apr 2010 08:35: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>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><item><title>Updating FreeBSD 7 (i386) to 8 (amd64)</title><description><![CDATA[<h3 xmlns="http://www.w3.org/1999/xhtml">Goal</h3><p xmlns="http://www.w3.org/1999/xhtml">Update to the latest FreeBSD version, switch to 64 bit, and switch to full ZFS. In short, use the best I can have (or what is supposed to be the best I can have) on my computer.</p><h3 xmlns="http://www.w3.org/1999/xhtml">Install an amd64 system</h3><p xmlns="http://www.w3.org/1999/xhtml">While cross compiling an amd64 system from i386 should be possible, I wanted to get sure that the <em>nouveau</em> video driver actually worked on amd64. I have so decided to install a fresh FreeBSD 8 on my system and perform a few tests before updating.</p><p xmlns="http://www.w3.org/1999/xhtml">At that time, FreeBSD 8-BETA2 was just available, so I downloaded and installed it on a fresh partition created in place of the mysterious free space at the end of my hard disk:</p><pre xmlns="http://www.w3.org/1999/xhtml"># mkdir goinfre/FreeBSD
# cd goinfre/FreeBSD
# mkdir base kernels manpages
# ftp -a ftp.freebsd.org
ftp&gt; cd /pub/FreeBSD/releases/amd64/8.0-BETA2/base
ftp&gt; lcd base
ftp&gt; mget *
ftp&gt; cd ../kernels
ftp&gt; lcd ../kernels
ftp&gt; mget *
ftp&gt; cd ../manpages
ftp&gt; lcd ../manpages
ftp&gt; mget *
ftp&gt; bye
# ( cd base &amp;&amp; DESTDIR=/goinfre sh install.sh )
# ( cd kernels &amp;&amp; DESTDIR=/goinfre sh install.sh generic )
# mv /goinfre/boot/GENERIC /goinfre/boot/kernel
# ( cd manpages &amp;&amp; DESTDIR=/goinfre sh install.sh )
# bsdlabel -w -B -b /goinfre/boot/boot /dev/ad10s3</pre><p xmlns="http://www.w3.org/1999/xhtml">Since my hardware BIOS sucks when it is supposed to give up control of USB to the kernel, USB is disabled in my BIOS and I have no keyboard to choose from which slice to boot when the system starts. I have so to instruct the boot manager to boot on the third slice on next boot:</p><pre xmlns="http://www.w3.org/1999/xhtml"># boot0cfg -s 3 ad10</pre><p xmlns="http://www.w3.org/1999/xhtml">I then rebooted and setup FreeBSD 8-BETA2 networking, patched the kernel sources, checked that the <em>nouveau</em> video driver worked as expected, installed packages, and so on.</p><h3 xmlns="http://www.w3.org/1999/xhtml">Setting up the disks</h3><p xmlns="http://www.w3.org/1999/xhtml">I basically followed instructions from the blog post <a href="http://lulf.geeknest.org/blog/freebsd/Setting_up_a_zfs-only_system/">Setting up a zfs-only system</a> by <a href="http://lulf.geeknest.org/about/">Ulf Lilleengen (nanolulf)</a>, adjusting settings according to my system (4 GB swap, all available space for the ZFS partition):</p><pre xmlns="http://www.w3.org/1999/xhtml"># gpart delete -i 1 ad12
# gpart destroy ad12
# gpart create -s GPT ad12
# gpart add -b 34 -s 128 -t freebsd-boot ad12
# echo "4 * 1024*1024*1024 / 512" | bc
8388608
# gpart add -b 162 -s 8388608 -t freebsd-swap ad12
# gpart show ad12
=&gt;       34  625142381  ad12  GPT  (298G)
         34        128     1  freebsd-boot  (64K)
        162    8388608     2  freebsd-swap  (4.0G)
    8388770  616753645        - free -  (294G)
# gpart add -b 8388770 -s 616753645 -t freebsd-zfs ad12
# gpart bootcode -b /boot/pmbr ad12
# gpart bootcode -p /boot/gptzfsboot -i 1 ad12</pre><p xmlns="http://www.w3.org/1999/xhtml">Then I created the various ZFS filesystems and extracted FreeBSD 8 stable (well, still named 8.0-RC1 actually)</p><pre xmlns="http://www.w3.org/1999/xhtml"># zpool create data /dev/ad12p3
# zfs create data/tmp
# zfs create data/usr
# zfs create data/var</pre><h3 xmlns="http://www.w3.org/1999/xhtml">Installing FreeBSD 8 from sources</h3><p xmlns="http://www.w3.org/1999/xhtml">Since I had the right branch of the FreeBSD subversion repository checked in into the <em>temporary</em> FreeBSD 8 system — with local patches — I copied it to the ZFS filesystem and updated it.</p><pre xmlns="http://www.w3.org/1999/xhtml"># cp -R /usr/src /data/usr
# cd /data/usr/src
# svn up
# make buildworld buildkernel
# make DESTDIR=/data installworld
# make DESTDIR=/data installkernel
# make DESTDIR=/data distribution</pre><p xmlns="http://www.w3.org/1999/xhtml">I then customezed <tt>/boot/loader.conf</tt>:</p><pre xmlns="http://www.w3.org/1999/xhtml">cat &lt;&lt; EOT &gt; /data/boot/loader.conf
nouveau_load=yes
zfs_load=yes
vfs.root.mountfrom="zfs:data"
EOT</pre><p xmlns="http://www.w3.org/1999/xhtml">Configured the swap device:</p><pre xmlns="http://www.w3.org/1999/xhtml">cat &lt;&lt; EOT &gt; /data/etc/fstab
# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/ad12p2             none            swap    sw              0       0
EOT</pre><p xmlns="http://www.w3.org/1999/xhtml">Customised new <tt>/etc/make.conf</tt>:</p><pre xmlns="http://www.w3.org/1999/xhtml">cat &lt;&lt; EOT &gt; /data/etc/make.conf
LOADER_ZFS_SUPPORT=YES
EOT</pre><p xmlns="http://www.w3.org/1999/xhtml">Setup the network in <tt>/etc/rc.conf</tt>:</p><pre xmlns="http://www.w3.org/1999/xhtml">cat &lt;&lt; EOT &gt; /data/etc/rc.conf
# This file now contains just the overrides from /etc/defaults/rc.conf.
# Please make all changes to this file, not to /etc/defaults/rc.conf.

# Enable network daemons for user convenience.
ifconfig_rl0="inet 192.168.63.42  netmask 255.255.255.0"
defaultrouter="192.168.63.1"
hostname="marvin.blogreen.org"

named_enable="YES"
# asterisk_enable="YES"
# dbus_enable="YES"
# hald_enable="YES"

# gdm_enable="YES"
# gdm_lang="fr_FR.UTF-8"
EOT</pre><p xmlns="http://www.w3.org/1999/xhtml">I finally finished the ZFS setup:</p><pre xmlns="http://www.w3.org/1999/xhtml"># zfs export data &amp;&amp; zfs import data
# cp /boot/zfs/zpool.cache /data/boot/zfs
# zfs set mountpoint=legacy data
# zfs set mountpoint=/usr data/usr
# zfs set mountpoint=/var data/var
# zpool set bootfs=data data</pre><p xmlns="http://www.w3.org/1999/xhtml">I then booted the fresh install from ZFS and finished the system configuration:</p><pre xmlns="http://www.w3.org/1999/xhtml"># passwd
# tzsetup
# adduser</pre><h3 xmlns="http://www.w3.org/1999/xhtml">Mirroring data</h3><p xmlns="http://www.w3.org/1999/xhtml">Since I have two identical disks on my system and wanted to have some kind of redundancy for a while, I set-up the second disk as a mirror of the first one.</p><p xmlns="http://www.w3.org/1999/xhtml">First, I prepared the old disk so it has the same structure as the new with the ZFS filesystem:</p><pre xmlns="http://www.w3.org/1999/xhtml"># gpart show ad10
=&gt;       63  625142385  ad10  MBR  (298G)
         63  104856192     1  freebsd  (50G)
  104856255  419425020     2  freebsd  (200G)
  524281275  100856070     3  freebsd  (48G)
  625137345       5103        - free -  (2.5M)
# gpart delete -i 1 ad10
# gpart delete -i 2 ad10
# gpart delete -i 3 ad10
# gpart destroy ad10
# gpart create -s GPT ad10
# gpart add -b 34 -s 128 -t freebsd-boot ad10
# gpart add -b 162 -s 8388608 -t freebsd-swap ad10
# gpart show ad10
=&gt;       34  625142381  ad10  GPT  (298G)
         34        128     1  freebsd-boot  (64K)
        162    8388608     2  freebsd-swap  (4.0G)
    8388770  616753645        - free -  (294G)
# gpart add -b 8388770 -s 616753645 -t freebsd-zfs ad10
# gpart bootcode -b /boot/pmbr ad10
# gpart bootcode -p /boot/gptzfsboot -i 1 ad10</pre><p xmlns="http://www.w3.org/1999/xhtml">I added my new 4 Gib swap to <tt>/etc/fstab</tt> and enabled it:</p><pre xmlns="http://www.w3.org/1999/xhtml"># echo "/dev/ad10p2             none            swap    sw              0       0" &gt;&gt; /etc/fstab
# swapon /dev/ad10p2</pre><p xmlns="http://www.w3.org/1999/xhtml">I could then tell ZFS to mirror ad10p3 and ad12p3:</p><pre xmlns="http://www.w3.org/1999/xhtml"># zpool attach data ad12p3 ad10p3
# zpool status
  pool: data
 state: ONLINE
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.
 scrub: resilver in progress for 0h2m, 0.35% done, 13h33m to go
config:

	NAME        STATE     READ WRITE CKSUM
	data        ONLINE       0     0     0
	  mirror    ONLINE       0     0     0
	    ad12p3  ONLINE       0     0     0  44.6M resilvered
	    ad10p3  ONLINE       0     0     0  754M resilvered

errors: No known data errors</pre><p xmlns="http://www.w3.org/1999/xhtml">The nice part is of course that you can continue to use the system while you are doing all this!</p>]]></description><link>http://romain.blogreen.org/blog/2009/10/updating-freebsd-7-i386-to-8-amd64/</link><category>FreeBSD</category><category>Sysadmin</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2009/10/updating-freebsd-7-i386-to-8-amd64/</guid><pubDate>Thu, 29 Oct 2009 09:32:00 GMT</pubDate></item><item><title>You! Yes you! Help saving BSD Magazine!</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml">I have been a subscriber for <a href="http://www.bsdmag.org/">BSD Magazine</a> since the first issue.</p><p xmlns="http://www.w3.org/1999/xhtml">While the targeted audience is definitively not the *BSD kernel hacker, and despite the fact that each issue (so far) is spotted on a BSD flavor; the diversity of the articles featured in the magazine will make any Free Software enthusiast find useful information.</p><p xmlns="http://www.w3.org/1999/xhtml">I never wrote a review about the magazine before, mainly because a lack of time, and now might be a bit too late. At the time of writing, BSD Magazine is likely to be discontinued because of lower benefits than expected :-(.</p><p xmlns="http://www.w3.org/1999/xhtml">However, BSD Magazine is not dead yet and can still be saved! How? Many ways:</p><ul xmlns="http://www.w3.org/1999/xhtml"><li>Buy one copy of BSD Magazine. If you can't find it, visit the <a href="http://www.bsdmag.org/">BSD Magazine website</a> and tell them. You can also order the latest issue from <a href="http://www.freebsdmall.com/cgi-bin/fm/bsdmag.05?id=GSxAr4WU&amp;mv_pc=34">FreeBSD Mall</a> with a discount;</li><li><a href="http://bsdmag.org/prt/view/subscribe.html">Subscribe to the print or electronic subscription</a>;</li><li>Spread the word. Speak about it on your website, blog, etc. Microblog about it (using the <tt>#savebsdmag</tt> hashtag).</li><li><a href="http://bsdmag.org/prt/view/advertising-inquirie.html">Advertise in BSD Magazine</a> if you have something related to *BSD or FreeSoftware to sell.</li></ul><p xmlns="http://www.w3.org/1999/xhtml" class="figure">
<img src="http://romain.blogreen.org/files/01_2008_BSD_200.jpg" alt="Cover of the 01_2008 issue of BSD Magazine"/>
<img src="http://romain.blogreen.org/files/02_2008_BSD_200.jpg" alt="Cover of the 02_2008 issue of BSD Magazine"/>
<img src="http://romain.blogreen.org/files/01_2009_BSD_400.jpg" alt="Cover of the 01_2008 issue of BSD Magazine"/>
<img src="http://romain.blogreen.org/files/02_2009_BSD_400.jpg" alt="Cover of the 02_2009 issue of BSD Magazine"/>
<img src="http://romain.blogreen.org/files/03_2009_BSD_200.jpg" alt="Cover of the 03_2009 issue of BSD Magazine"/>
</p>]]></description><link>http://romain.blogreen.org/blog/2009/07/you-yes-you-help-saving-bsd-magazine/</link><category>FreeBSD</category><category>Sysadmin</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2009/07/you-yes-you-help-saving-bsd-magazine/</guid><pubDate>Fri, 03 Jul 2009 10:49:00 GMT</pubDate></item><item><title>Enlève tes doigts d'ici gamin!</title><description><![CDATA[<p xmlns="http://www.w3.org/1999/xhtml"><a href="http://www.gnome.org/~veillard/gamin/index.html">Gamin</a> has been recently <a href="http://www.freebsd.org/cgi/getmsg.cgi?fetch=680353+0+current/cvs-ports">patched</a> on FreeBSD. This may change dramaticaly the way you use USB sticks, so here is a quick tutorial (for those who don't speak french, the title says <q>put your fingers away kid</q>).</p><h3 xmlns="http://www.w3.org/1999/xhtml">What you used to do</h3><ol xmlns="http://www.w3.org/1999/xhtml">
  <li>plug your USB device in. The device automagically appears on the desktop and by default a file manager window shows its contents;</li>
  <li>copy your files;</li>
  <li>left-click the device and select <q>Unmount Volume</q>;</li>
  <li>click <q>Ok</q> when a message dialog tells you that the volume cannot be unmounted :-s;</li>
  <li>Choose one:<ul>
    <li>If you are a violent person,<ol>
      <li>open a terminal;</li>
      <li>run <tt>killall -9 gam_server &amp;&amp; umount /media/KINGSTON</tt></li>
      <li>unplug your USB device.</li>
    </ol></li>
    <li>If you are <strong>not</strong> a violent person,<ol>
      <li>save your work;</li>
      <li>close your session;</li>
      <li>log-in into a console;</li>
      <li>run <tt>gnome-unmount --pseudonym KINGSTON</tt></li>
      <li>unplug your USB device;</li>
      <li>log-out from the console and log-in to X.</li>
    </ol></li>
  </ul></li>
</ol><h3 xmlns="http://www.w3.org/1999/xhtml">The new way of doing it</h3><ol xmlns="http://www.w3.org/1999/xhtml">
  <li>plug your USB device in. The device automagically appears on the desktop and by default a file manager window shows its contents;</li>
  <li>copy your files;</li>
  <li>left-click the device and select <q>Unmount Volume</q>;</li>
  <li>unplug your USB device :-D.</li>
</ol><p xmlns="http://www.w3.org/1999/xhtml">I'm not sure that FreeBSD is the platform of choice for beginners, but this problem was really irritating. Having it fixed may help people discovering FreeBSD not running away screaming I guess.</p>]]></description><link>http://romain.blogreen.org/blog/2009/04/enleve-tes-doigts-dici-gamin/</link><category>FreeBSD</category><category>Sysadmin</category><guid isPermaLink="true">http://romain.blogreen.org/blog/2009/04/enleve-tes-doigts-dici-gamin/</guid><pubDate>Sat, 18 Apr 2009 09:53:00 GMT</pubDate></item></channel></rss>

