I'm planning to setup a set of 3x 2TB 7200rpm drives as a LUKS-encrypted Z-RAID pool in Linux (for a NAS solution).
My understanding of the problem at hand is that the only way to achieve this is to luksFormat
every physical device and then assemble a zpool out of unlocked LUKS containers.
I have the following concerns with this:
Wouldn't it significantly impede write performance? In this setup redundant data is encrypted several times because LUKS is not "aware" of Z-RAID. In LUKS-on-mdadm solution data is encrypted once and merely written to disks multiple times. My CPU supports Intel AES-NI.
Will ZFS be aware of disk failures when operating on device-mapper LUKS containers as opposed to physical devices? How about deduplication and other ZFS features?
One of the servers that I administrate runs the type of configuration that you describe. It has six 1TB hard drives with a LUKS-encrypted RAIDZ pool on it. I also have two 3TB hard drives in a LUKS-encrypted ZFS mirror that are swapped out every week to be taken off-site. The server has been using this configuration for about three years, and I've never had a problem with it.
If you have a need for ZFS with encryption on Linux then I recommend this setup. I'm using ZFS-Fuse, not ZFS on Linux. However, I believe that would have no bearing on the result other than ZFS on Linux will probably have better performance than the setup that I am using.
Keep in mind that LUKS isn't aware of RAID. It only knows that it's sitting on top of a block device. If you use mdadm to create a RAID device and then
luksformat
it, it is mdadm that is replicating the encrypted data to the underlying storage devices, not LUKS.Question 2.8 of the LUKS FAQ addresses whether encryption should be on top of RAID or the other way around. It provides the following diagram.
Because ZFS combines the RAID and filesystem functionality, your solution will need to look like the following.
I've listed the raw partitions as optional as ZFS expects that it will use raw block storage rather than a partition. While you could create your zpool using partitions, it's not recommended because it'll add a useless level of management, and it will need to be taken into account when calculating what your offset will be for partition block alignment.
There shouldn't be a performance problem as long as you choose an encryption method that's supported by your AES-NI driver. If you have cryptsetup 1.6.0 or newer you can run
cryptsetup benchmark
and see which algorithm will provide the best performance.This question on recommended options for LUKS may also be of value.
Given that you have hardware encryption support, you are more likely to face performance issues due to partition misalignment.
ZFS on Linux has added the
ashift
property to thezfs
command to allow you to specify the sector size for your hard drives. According to the linked FAQ,ashift=12
would tell it that you are using drives with a 4K block size.The LUKS FAQ states that a LUKS partition has an alignment of 1 MB. Questions 6.12 and 6.13 discuss this in detail and also provide advice on how to make the LUKS partition header larger. However, I'm not sure it's possible to make it large enough to ensure that your ZFS filesystem will be created on a 4K boundary. I'd be interested in hearing how this works out for you if this is a problem you need to solve. Since you are using 2TB drives, you might not face this problem.
ZFS will be aware of disk failures insofar as it can read and write to them without problems. ZFS requires block storage and doesn't care or know about the specifics of that storage and where it comes from. It only keeps track of any read, write or checksum errors that it encounters. It's up to you to monitor the health of the underlying storage devices.
The ZFS documentation has a section on troubleshooting which is worth reading. The section on replacing or repairing a damaged device describes what you might encounter during a failure scenario and how you might resolve it. You'd do the same thing here that you would for devices that don't have ZFS. Check the syslog for messages from your SCSI driver, HBA or HD controller, and/or SMART monitoring software and then act accordingly.
All of the ZFS features will work the same regardless of whether the underlying block storage is encrypted or not.
Summary
cryptsetup benchmark
to see what will work best on your hardware.February 2020 Update
It's been six years since I wrote this answer. ZFS on Linux v0.8.0 supports native encryption, which you should consider if you don't have a specific need for LUKS.
An alternative implementation is to create a ZVOL block device (http://zfsonlinux.org/example-zvol.html), use LUKS to encrypt the newly created ZVOL and then create an ext4 (or other) filesystem on top of the encrypted block device.