<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Truenas on inetshell</title><link>https://inet.sh/en/tags/truenas/</link><description>Recent content in Truenas on inetshell</description><generator>Hugo</generator><language>en</language><lastBuildDate>Wed, 19 Aug 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://inet.sh/en/tags/truenas/index.xml" rel="self" type="application/rss+xml"/><item><title>Native ZFS encryption (OpenZFS): create, inherit, change-key</title><link>https://inet.sh/en/posts/zfs/encryption/</link><pubDate>Wed, 19 Aug 2026 00:00:00 +0000</pubDate><guid>https://inet.sh/en/posts/zfs/encryption/</guid><description>Create an encrypted OpenZFS dataset with a passphrase or keyfile, inherit encryption on children, and rotate keys with zfs change-key — not Solaris zfs key -c.</description><content:encoded><![CDATA[<h2 id="tldr">TL;DR</h2>
<p><code>zfs create -o encryption=on …</code>. Children inherit. Rotate keys on Linux with <code>zfs change-key</code> (not Solaris <code>zfs key -c</code>).</p>
<p>OpenZFS encrypts <strong>datasets</strong>, not the whole pool. Pool labels and metaslabs stay visible; <code>tank/secret</code> contents do not. This is the TrueNAS / Proxmox / Linux path.</p>
<p>Background: <a href="https://arstechnica.com/gadgets/2021/06/a-quick-start-guide-to-openzfs-native-encryption/">Ars native encryption</a>, <a href="https://mtlynch.io/zfs-encrypted-backups/">ZFS encrypted backups</a>.</p>
<h2 id="create">Create</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">zfs create -o <span class="nv">encryption</span><span class="o">=</span>on -o <span class="nv">keyformat</span><span class="o">=</span>passphrase -o <span class="nv">keylocation</span><span class="o">=</span>prompt tank/encrypted
</span></span><span class="line"><span class="cl">zfs create tank/encrypted/child1
</span></span></code></pre></td></tr></table>
</div>
</div><p><code>child1</code> inherits encryption. Do not set <code>encryption=off</code> on a child: OpenZFS will not let you punch a plaintext hole under an encrypted parent.</p>
<p>Keyfile instead of prompt:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">zfs create -o <span class="nv">encryption</span><span class="o">=</span>on -o <span class="nv">keyformat</span><span class="o">=</span>passphrase <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span>  -o <span class="nv">keylocation</span><span class="o">=</span>file:///root/zfs.key tank/encrypted
</span></span></code></pre></td></tr></table>
</div>
</div><p>The key file does <strong>not</strong> live on the encrypted dataset. USB, TPM, or a path on another pool.</p>
<h2 id="load-the-key-at-boot">Load the key at boot</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">zfs load-key tank/encrypted
</span></span><span class="line"><span class="cl">zfs mount tank/encrypted
</span></span></code></pre></td></tr></table>
</div>
</div><p>Without <code>load-key</code> the dataset exists and <code>zfs list</code> shows it, but it will not mount.</p>
<h2 id="receive-plaintext-as-encrypted">Receive plaintext as encrypted</h2>
<p>On the <strong>first</strong> <code>recv</code> you can set encryption properties:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">zfs send tank/test@snap1 <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span>  <span class="p">|</span> zfs recv -o <span class="nv">encryption</span><span class="o">=</span>on -o <span class="nv">keyformat</span><span class="o">=</span>passphrase <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span>      -o <span class="nv">keylocation</span><span class="o">=</span>file:///path/to/keyfile tank/encrypted
</span></span></code></pre></td></tr></table>
</div>
</div><p>That receive is <strong>without</strong> <code>-w</code>. Raw <code>-w</code> copies the source wrapping key: only valid if the source was already encrypted. Details: <a href="/en/posts/zfs/send-unencrypted-to-encrypted/">unencrypted send into encrypted</a>.</p>
<h2 id="rotate-the-passphrase-openzfs">Rotate the passphrase (OpenZFS)</h2>
<p>On <strong>Solaris</strong> the command was <code>zfs key -c</code>. On <strong>OpenZFS / Linux / TrueNAS</strong>:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">zfs change-key tank/encrypted
</span></span><span class="line"><span class="cl">zfs get keyformat,keylocation,keystatus tank/encrypted
</span></span></code></pre></td></tr></table>
</div>
</div><p>New keyfile:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">zfs change-key -o <span class="nv">keylocation</span><span class="o">=</span>file:///media/stick/key tank/encrypted
</span></span></code></pre></td></tr></table>
</div>
</div><p>Wrapping-key rekey (does not rewrite every block; rotates the key that wraps master keys) is <code>zfs change-key -i</code> depending on version — read <strong>your</strong> <code>zfs change-key</code> man page before production.</p>
<p>See also: <a href="/en/posts/zfs/hold-protect-snapshot/">snapshot holds</a>, <a href="/en/posts/zfs/backups-to-s3/">off-host backups</a>.</p>
]]></content:encoded></item></channel></rss>