Skip to content
TrySitePrice

How to add encrypted ZFS pool on FreeBSD server

Best/Tutorial

To add an encrypted ZFS pool on a FreeBSD server, you will need to have the geli (GEom ELI) kernel module loaded and the geli utility installed. Here are the general steps to add an encrypted ZFS pool:

  1. Load the geli kernel module:

kldload geom_eli

  1. Create a new GPT partition on the desired disk. This can be done using the gpart command. For example:

gpart create -s gpt /dev/ada0

  1. Create a new geli provider on the partition:

geli init -b -s 4096 /dev/ada0p1

This will create a 4KB sector-size encrypted partition.

  1. Attach the geli provider:

geli attach /dev/ada0p1

  1. Create the ZFS pool on the geli provider:

zpool create -o ashift=12 -O compression=lz4 -O encryption=aes-256-gcm -O keylocation=file:///root/ada0p1.key -O keyformat=passphrase tank /dev/ada0p1.eli

This command creates a ZFS pool named "tank", using the geli provider /dev/ada0p1.eli, with the specified options for ashift, compression, encryption, keylocation, and keyformat.

  1. Set the permissions on the key file

chmod 600 /root/ada0p1.key

  1. Create file systems and datasets as required.

zfs create tank/mydata

  1. Finally, you can now mount the new ZFS file system.

zfs mount tank/mydata

Note: This is a general guide for adding an encrypted ZFS pool. The exact commands and options used may vary depending on your specific setup and requirements.