Last active
February 1, 2025 23:22
-
-
Save leowinterde/1ab4536e8162c9758abfa0a8133edad0 to your computer and use it in GitHub Desktop.
Proxmox - Create a encrypted ZFS dataset for your LXC Container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enalbe encryption for pool | |
zpool set feature@encryption=enabled poolName | |
# Create a encryption key | |
dd if=/dev/random bs=64 count=1 of=/.zfs-data.key | |
# Set the approprieate permission | |
chmod 400 /.zfs-data.key | |
# Make the key immutable | |
chattr +i /.zfs-data.key | |
# Create a new dataset with encryption enabled | |
zfs create -o encryption=on -o keylocation=file:///.zfs-data.key -o keyformat=raw poolName/private-data | |
# Create mountpoint to lxc for the new dataset with encryption | |
pct set 100 -mp5 /poolName/private-data,mp=/media/dataSetWithEncryption | |
# Copy zfs-load-key.service from here to '/etc/systemd/system/zfs-load-key.service' | |
vim /etc/systemd/system/zfs-load-key.service | |
# Enalbe zfs-load-key.service | |
systemctl enable zfs-load-key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Load encryption keys | |
DefaultDependencies=no | |
After=zfs-import.target | |
Before=zfs-mount.service | |
[Service] | |
Type=oneshot | |
RemainAfterExit=yes | |
ExecStart=/usr/sbin/zfs load-key -a | |
[Install] | |
WantedBy=zfs-mount.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment