<?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>nlrs&#039; home</title>
	<atom:link href="http://www.nlrs.fr/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nlrs.fr</link>
	<description></description>
	<lastBuildDate>Sun, 17 May 2015 01:23:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.39</generator>
	<item>
		<title>Test build for LibreSSL</title>
		<link>http://www.nlrs.fr/2014/07/14/test-build-for-libressl/</link>
		<comments>http://www.nlrs.fr/2014/07/14/test-build-for-libressl/#comments</comments>
		<pubDate>Mon, 14 Jul 2014 00:00:21 +0000</pubDate>
		<dc:creator><![CDATA[Nico]]></dc:creator>
				<category><![CDATA[Crypto]]></category>
		<category><![CDATA[OpenSSL]]></category>

		<guid isPermaLink="false">http://www.nlrs.fr/?p=1340</guid>
		<description><![CDATA[LibreSSL has been released this weekend, so here is some steps to build a first version usuable in parallel with the default OpenSSL library of the system (Gentoo in my case). Compilation Get the source from OpenBSD FTP, verify its &#8230; <a href="http://www.nlrs.fr/2014/07/14/test-build-for-libressl/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.libressl.org/" target="_blank">LibreSSL</a> has been released this weekend, so here is some steps to build a first version usuable in parallel with the default OpenSSL library of the system (Gentoo in my case).<br />
<span id="more-1340"></span></p>
<h1>Compilation</h1>
<p>Get the source from <a href="http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/" target="_blank">OpenBSD FTP</a>, verify its checksum and compile it using some of the hardened Gentoo <a href="https://wiki.gentoo.org/wiki/Hardened/FAQ#Do_I_need_to_pass_any_flags_to_LDFLAGS.2FCFLAGS_in_order_to_turn_on_hardened_building.3F" target="_blank">compilation flags</a> :</p>
<pre>sha256sum libressl-2.0.1.tar.gz # Compare with http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/SHA256
./configure CFLAGS="-O2 -march=native -fstack-protector-all -fPIE" LDFLAGS="-Wl,-z,now -Wl,-z,relro -pie"
make -j 2
</pre>
<p>Install the binary and libraries in the <strong>/opt</strong> repertory, to leave the default OpenSSL usuable :</p>
<pre># mkdir /opt/libressl
# cp ./ssl/.libs/libssl.so.27 /opt/libressl
# cp ./crypto/.libs/libcrypto.so.30 /opt/libressl
# cp apps/.libs/openssl /opt/libressl/libressl
# chmod 555 /opt/libressl/*.so*
# chmod 755 /opt/libressl/libressl</pre>
<p>Then create a script to start it, for example <strong>/usr/local/bin/libressl</strong> :</p>
<pre>#!/bin/bash

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/libressl
/opt/libressl/libressl "$@"
</pre>
<p>Then :</p>
<pre>$ libressl version
LibreSSL 2.0
</pre>
<p>LibreSSL can now be used as a standalone tool to make some tests on its command line functions (generate keys, certificates, and so on), but the other programs will still use the OpenSSL library, until the port system <a href="https://bugs.gentoo.org/show_bug.cgi?id=508750" target="_blank">makes changes</a> to allow multiple versions of OpenSSL.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nlrs.fr/2014/07/14/test-build-for-libressl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Password Safe</title>
		<link>http://www.nlrs.fr/2014/06/26/password-safe/</link>
		<comments>http://www.nlrs.fr/2014/06/26/password-safe/#comments</comments>
		<pubDate>Thu, 26 Jun 2014 00:00:45 +0000</pubDate>
		<dc:creator><![CDATA[Nico]]></dc:creator>
				<category><![CDATA[Crypto]]></category>

		<guid isPermaLink="false">http://www.nlrs.fr/?p=1302</guid>
		<description><![CDATA[The 2014 year is, so far, disturbing for people who care about the security of their data. The deeper serious people dig into openssl, the weaker it seems, and corporations still consider than unsalted md5&#8217;s are the state of art &#8230; <a href="http://www.nlrs.fr/2014/06/26/password-safe/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>The 2014 year is, so far, disturbing for people who care about the security of their data. The deeper <a href="http://www.libressl.org/" target="_blank">serious people</a> dig into openssl, the weaker it seems, and corporations still consider than unsalted md5&#8217;s are the state of art for storing passwords in their <a href="http://www.theguardian.com/technology/2014/jun/16/dominos-pizza-ransom-hack-data" target="_blank">customer databases</a>.<br />
So time as come for the password spring-cleaning, and it is now obvious that a tool is required for remember the distinct <span style="text-decoration: underline;">passphrases</span> (<a href="https://www-ssl.intel.com/content/www/us/en/forms/passwordwin.html" target="_blank">15+ characters</a>) required to maintain some security online.<br />
<span id="more-1302"></span><br />
Two tools are prevalent for this job, <strong>KeepAss</strong> and <strong>Password Safe</strong>. Even if KeepAss seems serious (it has <b class="b3">r</b><b class="b2">eceive</b><b class="b3">d</b> the <a href="http://www.ssi.gouv.fr/IMG/cspn/anssi-cspn_2010-07fr.pdf" target="_blank">first level</a> of certification of the french IT securiy agency), it relies on the <code>System.Security</code> library provided by the .NET bulls<code>^W</code> framework and I prefer to stay away from the <code>mono</code> execution environment. Instead, Password Safe, which is now available as a native port for GNU/Linux (but still in beta), seems to be a better alternative (it was first designed and still recommended by <a href="https://www.schneier.com/" target="_blank">B. Schneier</a>).</p>
<h1>Build on Gentoo</h1>
<p>There is no Gentoo package available yet for Password Safe, but it can be built easily from source. Once the .tar.gz archive for source and its corresponding signature are downloaded, import the <a href="http://passwordsafe.sourceforge.net/contact.shtml" target="_blank">key used</a> to sign the packages, and verify the archive :</p>
<pre>$ gpg --keyserver pgp.mit.edu --recv-keys 5CCF8BB3
$ gpg --verify pwsafe-0.93BETA-src.tgz.sig</pre>
<p>Then, install the packages required as dependencies :</p>
<pre># emerge -va x11-libs/wxGTK:2.8 dev-libs/xerces-c</pre>
<p>Then build Password Safe without Yubikey support :</p>
<pre>$ NO_YUBI=1 make release</pre>
<h1>Security</h1>
<p>Password safe had a <a href="http://cvemap.org/cvevendor/891/counterpane/" target="_blank">few vulnerabilities</a> since its creation, especially in its <a href="https://www.schneier.com/paper-low-entropy.pdf" target="_blank">key derivation </a>function <a href="#note1">[1] </a><a href="#note2">[2]</a>.<br />
A quick look at the current code will show the bases are serious : /dev/random is used as source of entropy, Twofish is used as encryption cipher and the difficulty for the password key derivation function can be adjusted (but I found <a href="http://sourceforge.net/p/passwordsafe/bugs/1196/" target="_blank">a little bug</a> &#8211; patch for V0.93 beta available <a href="http://www.nlrs.fr/wp-content/uploads/2014/06/iterations_slider.patch">here</a>).</p>
<p>The latest doubt about Password Safe was related to a SHA-256 calculation speed increase for brute-force attacks <a href="#note3">[3]</a>.<br />
Short explanation : <a href="http://en.wikipedia.org/wiki/Fear,_uncertainty_and_doubt" target="_blank">FUD</a>.<br />
Long explanation : Password Safe processes the SHA-256 iterations directly using the last SHA-256 hash result as input. The SHA-256 hash calculation is done in a main loop and internal values can be kept between iterations, so pre-processing and final hash calculations can be avoided for the <span id="result_box" class="short_text" lang="en"><span class="hps">intermediate</span></span> iterations in order  to increase hash speed <a href="#note4">[4]</a>. No weakness here, only an implementation optimization, <a href="https://github.com/bwall/JohnTheRipper/commit/47c0b27d125ccdc81f371e2b0b51fab7682ef69a" target="_blank">pushed</a> last year into John the Ripper and which brings a speed increase of <a href="http://comments.gmane.org/gmane.comp.security.openwall.john.devel/7034" target="_blank">about 10%</a> for a brute-force attack. Since then, Password Safe offers the possibility to increase the number of iterations for key derivation from 2048 (default) to <span id="cwos" class="cwcot">4194304, hardening this type of attacks.</span></p>
<p>But keep in mind that GPUs, ASIC hardware or even the next Intel microarchitecture <a href="#note5">[5]</a> can process SHA-256 operations extremely fast, so the required number of iterations (a.k.a. &#8220;Unlock Difficulty&#8221; in the security options) <span style="text-decoration: underline;">must</span> be increased and a <span style="text-decoration: underline;">strong passphrase</span> must be used.<br />
The maximum difficulty can also be adjusted to a higher value in <strong>src/core/PWSfile.h</strong> (<a href="http://www.nlrs.fr/wp-content/uploads/2014/06/max_iterations.patch">patch here</a>). A value of 2^25 requires about 30s for unlocking on my current laptop, but greatly decreases the efficacy of a brute-force attack.</p>
<p>Additionally, it could also be a good idea to add some compilation flags to the default Makefile, as provided in <a href="http://www.nlrs.fr/wp-content/uploads/2014/06/Makefile.patch">this patch</a>.</p>
<p>&#8212;<br />
<a name="note1"></a>[1] : <a href="http://cxsecurity.com/cveshow/CVE-2005-3801" target="_blank">http://cxsecurity.com/cveshow/CVE-2005-3801</a><br />
<a name="note2"></a>[2] : <a href="http://sourceforge.net/p/passwordsafe/bugs/334/" target="_blank">http://sourceforge.net/p/passwordsafe/bugs/334/</a><br />
<a name="note3"></a>[3] : <a href="http://www.ballastsecurity.net/2012/07/auditing-of-password-safe-continues.html" target="_blank">http://www.ballastsecurity.net/2012/07/auditing-of-password-safe-continues.html</a><br />
<a name="note4"></a>[4] : <a href="http://csrc.nist.gov/groups/STM/cavp/documents/shs/sha256-384-512.pdf" target="_blank">http://csrc.nist.gov/groups/STM/cavp/documents/shs/sha256-384-512.pdf</a> (page 7)<br />
<a name="note5"></a>[5] : <a href="http://en.wikipedia.org/wiki/Intel_SHA_extensions" target="_blank">http://en.wikipedia.org/wiki/Intel_SHA_extensions</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nlrs.fr/2014/06/26/password-safe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FreeBSD 9.2 : Upgrade and SSH improvements</title>
		<link>http://www.nlrs.fr/2013/10/03/freebsd-9-2-upgrade-ssh-two-step-auth/</link>
		<comments>http://www.nlrs.fr/2013/10/03/freebsd-9-2-upgrade-ssh-two-step-auth/#comments</comments>
		<pubDate>Thu, 03 Oct 2013 09:35:18 +0000</pubDate>
		<dc:creator><![CDATA[Nico]]></dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://www.nlrs.fr/?p=1135</guid>
		<description><![CDATA[FreeBSD 9.2 have been released a few days ago, this post explains the required steps to upgrade a FreeBSD 9.1 host from source, and how to take advantage of an OpenSSH new feature in this release. Upgrade I&#8217;m assuming the host &#8230; <a href="http://www.nlrs.fr/2013/10/03/freebsd-9-2-upgrade-ssh-two-step-auth/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>FreeBSD 9.2 have been released a few days ago, this post explains the required steps to upgrade a FreeBSD 9.1 host from source, and how to take advantage of an OpenSSH new feature in this release.<br />
<span id="more-1135"></span><br />
<strong>Upgrade</strong><br />
I&#8217;m assuming the host is already running on FreeBSD 9.1. First, check the current mirror used by SVN :</p>
<pre># cd /usr/src &amp;&amp; svninfo</pre>
<p>Move the previously used <code>src</code> and <code>obj</code> repertories :</p>
<pre># mv /usr/src /usr/src.9_1
# mv /usr/obj /usr/obj.9_1</pre>
<p>Then, fetch the source from the <a href="http://www.freebsd.org/releases/9.2R/installation.html" target="_blank">releng/9.2</a> branch (in my case, from the <a href="http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/svn-mirrors.html" target="_blank">UK mirror</a>) :</p>
<pre># svn co https://svn0.eu.freebsd.org/base/releng/9.2 /usr/src</pre>
<p>Start to compile the world the usual way :</p>
<pre># cd /usr/src &amp;&amp; make -j&lt;NUMBER_OF_CPU&gt; buildworld</pre>
<p>Unfortunately, GCC failed to build some part of a llvm lib on my host :</p>
<pre>/usr/src/lib/clang/libllvminstcombine/../../../contrib/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1665: internal compiler error: in memory_address_length, at config/i386/i386.c:13897</pre>
<p>No matters what kind of error the good old GCC 4.2 could generate, I decided to switch to <code>clang/llvm</code>, which will be the default compiler on FreeBSD 10 anyway. This is done via <strong>/etc/src.conf</strong> :</p>
<pre>CC=clang
CXX=clang++
CPP=clang-cpp
CPUTYPE?=native</pre>
<p>Then I cleaned and rebuilt world. And guess what ? It worked.<br />
After that, follow the normal way to build / install a new version <a href="#note1">[1]</a>. Don&#8217;t forget to add the <code>auditdistd</code> user as requested by <code>mergemaster</code>, and to cleanup with <code>make delete-old</code> and <code>make delete-old-libs</code>.</p>
<h1>New features</h1>
<p>In FreeBSD 9.2, ZFS now include LZ4 compression, available after a pool upgrade via :</p>
<pre># zpool upgrade</pre>
<p>Remember : an upgraded pool could not be used anymore by the previous versions of FreeBSD, and this operation can not be reverted. Another useful ZFS change in this release is the display of the ARC cache usage in <code>top</code>.</p>
<p>But FreeBSD 9.2 also include the long awaited OpenSSH 6.2 instead of 5.8 <a href="#note2">[2]</a>. This version now include the <code>AuthenticationMethods</code> option <a href="#note3">[3]</a> required to use SSH keypair in combination with Google Authenticator <a href="#note4">[4]</a> (this was not possible before, because only one successful method out of all possible methods was required for a valid authentication).<br />
So, if you want to use an SSH keypair along with with Google Authenticator, first install the port :</p>
<pre># portmaster security/pam_google_authenticator</pre>
<p>Then generate a configuration file with the desired user account :</p>
<pre>$ google-authenticator</pre>
<p>And enable PAM in <strong>/etc/ssh/sshd_config</strong> :</p>
<pre>ChallengeResponseAuthentication yes
UsePAM yes</pre>
<p>As well as the authentication requirement for both public key and validation code (first require the public key) :</p>
<pre>AuthenticationMethods publickey,keyboard-interactive</pre>
<p>And enable the Google Authenticator module for PAM in <strong>/etc/pam.d/sshd</strong> (it replaces the password authentication for SSH, as a public key is already required by OpenSSH) :</p>
<pre>auth            required        /usr/local/lib/pam_google_authenticator.so
#auth           required        pam_unix.so             no_warn try_first_pass</pre>
<p>&#8212;<br />
<a name="note1"></a>[1] : <a href="http://www.freebsd.org/doc/handbook/makeworld.html" target="_blank">http://www.freebsd.org/doc/handbook/makeworld.html</a><br />
<a name="note2"></a>[2] : <a href="http://www.freebsd.org/releases/9.2R/relnotes.html" target="_blank">http://www.freebsd.org/releases/9.2R/relnotes.html</a><br />
<a name="note3"></a>[3] : <a href="http://lwn.net/Articles/544640/" target="_blank">http://lwn.net/Articles/544640/</a><br />
<a name="note4"></a>[4] : <a href="http://code.google.com/p/google-authenticator/issues/detail?id=40" target="_blank">http://code.google.com/p/google-authenticator/issues/detail?id=40</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nlrs.fr/2013/10/03/freebsd-9-2-upgrade-ssh-two-step-auth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZFS NAS in a FreeBSD jail</title>
		<link>http://www.nlrs.fr/2013/08/29/freebsd-zfs-nas-jail/</link>
		<comments>http://www.nlrs.fr/2013/08/29/freebsd-zfs-nas-jail/#comments</comments>
		<pubDate>Thu, 29 Aug 2013 00:00:50 +0000</pubDate>
		<dc:creator><![CDATA[Nico]]></dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[ZFS]]></category>

		<guid isPermaLink="false">http://www.nlrs.fr/?p=868</guid>
		<description><![CDATA[This article details all operations needed to setup a NAS based on FreeBSD 9.1 and ZFS in a jailed environnement. This is a updated version of this article, with a separate SSD for the OS (for lower noise and power consumption). &#8230; <a href="http://www.nlrs.fr/2013/08/29/freebsd-zfs-nas-jail/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This article details all operations needed to setup a NAS based on FreeBSD 9.1 and ZFS in a jailed environnement.<br />
<span id="more-868"></span><br />
This is a updated version of <a href="http://www.nlrs.fr/2011/07/01/nas-avec-freebsd-zfs/" target="_blank">this article</a>, with a separate SSD for the OS (for lower noise and power consumption).</p>
<h1>System setup</h1>
<p>FreeBSD 9.1 is a release of choice for this kind of installation, it brings support of TRIM and SHA-512 hash for passwords. ECC based protocols are included in OpenSSH since 9.0.</p>
<p>Before the setup, start the installation media in single user mode, then :</p>
<ul>
<li>Check if TRIM is listed on the tunables of the SSD drive : <code>/sbin/tunefs -p /dev/&lt;drive_id&gt;</code></li>
<li>If required, enable TRIM : <code>tunefs -t enable /dev/&lt;drive_id&gt;</code></li>
</ul>
<p>The system can be installed including src and ports.<br />
If required, new user can be assiged to wheel (for <code>su</code> access) and operator (for <code>shutdown</code> / <code>restart</code>) groups.</p>
<p>At first boot, perform the classic configuration operations :<br />
<code># echo 'ifconfig_&lt;interface_name&gt;="inet &lt;host_IP&gt; netmask &lt;host_mask&gt;"' &gt;&gt;<br />
/etc/rc.conf</code><br />
<code># echo 'ifconfig_&lt;interface_name&gt;="defaultrouter="&lt;router_IP&gt;""' &gt;&gt;<br />
/etc/rc.conf</code><br />
<code># echo 'nameserver &lt;DNS_IP&gt;' &gt;&gt; /etc/resolv.conf</code></p>
<p>For SSH, check if root login is disabled and restrict connections to host IP only to avoid conflicts with jails. In <strong>/etc/ssh/sshd.conf</strong> :</p>
<pre>PermitRootLogin no
ListenAddress &lt;host_IP&gt;</pre>
<p>Enable password for single user mode in <strong>/etc/ttys</strong> :</p>
<pre>console none unknown off insecure</pre>
<p>Enable SHA-512 for system passwords (<strong>/etc/login.conf</strong>) :</p>
<pre>default:\
     :passwd_format=sha512:\</pre>
<p><code># cap_mkdb /etc/login.conf<br />
# passwd<br />
# passwd &lt;existing_users&gt;</code></p>
<p>Then, configure the build environment :<br />
<code># cp /usr/share/examples/etc/make.conf /etc/</code></p>
<p>And adapt /etc/make.conf :</p>
<pre>CPUTYPE?=native   #'?=' allows to buildworld for a different CPUTYPE
MAKE_JOBS_NUMBER=&lt;number_of_CPU_cores&gt;</pre>
<p>Install subversion :<br />
<code># portsnap fetch extract &amp;&amp; cd /usr/ports/devel/subversion<br />
# make install clean</code></p>
<p>Then configure it and update the local source <a href="#note1">[1]</a> :<br />
<code># svn co https://svn0.eu.FreeBSD.org/base/releng/9.1 /usr/src</code></p>
<p>And rebuild the system :<br />
<code># make buildworld<br />
# make buildkernel<br />
# make installworld<br />
# make installkernel<br />
# reboot</code></p>
<p>Configure tcsh (<strong>~/.login_conf</strong>) :</p>
<pre>me:\
     :charset=UTF-8:\
     :lang=fr_FR.UTF-8:</pre>
<p>This settings can be checked with the <code>locale</code> command.</p>
<p>Install some essentials :<br />
<code># portsnap fetch extract<br />
# cd /usr/ports/ports-mgt/portmaster &amp;&amp; make install clean<br />
# portmaster editors/vim-lite<br />
# portmaster sysutils/ataidle</code></p>
<p>Enable power-savings options in <strong>/etc/rc.conf</strong> :</p>
<pre>powerd_flags="-b min"
powerd_enable="YES"
ataidle_enable="YES"
ataidle_devices="ada&lt;id&gt; ada&lt;id&gt; ada&lt;id&gt;"
ataidle_ada&lt;id&gt;="-I 150"
ataidle_ada&lt;id&gt;="-I 150"
ataidle_ada&lt;id&gt;="-I 150"</pre>
<p>Some kernel configuration is also necessary (<strong>/boot/loader.conf</strong>) :</p>
<ul>
<li>Force ZFS prefetch, which is disabled by default if the host have less than 4096MB of RAM.</li>
<li>Enable AHCI for NCQ support.</li>
<li>Enable thermal monitoring for AMD CPU (<code>$ sysctl dev.cpu.0.temperature</code>).</li>
</ul>
<pre>loader_logo="beastiebw"
vfs.zfs.prefetch_disable=0
ahci_load="YES"
amdtemp_load="YES"</pre>
<p>And finally, import the existing pool without mounting it (it will be mounted inside a jail) :<br />
<code>zpool import -N</code><br />
At this point, the host system is configured and all other features will be running in separate jail environments (in my case, in /usr/jails).</p>
<h1>Jails configuration</h1>
<p>Create the jail for the NAS environment :<br />
<code># cd /usr/src<br />
# make buildworld #If not already done<br />
# make installworld DESTDIR=/usr/jails/<br />
# make distribution DESTDIR=/usr/jails/<br />
# mount -t devfs devfs /usr/jails//dev</code></p>
<p>Next, configure this jail in /etc/rc.conf :</p>
<pre>ifconfig_&lt;interface_ID&gt;_alias&lt;jail_id&gt;="inet &lt;IP&gt;/&lt;mask_prefix&gt;"
jail_&lt;jail_name&gt;_hostname="&lt;hostname&gt;"
jail_&lt;jail_name&gt;_rootdir="/usr/jails/&lt;path&gt;"
jail_&lt;jail_name&gt;_devfs_enable="YES"
jail_&lt;jail_name&gt;_ip="&lt;IP&gt;"
jail_&lt;jail_name&gt;_exec_poststart0="/usr/jails/config/&lt;configuration_script&gt;.sh"</pre>
<p>The scripts located in <strong>/usr/jails/config</strong> and declared with <code>exec_poststart0</code> are launched at the jail startup, and could be used to set no-persistent configuration.<br />
Finally, enable the jail :</p>
<pre>jail_enable="YES"
jail_list="&lt;jail_name&gt;"</pre>
<h1>Generic jail configuration</h1>
<p>After the jail is started (<code>jls</code>), start a shell inside it :<br />
<code># jexec &lt;jail_id&gt; tcsh</code></p>
<p>By default in jails, there is no password for the root user, therefore the first thing to do is to set one :<br />
<code># passwd</code><br />
Or disable the user by adding a &#8216;*&#8217; character in the second field of <strong>/etc/passwd</strong> (using <code>vipw</code>).</p>
<p>Then, basic configuration for jails :<br />
<code># tzsetup<br />
# echo 'nameserver &lt;DNS_IP&gt;' &gt;&gt; /etc/resolv.conf</code></p>
<h1>NAS specific configuration</h1>
<p>First, enable SSH in /etc/rc.conf :</p>
<pre>sshd_enable="YES"</pre>
<p>In jails, SSH server must be binded to the IP alias of the jail, using the <code>listenadress</code> directive in /etc/ssh/sshd_config :</p>
<pre>ListenAddress &lt;jail_IP&gt;</pre>
<p>and I chose to disable all authentication methods except for certificates :</p>
<pre>PasswordAuthentication no
UsePAM no
ChallengeResponseAuthentication no
PermitRootLogin no</pre>
<p>SSH will be used with sshfs for NAS files access.</p>
<p>Now, existing ZFS pool can be imported into the jail. First, make sure there is no <code>zfs_enable="YES"</code> directive in the <strong>/etc/rc.conf </strong>file of the host so the pool will not be  mounted automatically at host level during the boot, but only when the NAS jail will start and explicitly mount the filesystems by calling the <code>zfs</code> command.</p>
<p>The ZFS datasets must be explicitly configured to be allow mouting in a jail with the <code>jailed</code> property (which is permanent) :</p>
<pre># zfs set jailed=on &lt;pool_or_dataset&gt;</pre>
<p>Then, create one or more users with the same uids than the owner of the files in the pool (in wheel group if necessary).</p>
<p>The operations required to mount the pool in the jail are performed in <a href="http://www.nlrs.fr/wp-content/uploads/2013/08/mount.sh_.txt" target="_blank">this script</a>, which must be called at jail startup using the <code>jail_exec_poststart0</code> directive.</p>
<p>Once the ZFS filesystem are mounted inside the jail, the ZFS mountpoints will remain the same in <code>zfs list</code>, but on the host, those mountpoints will be mounted under /usr/jails/&lt;jail_name&gt; from the <code>df view.<br />
</code></p>
<h1>Jail for remote access</h1>
<p>On my host, I also made a other dedicated jail for remote SSH access with port-knocking.<br />
Once logged into this jail, the other hosts / jails are reachable through another SSH connection on the local network.<br />
After the generic configuration of the jail, SSH was also configured to accept only certificates :</p>
<pre>ListenAddress &lt;jail_IP&gt;
PasswordAuthentication no
UsePAM no
ChallengeResponseAuthentication no
PermitRootLogin no</pre>
<p>Then SSH was configured to accept only connections from specific usernames and source IPs :</p>
<pre>AllowUsers &lt;username1&gt;@&lt;remote_IP1&gt; &lt;username2&gt;@&lt;remote_IP2&gt;</pre>
<p>sshd is only started on demand via a port-knocking mechanism, via knockd :<br />
<code># /usr/ports/security/knock<br />
# make config #only server part<br />
# make install clean</code></p>
<p>This feature require a specific devfs ruleset to allow bpf* devices to be accessible from the jail. If the configuration file does not already exists, copy the default file :</p>
<pre># cp /etc/defaults/devfs.rules /etc/devfs.rules</pre>
<p>Then, in <strong>/etc/devfs.rules</strong>, add a specific section :</p>
<pre># Knockd
[devfsrules_unhide_knockd=5]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add path 'bpf*' unhide</pre>
<p>This ruleset must be declared in /etc/rc.conf :</p>
<pre>jail_&lt;jail_name&gt;_devfs_ruleset="devfsrules_unhide_knockd"</pre>
<p>The knockd configuration is <a href="http://www.nlrs.fr/wp-content/uploads/2013/08/knockd.conf_.txt" target="_blank">available here</a>. It start the sshd, and modify the sshd_config file to accept connections from the knocking IP.<br />
It must be enabled with :</p>
<p><code>echo 'knockd_enable="YES"' &gt;&gt; /etc/rc.conf</code></p>
<p>sshd is automatically shutdown every five minutes via crond in order to refuse new connections and hide the service :</p>
<pre>*/5     *       *       *       *       root    /etc/rc.d/sshd onestop &amp;&gt; /dev/null</pre>
<p>But sshd keeps existing connections until they are intentionally closed, so this shutdown is transparent for existing sessions.</p>
<h1>Updating</h1>
<p>Source tree can be updated via svn update, and ports with portmasters -Da.<br />
In order to recompile only the required parts and save time recompile existing kernel and world with the following options :<br />
<code># make -DNO_KERNELCLEAN buildkernel<br />
# make -DNO_CLEAN -j&lt;NUMBER_OF_CORES&gt; buildworld</code></p>
<p>Jails can be updated with the usual <code>installworld</code> target :<br />
<code>make installworld DESTDIR=/usr/jails/&lt;jail&gt;</code></p>
<p>&#8212;<br />
<a name="note1"></a>[1] : <a href="http://www.freebsd.org/doc/handbook/svn.html" target="_blank">http://www.freebsd.org/doc/handbook/svn.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nlrs.fr/2013/08/29/freebsd-zfs-nas-jail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debian, DLNA and DMR devices</title>
		<link>http://www.nlrs.fr/2013/08/16/debian-dlna-dmr/</link>
		<comments>http://www.nlrs.fr/2013/08/16/debian-dlna-dmr/#comments</comments>
		<pubDate>Fri, 16 Aug 2013 00:00:45 +0000</pubDate>
		<dc:creator><![CDATA[Nico]]></dc:creator>
				<category><![CDATA[Audio]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.nlrs.fr/?p=1109</guid>
		<description><![CDATA[Recently, I spent some time wondering how to send the audio output of my laptop to a DLNA DMR (Digital Media Renderer) compliant HiFi device. DLNA Streaming The first step was to setup a classic DLNA streaming source with Rygel &#8230; <a href="http://www.nlrs.fr/2013/08/16/debian-dlna-dmr/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Recently, I spent some time wondering how to send the audio output of my laptop to a DLNA DMR (Digital Media Renderer) compliant HiFi device.<br />
<span id="more-1109"></span></p>
<h1>DLNA Streaming</h1>
<p>The first step was to setup a classic DLNA streaming source with Rygel using a Pulseaudio<code></code> module available in the <code>pulseaudio-module-rygel-media-server</code> package. This is done by adding the following options to <strong>/etc/pulse/default.pa</strong> :</p>
<pre>#dlna
load-module module-http-protocol-tcp
load-module module-rygel-media-server
load-module module-null-sink sink_name=dlna format=s16be channels=2 rate=44100 sink_properties="device.description='DLNA' device.bus='network' device.icon_name='network-server'"</pre>
<p>At this point, Pulseaudio create a new virtual output device named dlna.<br />
Then, Rygel is used to serve this output with the DLNA protocol. In <strong>~/.config/rygel.conf</strong> :</p>
<pre>[GstLaunch]
enabled=true
launch-items=pulseaudio_out
pulseaudio_out-title=Audio output on @HOSTNAME@
pulseaudio_out-mime=audio/mpeg
pulseaudio_out-launch=pulsesrc device=dlna.monitor</pre>
<p>Here, no shameful on-the-fly encoding with <code>lamemp3</code>, first because Rygel already provides built-in transcoding in MP3, and also because a WiFi network is strong enough to handle a PCM stream. This format has the advantage to avoid an additional encoding in an other lossly codec, which is a bad idea for audio quality.<br />
The LPCM transcoding is set this way in the Rygel configuration :</p>
<pre>transcoders=lpcm</pre>
<p>All other features of Rygel (Tracker, MediaExport and Playbin) are disabled in my case.</p>
<p>At this point, an URL providing the stream is available on the local machine, but there is no way for me to call it directly from the DMR.<br />
This is why the <code>gupnp-dlna-tools</code> package is required. It provides a few tools to manage DLNA devices, and more especially the <code>gupnp-av-cp</code> command. This command manages all the URL calls (for example, it sends the CurrentURI parameter) in order to control the DMR and fetch the laptop output from it.<br />
So after starting <code>rygel</code> and set the default audio output to the DLNA device, just launch <code>gupnp-av-cp</code> to define the source and the destination of the stream : the output must be redirected.</p>
<h1>Spotify</h1>
<p>By default, wine don&#8217;t use Pulseaudio, so Spotify started with wine can&#8217;t be streamed via DLNA with this method. The working solutions are the web-based player (but it uses MP3 instead of OGG, and Flash. : two good reasons to avoid it), or the native client for Linux.</p>
<p>This client can be downloaded from the <a href="http://repository.spotify.com/pool/non-free/s/spotify/" target="_blank">Spotify official repo</a>, but it requires openssl in a version not provided in Jessie.<br />
In order to keep standard versions of the system libraries, I manually downloaded <a href="http://packages.debian.org/squeeze/amd64/openssl/download" target="_blank">openssl</a> (for x86_64), then I installed Spotify in <strong>/opt</strong> :</p>
<pre># mkdir /opt/spotify
# dkpg -x &lt;spotify_package.deb&gt; /opt/spotify
# cd /opt/spotify &amp;&amp; mv opt/spotify/spotify-client .
# dpkg -x &lt;ssl_package.deb&gt; /opt/spotify
# cd /opt/spotify &amp;&amp; mv usr/lib .
# rm -rf /opt/spotify/usr &amp;&amp; rm -rf /opt/spotify/opt</pre>
<p>It can now be started after setting the LD_LIBRARY_PATH variable manually :</p>
<pre>#!/bin/bash
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/spotify/lib /opt/spotify/spotify-client/spotify</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nlrs.fr/2013/08/16/debian-dlna-dmr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Audio codecs, keep it real.</title>
		<link>http://www.nlrs.fr/2013/05/08/audio-codecs-keep-it-real/</link>
		<comments>http://www.nlrs.fr/2013/05/08/audio-codecs-keep-it-real/#comments</comments>
		<pubDate>Wed, 08 May 2013 00:00:53 +0000</pubDate>
		<dc:creator><![CDATA[Nico]]></dc:creator>
				<category><![CDATA[Compression]]></category>

		<guid isPermaLink="false">http://www.nlrs.fr/?p=927</guid>
		<description><![CDATA[After trying to find some decent qualitative analysis of AAC / OGG codecs online, I didn&#8217;t manage to find a correct or recent one, so I decided to make a test by myself. Those tests have been made with the &#8230; <a href="http://www.nlrs.fr/2013/05/08/audio-codecs-keep-it-real/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>After trying to find some decent qualitative analysis of AAC / OGG codecs online, I didn&#8217;t manage to find a correct or recent one, so I decided to make a test by myself.<br />
<span id="more-927"></span><br />
Those tests have been made with the first aim to find the best candidate for audio storage on my Android phone. Possibles choices are quite limited, it only could be AAC or OGG. The audio sample used as source for the comparative was extracted from a compact disc by using <code>cdparanoia</code> and was choosen as a good representative of my usual listenings (English rock &#8211; Manchester / 1994).</p>
<p>The following tools were used for the compression :</p>
<ul>
<li>FAAC 1.28 :<br />
<code>faac input.wav -q &lt;quality&gt; -o output.aac</code></li>
<li>Vorbis tools 1.4.0 :<br />
<code>oggenc -q &lt;quality&gt; input.wav</code></li>
<li>Spectral analysis was made using a python script to compare spectral bands (available <a href="http://www.nlrs.fr/spectral-comparator/" target="_blank">here</a>) and Audacity to display the masking impact.</li>
</ul>
<p>Here are the results (attenuation (dB) / frequency (Hz)). For AAC :<br />
<a href="http://www.nlrs.fr/wp-content/uploads/2013/05/aac.png" target="_blank"><img class="alignnone size-full wp-image-1008" alt="AAC" src="http://www.nlrs.fr/wp-content/uploads/2013/05/aac.png" width="617" height="459" /></a></p>
<p>For OGG :<br />
<a href="http://www.nlrs.fr/wp-content/uploads/2013/05/ogg.png" target="_blank"><img class="alignnone size-full wp-image-1009" alt="OGG" src="http://www.nlrs.fr/wp-content/uploads/2013/05/ogg.png" width="616" height="467" /></a></p>
<p>And the corresponding quality parameter / filesize :</p>
<table border="0" cellspacing="0">
<tbody>
<tr>
<td align="LEFT" height="16">Quality</td>
<td align="LEFT">OGG</td>
<td align="LEFT"></td>
<td align="LEFT">Quality</td>
<td align="LEFT">AAC</td>
<td align="LEFT"></td>
<td align="LEFT">Lossless</td>
</tr>
<tr>
<td align="LEFT" height="15">3</td>
<td align="LEFT">3.2 MB</td>
<td align="LEFT"></td>
<td align="LEFT">70</td>
<td align="LEFT">3.1 MB</td>
<td align="LEFT"></td>
<td align="LEFT">41 MB</td>
</tr>
<tr>
<td align="LEFT" height="15">5</td>
<td align="LEFT">4.5 MB</td>
<td align="LEFT"></td>
<td align="LEFT">110</td>
<td align="LEFT">4.4 MB</td>
<td align="LEFT"></td>
<td align="LEFT"></td>
</tr>
<tr>
<td align="LEFT" height="15">6</td>
<td align="LEFT">5.6 MB</td>
<td align="LEFT"></td>
<td align="LEFT">140</td>
<td align="LEFT">5.5 MB</td>
<td align="LEFT"></td>
<td align="LEFT"></td>
</tr>
<tr>
<td align="LEFT" height="15">7</td>
<td align="LEFT">6.5 MB</td>
<td align="LEFT"></td>
<td align="LEFT">200</td>
<td align="LEFT"> 6.4 MB</td>
<td align="LEFT"></td>
<td align="LEFT"></td>
</tr>
<tr>
<td align="LEFT" height="15">8</td>
<td align="LEFT">7.8 MB</td>
<td align="LEFT"></td>
<td align="LEFT"> 325</td>
<td align="LEFT"> 7.7 MB</td>
<td align="LEFT"></td>
<td align="LEFT"></td>
</tr>
</tbody>
</table>
<p>First thoughts :</p>
<ul>
<li>AAC with quality &lt; 110 must be avoid if the file is not voice only, because it cuts middle and high frequencies .</li>
<li>At quality 200, AAC have a real good spectral resolution, close to the original file.</li>
<li>As frequencies &gt; 20 kHz is humanly inaudible or not rendered by the audio devices <a href="#note1">[1]</a>, OGG at quality 5 is the right choice to encode music and minimize the space usage (better resolution than ACC at level 110 for the same file size). This is also the quality level used by default by Spotify <a href="#note2">[2]</a>.</li>
<li>OGG at quality 6 provides a quite good spectral resolution, very close to OGG quality 7 and 8.</li>
<li>OGG at quality 6 is also the first level to enable lossless coupling <a href="#note3">[3]</a>, even if the (lossly) coupling can be disabled at fewer levels <a href="#note4">[4]</a> (quality 5 -&gt; quality 5 without coupling : size increased by 7%, still smaller files than quality 6).</li>
</ul>
<p>More specifically, here is the representation of the spectral removal. Original file :<br />
<a href="http://www.nlrs.fr/wp-content/uploads/2013/05/spectral_master.png" target="_blank"><img class="alignnone size-full wp-image-1011" alt="spectral_master" src="http://www.nlrs.fr/wp-content/uploads/2013/05/spectral_master.png" width="1256" height="143" /></a><br />
AAC at quality 200 :<br />
<a href="http://www.nlrs.fr/wp-content/uploads/2013/05/spectral_aac.png" target="_blank"><img class="alignnone size-full wp-image-1010" alt="spectral_aac" src="http://www.nlrs.fr/wp-content/uploads/2013/05/spectral_aac.png" width="1260" height="144" /></a><br />
OGG at quality 7 :<br />
<a href="http://www.nlrs.fr/wp-content/uploads/2013/05/spectral_ogg.png" target="_blank"><img class="alignnone size-full wp-image-1013" alt="spectral_ogg" src="http://www.nlrs.fr/wp-content/uploads/2013/05/spectral_ogg.png" width="1256" height="143" /></a></p>
<p>As we can see at the middle and the end of the sample, the amount of data required by the large spectral resolution of AAC is balanced by frequency cuts in the audible domain, more especially by a more agressive temporal masking <a href="#note5">[5]</a>, and to a lesser extent, by a more important simultaneous masking  <a href="#note6">[6]</a> than for OGG, which only cuts high (and inaudibles anyway) frequencies.</p>
<p>In summation, the first thing to do is to realize you likely did not hear high frequencies anymore <a href="#note1">[1, again]</a> (and if you don&#8217;t trust your equipment, just look at your cat/dog face while running the test).<br />
The best candidate for the specified usage seems to be <strong>OGG at quality 5</strong>, for the restrained masking in audible domain, the limited size and the good spectral resolution. It could be improved by disabling (lossly) coupling and it is also natively supported under Linux / Android.<br />
If you are young enouth to hear 20 kHz, OGG at quality 6 or AAC at quality 140 seems fine. And if, for weird reasons, you want to keep all inaudibles frequencies (music for your dog, maybe ?), AAC at quality 200 is the right choice.</p>
<p>&#8212;</p>
<p><a name="note1"></a>[1] : <a href="http://www.audiocheck.net/audiotests_frequencycheckhigh.php" target="_blank">http://www.audiocheck.net/audiotests_frequencycheckhigh.php</a><br />
<a name="note2"></a>[2] : <a href="http://support.spotify.com/se/learn-more/faq/#!/article/What-bitrate-does-Spotify-use-for-streaming" target="_blank">http://support.spotify.com/se/learn-more/faq/#!/article/What-bitrate-does-Spotify-use-for-streaming</a><br />
<a name="note3"></a>[3] : <a href="http://wiki.hydrogenaudio.org/index.php?title=Recommended_Ogg_Vorbis#Recommended_Encoder_Settings" target="_blank">http://wiki.hydrogenaudio.org/index.php?title=Recommended_Ogg_Vorbis#Recommended_Encoder_Settings</a><br />
<a name="note4"></a>[4] : <a href="http://wiki.hydrogenaudio.org/index.php?title=Recommended_Ogg_Vorbis#Enabling_and_disabling_Vorbis_5.1.2F7.1_Channel_Coupling_for_Use_in_Mainline" target="_blank">http://wiki.hydrogenaudio.org/index.php?title=Recommended_Ogg_Vorbis#Enabling_and_disabling_Vorbis_5.1.2F7.1_Channel_Coupling_for_Use_in_Mainline</a><br />
<a name="note5"></a>[5] : <a href="https://en.wikipedia.org/wiki/Auditory_masking#Temporal_masking" target="_blank">https://en.wikipedia.org/wiki/Auditory_masking#Temporal_masking</a><br />
<a name="note6"></a>[6] : <a href="https://en.wikipedia.org/wiki/Auditory_masking#Simultaneous_masking" target="_blank">https://en.wikipedia.org/wiki/Auditory_masking#Simultaneous_masking</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nlrs.fr/2013/05/08/audio-codecs-keep-it-real/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLite / PostgreSQL Migration</title>
		<link>http://www.nlrs.fr/2013/02/07/migration-sqlite-postgresql/</link>
		<comments>http://www.nlrs.fr/2013/02/07/migration-sqlite-postgresql/#comments</comments>
		<pubDate>Thu, 07 Feb 2013 00:00:04 +0000</pubDate>
		<dc:creator><![CDATA[Nico]]></dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.nlrs.fr/?p=848</guid>
		<description><![CDATA[Here is some operations made for a manual (but quick) SQLite / PostgreSQL migration. Data export First, export the data from SQLite : $ sqlite3 data.db sqlite&#62; .mode csv sqlite&#62; .separator ',' sqlite&#62; .output mydb.csv sqlite&#62; select field1, field2, field3 &#8230; <a href="http://www.nlrs.fr/2013/02/07/migration-sqlite-postgresql/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Here is some operations made for a manual (but quick) SQLite / PostgreSQL migration.<br />
<span id="more-848"></span></p>
<h1>Data export</h1>
<p>First, export the data from SQLite :</p>
<pre>$ sqlite3 data.db
sqlite&gt; .mode csv
sqlite&gt; .separator ','
sqlite&gt; .output mydb.csv
sqlite&gt; select field1, field2, field3 from mytable where param='value';</pre>
<p>The rows are now saved in the selected order in a CSV file.</p>
<h1>Data migration</h1>
<p>In my case, the size of the dump was small enough to make the following changes using a spreadsheet :</p>
<ul>
<li>Insert the &#8216;\&#8217; escape character before carriage returns, commas and existings &#8216;\&#8217; in text fiels.</li>
<li>Replace &#8216;0&#8217; or &#8216;1&#8217; by &#8216;true&#8217; or &#8216;false&#8217; values for the boolean fields.</li>
</ul>
<p>The database schema can be exported :</p>
<pre>sqlite&gt; .schema</pre>
<h1>PostgreSQL import</h1>
<p>The data can now be imported in PostgreSQL : first recreate the previously exported schema with the statement <code>CREATE &lt;table&gt;</code>. The rows import can be started with :</p>
<pre>psql # COPY &lt;table&gt; FROM '/path/to/my/file' DELIMITER ',';</pre>
<p>All data is now imported in the new database. It could be required to adjust the sequence of the generated primary key.<br />
If <code>SELECT MAX(&lt;id&gt;) FROM &lt;table&gt;;</code> is greater than <code>SELECT nextval('&lt;table&gt;_&lt;id&gt;_seq');</code> the sequence must be adjusted with the statement :</p>
<pre>SELECT setval('your_table_id_seq', (SELECT MAX(id) FROM your_table));</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nlrs.fr/2013/02/07/migration-sqlite-postgresql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debian on Vostro 3460</title>
		<link>http://www.nlrs.fr/2012/11/04/debian-vostro-3460/</link>
		<comments>http://www.nlrs.fr/2012/11/04/debian-vostro-3460/#comments</comments>
		<pubDate>Sun, 04 Nov 2012 00:00:37 +0000</pubDate>
		<dc:creator><![CDATA[Nico]]></dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.nlrs.fr/?p=778</guid>
		<description><![CDATA[This post summarize all the required steps to setup a operational GNU/Linux on a Dell Vostro 3460. After being a Fedora user during many years, I switched to Debian Wheezy to avoid the systemd philosophy (but I was also highly influenced by &#8230; <a href="http://www.nlrs.fr/2012/11/04/debian-vostro-3460/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This post summarize all the required steps to setup a operational GNU/Linux on a Dell Vostro 3460. After being a Fedora user during many years, I switched to Debian Wheezy to avoid the <code>systemd</code> philosophy (but I was <a href="https://twitter.com/GCUSquad/status/264460282435362817" target="_blank">also</a> <a href="https://twitter.com/GCUSquad/status/264454180901629953" target="_blank">highly</a> <a href="https://twitter.com/GCUSquad/status/264455116483088384" target="_blank">influenced</a> by <a href="https://twitter.com/GCUSquad/status/264453810225819648" target="_blank">Pinpin</a>).</p>
<p><span id="more-778"></span></p>
<h1>Installation media preparation</h1>
<p>First of all, copy the DVD1 into an USB stick :</p>
<pre># cat debian.iso &gt; /dev/sdX
# sync</pre>
<p>After a boot from this support, proceed with the classical installation, including the &#8220;Laptop&#8221; packages.</p>
<h1>Energy saving bug</h1>
<p>In the current kernel version (3.2.32-1) the power savings mechanism of Ivy Bridge platform is affected by a bug which leads to a random complete system freeze, more especially while using Firefox.</p>
<p>To get rid of this, the power savings mechanism can be disabled <a href="#note1">[1]</a>. In <code>/etc/default/grub</code>, set the following :</p>
<pre>GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.i915_enable_rc6=0"</pre>
<p>Then re-install grub with <code>update-grub</code>.<br />
This bug was corrected in more recent kernel versions.</p>
<h1>Drivers installation</h1>
<p>Once installed from scratch, the kernel does not detect neither the ethernet controller (Atheros AR813x), nor the WiFi chip (Dell 1704 / Broadcom 43142).</p>
<p>The WiFi driver is available <a href="http://jas.gemnetworks.com/debian/pool/main/w/wireless-bcm43142/" target="_blank">here</a>. Before installation, dkms must be installed from the ISO file (stored on an other partition for example) :</p>
<pre># mount -t iso9660 /path/to/debian-wheezy-DI-b3-amd64-DVD-1.iso /media/cdrom
# apt-cdrom add
# apt-get install dkms
# dpkg -i /path/to/wireless-bcm43142-dkms_&lt;version&gt;_amd64.deb</pre>
<p>The alx driver for the ethernet card is available <a href="http://www.linuxfoundation.org/collaborate/workgroups/networking/alx" target="_blank">here</a>. The installation must be done as documented in the project homepage :</p>
<pre>tar xvf compat-wireless-2012-05-10-p.tar.bz2
cd compat-wireless-2012-05-10-p/
./scripts/driver-select alx
make &amp;&amp; make install
modprobe alx</pre>
<p>The touchpad is detected as aPS/2 mouse by default. In fact this is an ALPS touchpad :</p>
<pre># tpconfig
Found Synaptics Touchpad.
Firmware: 8.96 (multiple-byte mode).</pre>
<p>The driver <a href="http://www.dahetral.com/public-download/psmouse-alps-dst-1.0.tbz" target="_blank">version 1.0</a> corrects the detection issue. To install it <a href="#note2">[2]</a> :</p>
<pre># mv psmouse-alps-dst-1.0 /usr/src
# cd /usr/src
# dkms build psmouse/alps-dst-1.0
# dkms install psmouse/alps-dst-1.0
# rmmod psmouse &amp;&amp; sudo modprobe -v psmouse</pre>
<p>Since september 2013, update the CPU microcode on boot is also recommended <a href="#note3">[3]</a> :</p>
<pre># apt-get install iucode-tool intel-microcode</pre>
<h1>Apt repositories configuration</h1>
<p>Since the sources list was not completed during installation, edit the <code>/etc/apt/sources.list</code> to add the closest repositories :</p>
<pre>deb http://ftp.fr.debian.org/debian/ wheezy main contrib non-free
deb http://ftp.fr.debian.org/debian/ wheezy-updates main</pre>
<p>and comment the entry added by the <code>apt-cdrom add</code> :</p>
<pre># deb cdrom:[Debian GNU/Linux wheezy-DI-b3 _Wheezy_ - Official Snapshot amd64 DVD Binary-1 20121012-12:02]/ wheezy contrib main</pre>
<p>Then, add te source for the <a href="http://jas.gemnetworks.com/" target="_blank">source</a> for the WiFi driver.</p>
<h1>Miscellaneous</h1>
<p>Flash is included in the flashplugin-nonfree package and the official JRE must be declared via <code>alternatives</code> :</p>
<pre># update-alternatives --install /usr/bin/java java /usr/java/jre1.7.0_09/bin/java 1
# update-alternatives --config java</pre>
<p>For Gnome 3, shortcuts can be added in the applications list with <code>alacarte</code> or in any repertory with <code>gnome-desktop-item-edit.</code><br />
The *slightly* too thick title bar can be reduced to a decent size with :</p>
<pre>sed -i "/title_vertical_pad/s/value=\"[0-9]\{1,2\}\"/value=\"0\"/g" /usr/share/themes/Adwaita/metacity-1/metacity-theme-3.xml</pre>
<p><code></code>To mount filesystems via ssh, Fuse is the best solution, especially for video playing with VLC. It can be installed with :</p>
<pre># apt-get gvfs-fuse sshfs fuse-utils
# adduser &lt;username&gt; fuse</pre>
<p>In the same domain, <code>usbmount</code> is required to mount external HDDs via USB with <code>ntfs-3g</code>.<br />
By default, the firefox theme is <b>poorly suited </b>to Gnome 3, but this can be adjusted by disabling the menu bar, and by enabling the dedicated <a href="https://addons.mozilla.org/fr/firefox/addon/adwaita/" target="_blank">theme</a> with an <a href="https://addons.mozilla.org/fr/firefox/addon/htitle/" target="_blank">extension</a> to disable title bar <a href="#note4">[4]</a>.</p>
<p>Finally, to avoid bips during completion with the tabulation key, uncomment <code>set bell-style none</code> in <code>/etc/inputrc</code> and add <code>set vb</code> in the file <code>~/.vimrc.</code></p>
<h1>Power management and temperature</h1>
<p>The graphics chip sleep mode (i915.i915_enable_rc6) is available only from the current unstable kernel (3.8.13). To install it, add the unstable repo in <strong>/etc/apt/sources.list</strong> :</p>
<pre>deb http://ftp.fr.debian.org/debian/ unstable main</pre>
<p>Then lock system upgrade from unstable by modifying its priority with the file <strong>/etc/apt/preferences</strong> :</p>
<pre>Package: *
Pin: release o=Debian,a=unstable
Pin-Priority: 102</pre>
<p>The kernel can be installed :</p>
<pre># apt-get -t unstable install linux-image-3.8-2-amd64</pre>
<p>Compatible drivers are available for <a href="https://launchpad.net/ubuntu/+source/bcmwl" target="_blank">WiFi</a> and <a href="http://www.dahetral.com/public-download/alps-psmouse-dlkm-for-3-2-and-3-5/view" target="_blank">touchpad</a> (the install is done the same way than for previous kernel versions).<br />
At this point, the power saving options can be enabled in <strong>/etc/default/grub</strong> :</p>
<pre>GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.i915_enable_rc6=3 i915.i915_enable_fbc=1 i915.lvds_downclock=1 pcie_aspm=force acpi_osi=Linux"</pre>
<p>Followed by a grub update for application :</p>
<pre># update-grub</pre>
<p>The CPU scaling governor can also be set to <strong>conservative</strong> via <code>cpufrequtils</code> to limit the CPU frequency <a href="#note5">[5]</a>. Temperature monitoring can me done with the <code>i8kctl temp </code>command, provided in the <code>i8kutils</code> package.</p>
<p>Finally, the kernel module for SD card reader can be disabled (it makes a lot of cpu events), and power saving mode for the audio chipset can be forced. In a new <strong>/etc/modprobe.d/power_savings.conf</strong> file, set :</p>
<pre>blacklist rts5139
options snd-hda-intel power_save=5
options snd-hda-intel power_save_controller=Y</pre>
<p>And to prevent <code>powerd</code> to overwrite this settings, disable the corresponding module via the <strong>/etc/pm/config.d/modules</strong> configuration file :</p>
<pre>HOOK_BLACKLIST="intel-audio-powersave"</pre>
<h1>H264 hardware acceleration</h1>
<p>To enable the MPEG2 and H.264 decoding by the graphics chipset, install the packages <code>libva-intel-vaapi-driver</code> and <code>vainfo</code>. The <code>vainfo</code> command will return all the video codecs supported by the GPU. Hardware acceleration is also natively supported by VLC, after enabling it in the preferences, and by mplayer in this<a href="https://launchpad.net/~sander-vangrieken/+archive/vaapi/+packages" target="_blank"> this build</a> <a href="#note6">[6]</a>.</p>
<p>&#8212;<br />
<a name="note1"></a>[1] : <a href="http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1075486.html" target="_blank">http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1075486.html</a><br />
<a name="note2"></a>[2] : <a href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/606238/comments/227" target="_blank">https://bugs.launchpad.net/ubuntu/+source/linux/+bug/606238/comments/227</a><br />
<a name="note3"></a>[3] : <a href="http://lists.debian.org/debian-user/2013/09/msg00126.html" target="_blank">http://lists.debian.org/debian-user/2013/09/msg00126.html</a><br />
<a name="note4"></a>[4] : <a href="http://libre-ouvert.toile-libre.org/index.php?article117/toi-aussi-gnome3-firefox-adwaita-htitle-movable-firefox-button-tab-bar-omnibar" target="_blank">http://libre-ouvert.toile-libre.org/index.php?article117/toi-aussi-gnome3-firefox-adwaita-htitle-movable-firefox-button-tab-bar-omnibar</a><br />
<a name="note5"></a>[5] : <a href="http://wiki.debian.org/HowTo/CpuFrequencyScaling" target="_blank">http://wiki.debian.org/HowTo/CpuFrequencyScaling</a><br />
<a name="note6"></a>[6] : <a href="http://devel.mplayer2.org/ticket/17" target="_blank">http://devel.mplayer2.org/ticket/17</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nlrs.fr/2012/11/04/debian-vostro-3460/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elliptic Curve Diffie-Hellman</title>
		<link>http://www.nlrs.fr/2012/08/25/elliptic-curve-diffie-hellman/</link>
		<comments>http://www.nlrs.fr/2012/08/25/elliptic-curve-diffie-hellman/#comments</comments>
		<pubDate>Sat, 25 Aug 2012 00:00:26 +0000</pubDate>
		<dc:creator><![CDATA[Nico]]></dc:creator>
				<category><![CDATA[Crypto]]></category>
		<category><![CDATA[OpenSSL]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://www.nlrs.fr/?p=732</guid>
		<description><![CDATA[Depuis l&#8217;intégration du chiffrement par courbes elliptiques à partir d&#8217;openSSH 5.7[1] (ECDSA), j&#8217;ai cherché à comprendre les mécanismes de base de cet échange de clés. Ceci est un (très) bref resumé des informations trouvées (voir biographie). Recommandations L&#8217;échange de clés &#8230; <a href="http://www.nlrs.fr/2012/08/25/elliptic-curve-diffie-hellman/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Depuis l&#8217;intégration du chiffrement par courbes elliptiques à partir d&#8217;openSSH 5.7<a href="#note1">[1]</a> (ECDSA), j&#8217;ai cherché à comprendre les mécanismes de base de cet échange de clés. Ceci est un (très) bref resumé des informations trouvées (voir biographie).</p>
<h1><span id="more-732"></span>Recommandations</h1>
<p>L&#8217;échange de clés Diffie-Hellman basé sur les courbes elliptiques (ECDH) est devenue la méthode recommandée pour le chiffrement asymétrique ces dernières années, notamment dans la &#8220;<a href="http://www.nsa.gov/ia/programs/suiteb_cryptography/index.shtml">Suite B</a>&#8221; publiée par la NSA en 2010<a href="#note2">[2]</a>, qui exclue totalement les protocoles basés sur le RSA ou le logarithme discret (DSA).</p>
<p>La NSA recommande l&#8217;utilisation de ECDH avec des clés de 256 bits ou 384 bits selon le niveau de confidentialité des informations. En France, l&#8217;ANSSI recommande une taille de clé d&#8217;au moins 256 bits pour l&#8217;ECDH<a href="#note3">[3]</a>. Étant donné son fonctionnement, le protocole ECDH nécessite des clés de taille beaucoup plus réduite que ses prédécesseurs tout en assurant le même niveau de sécurité. Il est conseillé d&#8217;utiliser des clés de 256 bits pour ECDH lorsqu&#8217;il est couplé avec AES en 128 bits, tandis que RSA nécessite une clé de 3072 bits pour assurer une sécurité équivalente<a href="#note4">[4]</a>.</p>
<h1>Protocole de l&#8217;échange de clés</h1>
<p>En résumé, l&#8217;échange de clé se déroule de la façon suivante :</p>
<ul>
<li>Accord entre A et B sur les paramètres de la courbe et un point commun <strong>P</strong> choisi au hasard sur cette courbe.</li>
<li>Génération de grands nombres aléatoires <strong>K</strong> par chacun des protagonistes. Ces nombres correspondent à leur clé privée.</li>
<li> A envoie <strong>Qa</strong> à B. <strong>Qa</strong> est un point sur la courbe correspondant à la multiplication du point P par la clé privée Ka de A. <strong>Qa</strong> correspond à la clé publique de A.</li>
<li>B envoie également sa clé publique <strong>Qb</strong> générée à partir de P et de sa clé privée privée Kb.</li>
<li>A et B peuvent maintenant calculer le secret partagé (Ka.Kb).P à partir de Kb.(Qa) et Ka.(Qb).</li>
<li>La clé utilisée pour le chiffrement proprement dit de la communication (avec AES par exemple) est générée  à partir d&#8217;un hash du secret partagé.</li>
</ul>
<p>Pour plus d&#8217;explication sur les mécanismes mathématiques en jeu dans cet échange, voir <a href="http://www-verimag.imag.fr/~plafourc/teaching/L2_08_ouverture.pdf" target="_blank">cette présentation</a>.</p>
<h1>Sécurité</h1>
<p>Il est couramment admis que la sécurité de cet échange repose sur le fait qu&#8217;il est facile de calculer <strong>Qa</strong> et <strong>Qb</strong> à partir de <strong>P</strong>, <strong>Ka</strong> et <strong>Kb</strong>, mais qu&#8217;il est impossible de retrouver les clés privées <strong>K</strong> à partir des éléments publics <strong>P</strong>, <strong>Qa</strong> et <strong>Qb</strong>.</p>
<p>En effet, aucune méthode permettant de résoudre le logarithme discret sur la courbe elliptique (donc retrouver <strong>Ka</strong> à partir de <strong>Qa</strong> et <strong>P</strong>) n&#8217;est connue publiquement à ce jour.<br />
Au premier abord, il est parait simple de retrouver K &#8220;à la main&#8221; puisque la multiplication scalaire est réalisée très rapidement par les deux protagonistes. Cependant, le calcul du point Q repose sur des optimisations qui permettent de réduire très fortement le nombre de points intermédiaires à calculer<a href="#note5">[5]</a> (un peu à l&#8217;image de l&#8217;exponentiation rapide<a href="#note6">[6]</a> pour les échanges de clé reposants sur le logarithme discret). Une recherche exhaustive de K à partir de Q et P implique un calcul de chaque point Q possible et donc un temps de calcul mettant hors de portée cette solution.</p>
<p>D&#8217;autres méthodes ont été trouvées pour accélérer ce calcul (Shanks&#8217; Method, Baby-step giant-step<a href="#note7">[7]</a>, Pollard&#8217;s Rho<a href="#note8">[8]</a><a href="#note9">[9]</a>) avec une complexité O(√(n)). Un &#8220;challenge&#8221;<a href="#note10">[10]</a> est d&#8217;ailleurs en cours pour casser ECDH à l&#8217;aide de ces outils et donne un bon aperçu du temps et des ressources nécessaires pour un challenge sur 131 bits (estimation : 2466 Playstation 3 utilisées pendant 1 an<a href="#note11">[11]</a>).</p>
<h1>En pratique</h1>
<p>Pour mes clés SSH, j&#8217;ai donc tendance à favoriser d&#8217;abord des clés ECDSA, puis RSA de grande taille, et s&#8217;il y n&#8217;y a pas d&#8217;autre solution, une paire en DSA.</p>
<p>ECDSA n&#8217;a pas fait l&#8217;objet pour le moment d&#8217;attaque significative<a href="#note12">[12]</a>, mais n&#8217;est pas encore disponible sur toutes les distributions (notamment Fedora, qui exclut ECDSA conformément à sa licence, puisque le protocole est encore couvert par un brevet en cours de validité).</p>
<p>RSA est toujours fiable, à condition d&#8217;utiliser des clés de taille supérieure à 4096 bits. Le dernier record de factorisation a été établi en 2010 sur 768 bits<a href="#note13">[13]</a> (temps de calcul estimé à 6 mois avec 10000 stations de travail<a href="#note14">[14]</a>).</p>
<p>Quant à DSA, la dernière attaque portant sur le logarithme discret avec des clés standard date de 2005 et a atteint 613 bits<a href="#note15">[15]</a> (avec 4*16 processeurs pendant 17 jours<a href="#note16">[16]</a>).<br />
Les spécifications actuelles de DSA empêchent son utilisation avec une clé de plus de 1024 bits, et même si cette taille peut être considérée comme sûre, elle ne permet pas une fiabilité à très long terme de ces clés.<br />
Il est intéressant de noter que l&#8217;ANSSI a révoqué en 2010 un des certificats racine de l&#8217;État (qui avait été émis en 2007, de type DSA 1024 bits) et continue par ailleurs à utiliser des certificats RSA de 2048 et 4096 bits<a href="#note17">[17]</a>.<br />
Dans la documentation publiée à partir d&#8217;avril 2013, l&#8217;ANSSI ne recommande d&#8217;ailleurs plus l&#8217;utilisation de clés DSA <a href="#note18">[18]</a>.</p>
<p>&#8212;<br />
<a name="note1"></a>[1] : <a href="http://www.openssh.com/txt/release-5.7" target="_blank">http://www.openssh.com/txt/release-5.7</a><br />
<a name="note2"></a>[2] : <a href="http://www.keylength.com/" target="_blank">http://www.keylength.com/</a><br />
<a name="note3"></a>[3] : <a href="http://www.ssi.gouv.fr/IMG/pdf/RGS_B_1.pdf" target="_blank">http://www.ssi.gouv.fr/IMG/pdf/RGS_B_1.pdf</a><br />
<a name="note4"></a>[4] : <a href="http://www.nsa.gov/business/programs/elliptic_curve.shtml" target="_blank">http://www.nsa.gov/business/programs/elliptic_curve.shtml</a><br />
<a name="note5"></a>[5] : <a href="https://static.googleusercontent.com/external_content/untrusted_dlcp/research.google.com/fr//pubs/archive/37376.pdf" target="_blank">https://static.googleusercontent.com/external_content/untrusted_dlcp/research.google.com/fr//pubs/archive/37376.pdf</a> &#8211; 3.3 Point multiplication with precomputation<br />
<a name="note6"></a>[6] : <a href="https://en.wikipedia.org/wiki/Exponentiation_by_squaring" target="_blank">https://en.wikipedia.org/wiki/Exponentiation_by_squaring</a><br />
<a name="note7"></a>[7] : <a href="https://en.wikipedia.org/wiki/Counting_points_on_elliptic_curves#Baby-step_giant-step" target="_blank">https://en.wikipedia.org/wiki/Counting_points_on_elliptic_curves#Baby-step_giant-step</a><br />
<a name="note8"></a>[8] : <a href="http://math.ucalgary.ca/~mmusson/presentations/ECC09SummerSchool.pdf" target="_blank">http://math.ucalgary.ca/~mmusson/presentations/ECC09SummerSchool.pdf</a><br />
<a name="note9"></a>[9] : <a href="http://www.ecc-challenge.info/anon.pdf" target="_blank">http://www.ecc-challenge.info/anon.pdf</a><br />
<a name="note10"></a>[10] : <a href="http://www.certicom.com/index.php/the-certicom-ecc-challenge" target="_blank">http://www.certicom.com/index.php/the-certicom-ecc-challenge</a><br />
<a name="note11"></a>[11] : <a href="http://www.ecc-challenge.info/" target="_blank">http://www.ecc-challenge.info/</a><br />
<a name="note12"></a>[12] : <a href="https://en.wikipedia.org/wiki/Discrete_logarithm_records#Elliptic_curves" target="_blank">https://en.wikipedia.org/wiki/Discrete_logarithm_records#Elliptic_curves</a><br />
<a name="note13"></a>[13] : <a href="https://www.rsa.com/rsalabs/node.asp?id=3723" target="_blank">https://www.rsa.com/rsalabs/node.asp?id=3723</a><br />
<a name="note14"></a>[14] : <a href="http://eprint.iacr.org/2010/006.pdf" target="_blank">http://eprint.iacr.org/2010/006.pdf</a><br />
<a name="note15"></a>[15] : <a href="https://en.wikipedia.org/wiki/Discrete_logarithm_records#Finite_fields" target="_blank">https://en.wikipedia.org/wiki/Discrete_logarithm_records#Finite_fields</a><br />
<a name="note16"></a>[16] : <a href="https://listserv.nodak.edu/cgi-bin/wa.exe?A2=ind0509&amp;L=NMBRTHRY&amp;P=R1490&amp;D=0&amp;I=-3&amp;T=0" target="_blank">https://listserv.nodak.edu/cgi-bin/wa.exe?A2=ind0509&amp;L=NMBRTHRY&amp;P=R1490&amp;D=0&amp;I=-3&amp;T=0</a><br />
<a name="note17"></a>[17] : <a href="http://www.legifrance.gouv.fr/affichTexte.do?cidTexte=JORFTEXT000022299271&amp;dateTexte=&amp;categorieLien=id" target="_blank">http://www.legifrance.gouv.fr/affichTexte.do?cidTexte=JORFTEXT000022299271&amp;dateTexte=&amp;categorieLien=id</a><br />
<a name="note18"></a>[18] : <a href="http://www.ssi.gouv.fr/fr/guides-et-bonnes-pratiques/recommandations-et-guides/securite-des-reseaux/recommandations-pour-un-usage-securise-d-open-ssh.html" target="_blank">http://www.ssi.gouv.fr/fr/guides-et-bonnes-pratiques/recommandations-et-guides/securite-des-reseaux/recommandations-pour-un-usage-securise-d-open-ssh.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nlrs.fr/2012/08/25/elliptic-curve-diffie-hellman/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZFS &#8211; Backup</title>
		<link>http://www.nlrs.fr/2012/06/23/zfs-backup/</link>
		<comments>http://www.nlrs.fr/2012/06/23/zfs-backup/#comments</comments>
		<pubDate>Sat, 23 Jun 2012 00:00:23 +0000</pubDate>
		<dc:creator><![CDATA[Nico]]></dc:creator>
				<category><![CDATA[ZFS]]></category>

		<guid isPermaLink="false">http://www.nlrs.fr/?p=689</guid>
		<description><![CDATA[All my data is currently saved in a quite trustable raidz pool, but this is not theft-proof for example. For increased safety, I chose to externalize a backup of the pool with a used tape drive on another hard drive. &#8230; <a href="http://www.nlrs.fr/2012/06/23/zfs-backup/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>All my data is currently saved in a quite trustable raidz pool, but this is not theft-proof for example. For increased safety, I chose to externalize a backup of the pool <s>with a used tape drive</s> on another hard drive.<br />
<span id="more-689"></span></p>
<h1>Disk preparation</h1>
<p>First, connect the backup disk to the computer, and make sure the device descriptor points to the correct drive :</p>
<pre># smartctl -i /dev/ad2
 smartctl 5.42 2011-10-20 r3458 [FreeBSD 8.3-RELEASE-p3 amd64] (local build)
 Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net
=== START OF INFORMATION SECTION ===
 Model Family: Seagate Barracuda Green (Adv. Format)
 Device Model: ST2000DL003-9VT166
 Serial Number: xxxxxxx
 LU WWN Device Id: 5 000c50 044b0747a
 Firmware Version: CC3C
 User Capacity: 2,000,398,934,016 bytes [2.00 TB]
 Sector Sizes: 512 bytes logical, 4096 bytes physical
 Device is: In smartctl database [for details use: -P show]
 ATA Version is: 8
 ATA Standard is: ATA-8-ACS revision 4
 Local Time is: Wed Jun 20 19:04:15 2012 CEST
 SMART support is: Available - device has SMART capability.
 SMART support is: Enabled</pre>
<p>Then, create a new pool on this drive, with no particular option :</p>
<pre># zpool create backup /dev/ad2
# zpool status backup
 pool: backup
 state: ONLINE
 scan: none requested
 config:
NAME STATE READ WRITE CKSUM
 backup ONLINE 0 0 0
 ad2 ONLINE 0 0 0
errors: No known data errors</pre>
<p>This is followed by the datasets creation. The option copies=2 <a href="#note1">[1]</a> is used for the &#8220;important&#8221; datasets in order to protect them against an <b>hypothetical</b> bit rot <a href="#note2">[2]</a> (but this double the used disk space).</p>
<pre># zfs create backup/fichiers
# zfs create -o checksum=sha256 -o copies=2 backup/fichiers/Photos</pre>
<p>Less critical datasets can be created in a more usual way :</p>
<pre># zfs create -o checksum=sha256 backup/fichiers/Videos</pre>
<h1>Backup</h1>
<p>For my backups, I chose the <code>send</code> option <a href="#note3">[3]</a> included in ZFS. This feature is mainly used for data replication between hosts, but it is not recommended for backups on a external storage support, for a good reason : if one block is corrupted in the flow, the whole backup becomes unusable, which explains the importance of not forgetting the copies=2 option <b>previ</b><b>ous</b><b>ly mentioned.</b></p>
<p>These backups are made from existing snapshots and encrypted with openssl this way :</p>
<pre># zfs send data/fichiers/Photos@062012 | openssl enc -aes-256-cbc -salt &gt; /backup/fichiers/Photos/Photos_062012.ssl</pre>
<p>And for &#8220;compressible&#8221; data :</p>
<pre># zfs send data/fichiers/Documents@062012 | compress | openssl enc -aes-256-cbc -salt &gt; /backup/fichiers/Documents/Documents_062012.z.ssl</pre>
<p>Once the backup is finished, the pool can be exported :</p>
<pre># zfs export backup</pre>
<h1>Backup validation</h1>
<p>To make sure the backup is usable, the drive must be checked from time to time, for example with the live CD mode integrated into FreeBSD 9.0 (in this mode, the keymap can be changed via the <code>kbdmap</code> command).</p>
<p>A global check (<code>zpool scrub)</code> is possible after a drive import. All available pools can be listed with the <code>zpool import</code> command, and an alternative mountpoint can be set with the <code>-R</code> option, since / is in read-only mode when the live CD is used :</p>
<pre># zpool import
# mkdir /tmp/zfsroot
# zpool import -R /tmp/zfsroot &lt;pool&gt;
# zpool scrub &lt;pool&gt;</pre>
<p>To check backups integrity at the filesystem level, the pool can be mounted in read-only, and checked with <code>zstreamdump</code> <a href="#note4">[4]</a> :</p>
<pre># zpool import -o readonly=on -R /tmp/zfsroot &lt;pool&gt;
# openssl enc -d -aes-256-cbc -in /tmp/zfsroot/path/to/file.ssl | zstreamdump</pre>
<p>If <code>zstreamdump</code> returns only the checksum, the backup data is valid. Otherwise, the command returns the following error :</p>
<pre>Expected checksum differs from checksum in stream.</pre>
<p>&#8212;<br />
<a name="note1"></a>[1] : <a href="http://docs.oracle.com/cd/E19253-01/820-2315/gevpg/index.html" target="_blank">http://docs.oracle.com/cd/E19253-01/820-2315/gevpg/index.html</a><br />
<a name="note2"></a>[2] : <a href="http://www.linux-mag.com/id/8794/" target="_blank">http://www.linux-mag.com/id/8794/</a><br />
<a name="note3"></a>[3] : <a href="http://docs.oracle.com/cd/E19963-01/html/821-1448/gbchx.html" target="_blank">http://docs.oracle.com/cd/E19963-01/html/821-1448/gbchx.html</a><br />
<a name="note4"></a>[4] : <a href="http://blog.richardelling.com/2009/10/check-integrity-of-zfs-send-streams.html" target="_blank">http://blog.richardelling.com/2009/10/check-integrity-of-zfs-send-streams.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nlrs.fr/2012/06/23/zfs-backup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
