Lab 14: Disk Encryption with LUKS
Prerequisites
docker run -it --rm --privileged ubuntu:22.04 bash
apt-get update -qq && apt-get install -y cryptsetupStep 1: Create a Loopback Device for Encryption
# Create a 100 MiB "virtual disk"
dd if=/dev/zero of=/tmp/encrypted.img bs=1M count=100
# Attach to a loop device
mknod /dev/loop50 b 7 50 2>/dev/null || true
losetup /dev/loop50 /tmp/encrypted.img
echo "Device ready:"
losetup -a | grep loop50
# Verify the raw device (no filesystem yet)
file -s /dev/loop50Step 2: Format the Device with LUKS
Step 3: Inspect LUKS Header with luksDump
Step 4: Open the Encrypted Device
Step 5: Create a Filesystem and Mount
Step 6: Close the Encrypted Device
Step 7: Add a Second Key (luksAddKey)
Step 8: Capstone — Auto-mount with /etc/crypttab
Summary
Command
Purpose
LUKS2 Concept
Detail
Last updated
