-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zfs: create zfs_data pool with LUKS encryption #940
base: main
Are you sure you want to change the base?
Conversation
pool = "zfs_root"; | ||
}; | ||
}; | ||
zfs_data = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are still using this post boot script, than this should be just an empty partition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If using post boot script, we keep empty partition and we do something similar to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We need to detect if the device already has luks headers and if only format if this is not the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed, now we have better control on password with post boot script
.
My only concern is once I use luksFormat
on zfs_data
partition all zfs meta data (pools, datasets) info is lost, because of that I need to create pool and datasets again in post boot script
.
With this patch we create zfs_data pool with LUKS encryption enabled and modify postBostCommands accordingly. Signed-off-by: Vunny Sodhi <[email protected]>
Signed-off-by: Vunny Sodhi <[email protected]>
echo -n $pswd | cryptsetup luksFormat --type luks2 -q "$ZFS_LOCATION" | ||
echo -n $pswd | cryptsetup luksOpen "$ZFS_LOCATION" "$ZFS_POOLNAME" --persistent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can actually generate password randomly because we can use the TPM to unlock the disk.
# Create pool, datasets as luksFormat will erase pools, ZFS datasets stored on that partition | ||
zpool create -o ashift=12 -O compression=lz4 -O acltype=posixacl -O xattr=sa -f "$ZFS_POOLNAME" /dev/mapper/"$ZFS_POOLNAME" | ||
zfs create -o quota=30G "$ZFS_POOLNAME"/vm_storage | ||
zfs create -o quota=10G -o mountpoint=none "$ZFS_POOLNAME"/reserved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this used for? If one wants to reserve space, there is refreservation
. It's a zfs property
@@ -44,6 +44,10 @@ | |||
boot = { | |||
initrd.availableKernelModules = [ "zfs" ]; | |||
supportedFilesystems = [ "zfs" ]; | |||
zfs.extraPools = [ "zfs_data" ]; | |||
initrd.luks.devices.zfs_data = { | |||
device = "/dev/disk/by-partlabel/disk-disk1-zfs_data"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you also need this for tpm decryption:
device = "/dev/disk/by-partlabel/disk-disk1-zfs_data"; | |
device = "/dev/disk/by-partlabel/disk-disk1-zfs_data"; | |
crypttabExtraOpts = [ "tpm2-device=auto" ]; |
For encrypted swap we could also do the same tpm encryption dance. |
Description of changes
With this patch we create zfs_data pool with LUKS encryption enabled and modify postBostCommands accordingly.
Checklist for things done
x86_64
aarch64
riscv64
make-checks
and it passesnixos-rebuild ... switch
Instructions for Testing
Difference
Test steps
Make sure now there are two pools called as
zfs_root
andzfs_data
and there is NOzfspool
using below command.To verify
zfs_data
is luks encrypted run below commandImprovements
* With this PR everytime user need to enter password when system boots.* Change decryption mechanism to Yubikey/TPM.