Lion Cipher Lab

Encrypt a volume with LUKS in a loopback file and prove it is unreadable when closed

Why it matters

Encrypting data at rest protects it when a laptop is lost, a disk is sold or a backup tape goes missing. LUKS is the standard Linux way to do it, and the mechanics are simple once you have done them: a header with keyslots, a key that exists in memory only while the volume is open, and ordinary ciphertext on disk. Doing it inside a file lets you break things safely. You will also learn the two judgment calls that catch real teams: proving the protection with a test, and treating the header backup as a secret.

What you'll learn

Steps in this lab

  1. What LUKS is, and why a file is a safe place to learn
  2. Create the image file and attach it as a loop device
  3. Format it as LUKS2, open it, and make a filesystem
  4. Mount it, write a marker, then unmount and close
  5. Prove it: search the raw image, with a plaintext control
  6. Read the header: luksDump
  7. Back up the header, then wipe it on purpose
  8. Restore the header and read the data back
  9. What LUKS protects, and what it does not
  10. Clean up

Open the full interactive lab →

Keep learning