User:Nathanlkoch/Tutorials/TrueNASzfs to Gentoo

From Gentoo Wiki
Jump to:navigation Jump to:search

TrueNAS Encrypted ZFS Pool to Gentoo

This document should assist you in mounting a encrypted zfs pool from TrueNAS onto Gentoo.

For the use of this document my pools name is SpacePool

Install and Configure

Kernel

Follow ZFS#Kernel

Do the kernel bits and install zfs-kmod.

Mount to pool

Do a quick fdisk -l. It will show you all your drives and uuid information. It will also show you the name of your ZFS pool.

root #zpool import -f SpacePool

It's kind enough to know I have multiple disks in the set. Very nifty.

Save the key

In TrueNAS you want to store your encryption keys. The file will save to something like this "dataset_NAMEOFDATASET_keys.json". Save it somewhere to the disk. Open it and remove everything not in between the quotations. Leaving just the encryption key. I saved mine to something easy to find.

root #nano /etc/spacepool.key

Set the key

Set the key to the proper pool.

root #zfs set keylocation=file:///etc/spacepool.key SpacePool

Load the key

root #zfs load-key -a

-a will load all available keys.

Set mount point

root #zfs set mountpoint=/home/USER/Space SpacePool/Backup

Async on ZFS will considerable slow down a system. Disable it.

root #zfs set SpacePool atime=off
root #zfs set SpacePool/Backup atime=off

Mount the Dataset

Mount.

A simple "zfs list" will show you all configured datasets.

root #zfs mount SpacePool/Backup

Mount at boot

FILE /etc/systemd/system/zfs-load-key.service
/etc/systemd/system/zfs-load-key.service
[Unit]
Description=Load encryption keys
DefaultDependencies=no
After=zfs-import.target
Before=zfs-mount.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/zfs load-key -a
StandardInput=tty-force

[Install]
WantedBy=zfs-mount.service
root #systemctl enable zfs-import-cache.service
root #systemctl enable zfs-mount.service
root #systemctl enable zfs.target
root #systemctl enable zfs-load-key
root #systemctl enable zfs-import.target

Done.