ZFS Dataset Encryption on TrueNAS: A Practical Setup Guide
If you store sensitive data on your TrueNAS server — financial records, medical documents, or client files — encrypting individual datasets is the most practical way to protect that data at rest without sacrificing the flexibility of your pool. This guide walks you through the critical choices: passphrase vs. key file, the hard limitation that you cannot encrypt an existing dataset (and how to work around it), and the exact steps to create an encrypted dataset that survives a reboot. You will leave with a clear, repeatable setup that matches your automation needs and risk tolerance.
Why Dataset-Level Encryption Is Better Than Pool-Wide Encryption
TrueNAS offers encryption at the pool level and the dataset level. Pool-wide encryption encrypts the entire vdev, which sounds simpler but creates a single point of failure — if the pool key is lost, all data across every dataset is gone. Dataset-level encryption lets you encrypt only what needs protecting, leaving your media library, Docker app data, or backup targets unencrypted for faster access and easier sharing.
Create an unencrypted pool, then encrypt only the datasets that hold sensitive data. This keeps your pool fast for bulk storage and lets you selectively lock/unlock sensitive folders after a reboot.
Dataset-level encryption also makes key rotation or passphrase changes less disruptive. You can re-key one dataset without affecting others, and you can back up the encryption key for each dataset separately.
ZFS Dataset Encryption TrueNAS: Passphrase vs. Key File
When you create an encrypted dataset in TrueNAS, you choose between a passphrase and a key file. This is the single most important decision in your setup — it determines whether your dataset can unlock automatically after a reboot or requires manual intervention every time.
Passphrase-Based Encryption
A passphrase is a text string you type in the TrueNAS web UI or at the console to unlock the dataset. It is human-readable and memorable, which makes it convenient for manual recovery but a non-starter for automation.
Pros
- Easy to remember and type manually
- No separate file to lose or corrupt
- Works out of the box on any TrueNAS install
Cons
- Requires manual entry after every reboot or pool import
- Breaks any service that needs the dataset at boot (Docker, Plex, SMB shares)
- Harder to automate unlocking in scripts or initramfs
Passphrases are best if you have a single-user server that you reboot rarely (every few months), and you are willing to log into the web UI after each restart to unlock the dataset. They are a poor fit for a headless homelab that must survive power outages unattended.
Key File Encryption
A key file is a randomly generated binary file — typically 32 bytes (256 bits) — stored on a USB drive, another dataset, or a remote server. TrueNAS reads this file to unlock the dataset automatically, without human interaction.
Pros
- Enables automatic unlocking at boot — no manual login required
- Key file can be copied to multiple locations for redundancy
- Can be combined with a TPM or secure boot for hardware-bound encryption
Cons
- Key file loss = permanent data loss — no password recovery
- Must store the key file securely; if it lives on the same server, it partly defeats encryption-at-rest
- Requires a deliberate backup strategy for the key file itself
Never store your ZFS encryption key file on the same dataset it encrypts. If you lose the dataset, you lose both the data and the key. Store the key on a separate USB drive, a different TrueNAS pool, or an offsite location.
Key files are the right choice for most homelab users because they allow unattended reboots, which is critical for a server hosting Docker containers, Plex, or file shares. The trade-off is that you must manage the key file as carefully as you manage the data itself.
TrueNAS Encrypt Dataset Guide: Step-by-Step
Follow these steps to create an encrypted dataset on TrueNAS. The process is identical whether you choose a passphrase or a key file — the difference is in the unlock method you select during creation.
In the TrueNAS web UI, go to Storage > Pools, click the three dots next to your pool, and select Add Dataset.
Check the Encryption box. You will see the option to choose between Passphrase and Key. Select your preferred method.
If using a key file, click Generate Key — TrueNAS creates a random 32-byte key. If using a passphrase, type a strong passphrase (at least 20 characters with mixed case, numbers, and symbols).
TrueNAS shows a one-time download prompt for the encryption key. Download it and store it on a separate device or encrypted USB drive. If you skip this, you cannot retrieve the key later.
Set the dataset name, share type (SMB, NFS, or generic), and any quotas or reservations. Click Save to create the encrypted dataset.
After creation, the dataset appears as locked in the Datasets list. You must unlock it before any data can be written or read. For a key file, TrueNAS attempts to unlock automatically at boot if the key is available. For a passphrase, you must unlock it manually through the web UI or CLI.
Why You Cannot Encrypt an Existing Dataset (and the Migration Path)
TrueNAS does not support adding encryption to a dataset after it has been created. This is a ZFS limitation — encryption is a property set at dataset creation time, and ZFS does not allow in-place conversion. If you created a dataset without encryption and now need it encrypted, you have two options:
- Create a new encrypted dataset and copy data — Create a new dataset with encryption enabled, then copy or rsync your data from the unencrypted dataset to the encrypted one. This is the safest and most straightforward method.
- Use ZFS send/receive to a new encrypted dataset — Take a snapshot of the unencrypted dataset, then send it to a new encrypted dataset on the same pool. This preserves permissions and metadata but requires careful handling of the snapshot chain.
If you use ZFS send/receive to migrate data, the destination dataset must be created with encryption enabled before you receive the stream. You cannot encrypt a dataset during the receive process.
Once the data is on the new encrypted dataset, verify the copy, then delete the old unencrypted dataset. The old data remains on disk until overwritten — for sensitive data, consider a secure erase pass on the pool or physically destroying the drives if decommissioning.
TrueNAS Encryption Best Practice: Key Management and Backup
Losing your encryption key or passphrase means permanent data loss. There is no backdoor, no “forgot password” flow, and no vendor recovery. TrueNAS encrypts data with AES-256-GCM (or AES-256-CCM on older versions), and without the key, the data is mathematically unrecoverable.
For key file users, the key file is a plain binary file. You can copy it to a USB drive, another TrueNAS pool, or a password manager that supports file attachments (like Bitwarden or 1Password). Do not store it on the same dataset it encrypts — if that dataset corrupts, the key is lost with the data.
For passphrase users, write the passphrase down and store it in a secure location. A password manager is acceptable, but ensure you can access it without your TrueNAS server running (e.g., on your phone or a laptop).
Test your recovery process before you need it. Reboot your TrueNAS server, then attempt to unlock the encrypted dataset using your stored key or passphrase. If it fails, fix the process now — not after a drive failure or power outage.
Locking and Unlocking Behavior After Reboot
When TrueNAS reboots, all encrypted datasets start in a locked state. The unlock behavior depends entirely on your encryption method:
| Encryption Method | Unlock Behavior at Boot | Impact on Services |
|---|---|---|
| Passphrase | Stays locked — must unlock manually via web UI or CLI | Any service needing data on that dataset (Docker, SMB shares, Plex libraries) fails to start or shows empty folders |
| Key file on local storage | Unlocks automatically if the key file is accessible | Services start normally — no manual intervention needed |
| Key file on USB drive | Unlocks automatically only if the USB drive is plugged in and recognized at boot | If USB fails or is disconnected, dataset stays locked — services break |
If you use a passphrase and need a service to run after a reboot, you must either switch to a key file or set up a script that prompts for the passphrase at boot (which defeats the purpose of unattended operation).
On TrueNAS SCALE (Linux-based), you can store the key file on the boot pool or a separate unencrypted dataset, then reference it in the dataset’s unlock configuration. This is fine for most homelabs — the boot pool is rarely exposed to attackers. For production environments, consider a dedicated USB key that you physically remove when the server is unattended.
Which Should You Choose: Passphrase or Key File?
For the vast majority of homelab users, a key file is the right choice. It enables unattended reboots, which is essential for a server that hosts Docker containers, media libraries, or file shares that must remain accessible 24/7. The key management overhead is minimal — download the key once, store it in two places, and test recovery.
Choose a passphrase only if:
- You reboot your server less than once a quarter and are present to unlock it.
- You are uncomfortable managing binary key files.
- You want the strongest possible protection against physical theft (a passphrase cannot be copied without your knowledge; a key file can be silently copied if an attacker gains access to your storage).
Whichever method you pick, remember that encryption protects against physical theft and drive disposal — it does not protect against ransomware, accidental deletion, or logical corruption. A separate backup strategy is still required. Consider combining encrypted datasets with regular ZFS snapshots for instant rollback capability, and always maintain an offsite backup of your critical data.
Frequently Asked Questions
Can I encrypt a dataset I already created without losing data?
No, TrueNAS does not support adding encryption to an existing dataset. You must create a new encrypted dataset and copy your data into it. The safest method is to create the new encrypted dataset, then use rsync or ZFS send/receive to migrate the data. Once you verify the copy is complete and accessible, you can delete the original unencrypted dataset. This process preserves all your files and permissions, but it does require downtime and extra storage space during the migration.
Should I use a passphrase or a key file for TrueNAS encryption?
For most homelab users, a key file is the better choice because it allows your encrypted datasets to unlock automatically after a reboot, keeping your services running without manual intervention. A passphrase requires you to log into the TrueNAS web UI and type it in after every restart, which breaks any automated service that needs access to the dataset. Choose a passphrase only if you reboot very rarely (once every few months) and are comfortable with the manual unlock process. The key file approach adds a small management overhead — you must store the key file securely and test that it works after a reboot.
What happens if I lose my ZFS encryption key?
Losing your ZFS encryption key or passphrase results in permanent, unrecoverable data loss. TrueNAS uses AES-256 encryption, and there is no backdoor, password reset, or vendor recovery option. The data remains on the drives but is mathematically impossible to decrypt without the correct key. This is why it is critical to store at least two copies of your encryption key in physically separate locations — for example, one on a USB drive in a fireproof safe and one in an encrypted password manager or offsite backup. Always test your recovery process before you actually need it.
Does an encrypted dataset unlock automatically after a reboot?
It depends on your encryption method. If you use a passphrase, the dataset stays locked after a reboot and requires you to manually unlock it through the TrueNAS web UI or command line. If you use a key file stored on the server’s boot pool or a separate unencrypted dataset, TrueNAS will attempt to unlock the dataset automatically during boot. If the key file is stored on a USB drive, the dataset unlocks only if the USB drive is connected and recognized at boot time. Any service that depends on data from a locked dataset — such as Docker containers, SMB shares, or Plex libraries — will fail to start or show empty folders until the dataset is unlocked.
Last verified: July 10, 2026. Specifications cross-checked against manufacturer documentation where available.
🛡 Shop Recommended Hardware
Prices and stock verified regularly by our affiliate partners. As an affiliate, HomeLabCost may earn a commission on qualifying purchases at no extra cost to you.
Browse Hardware Picks →