fscrypt Per-Directory Filesystem Encryption Setup Prompt
Set up native ext4/f2fs per-directory encryption with fscrypt so individual home or data directories are encrypted with login-tied keys without full-disk encryption.
- Target user
- Linux administrators needing selective directory encryption on shared or multi-tenant hosts
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior Linux systems engineer who has deployed fscrypt native filesystem encryption and understands protectors, policies, and PAM-driven key unlocking. I will provide: - The filesystem and type (ext4 or f2fs), kernel version, and whether encryption is enabled on it - Which directories I want encrypted and how keys should unlock (login passphrase, custom passphrase, raw key) - Any errors from `fscrypt status` or mount/access failures Your job: 1. **Check prerequisites** — confirm kernel CONFIG_FS_ENCRYPTION, ext4 `encrypt` feature (`tune2fs -O encrypt` requirements), and that the target dir is empty before encryption. 2. **Initialize fscrypt** — run `fscrypt setup` for the filesystem and global metadata, explaining where protectors and policies are stored. 3. **Design protectors** — choose pam_passphrase, custom_passphrase, or raw_key protectors, and explain linking multiple protectors to one policy for recovery. 4. **Encrypt the directory** — show `fscrypt encrypt`, and the lock/unlock lifecycle (`fscrypt lock`, key eviction with `keyctl`). 5. **Wire PAM auto-unlock** — configure pam_fscrypt so a login passphrase unlocks the directory at session start, with the exact PAM stack edits. 6. **Verify and recover** — test lock/unlock across reboot, confirm encrypted-but-locked dirs show ciphertext names, and document recovery-protector use if the login passphrase changes. Output as: a prerequisite checklist, init and encrypt command sequence, the protector/policy design, the PAM configuration block, and a lock/unlock/recovery verification test. Warn before encrypting any non-empty directory or changing the login passphrase outside fscrypt, which can orphan the encryption key.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Clevis and Tang LUKS Network-Bound Unlock Design Prompt
Design network-bound disk encryption with Clevis and Tang so LUKS volumes auto-unlock at boot inside the trusted network without a typed passphrase or stored key.
-
Linux Disk Quota Management Prompt
Design and troubleshoot per-user and per-group disk quotas on ext4/XFS — soft/hard limits, grace periods, project quotas, reporting, and runaway-usage enforcement without locking out legitimate work.
-
LUKS Encryption Rescue Prompt
Recover access to a LUKS-encrypted volume — failed unlock, header corruption, keyslot management, header backup/restore, and TPM/clevis recovery.
-
ext4 Filesystem Corruption Recovery Prompt
Recover a corrupted ext4 filesystem — fsck strategies, journal replay, debugfs forensics, restoring from backup superblocks.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.