LUKS Encrypted Container
💊 Quick Pill: LUKS Encrypted Container ℹ️Info Use case: Create encrypted file containers for secure backup storage, sensitive documents, or portable encrypted volumes. Works like a virtual encrypted disk. 🔐 Quick Setup (5 minutes) 1. Install Required Tools sudo apt install cryptsetup 2. Create Encrypted Container # Create a 10GB empty file (fast allocation) fallocate -l 10G BackupCrypt.img # Initialize LUKS encryption (you'll set a password) sudo cryptsetup luksFormat BackupCrypt.img # Open the encrypted container sudo cryptsetup open BackupCrypt.img backup_crypt # Create filesystem inside sudo mkfs.ext4 /dev/mapper/backup_crypt # Mount it sudo mkdir -p /mnt/encrypted sudo mount /dev/mapper/backup_crypt /mnt/encrypted # Set permissions (optional - for your user) sudo chown $USER:$USER /mnt/encrypted 3. Use Your Encrypted Storage # Copy files cp -r ~/Documents/sensitive/ /mnt/encrypted/ # Work with files normally echo "Secret data" > /mnt/encrypted/secret.txt 4. Close Encrypted Container # Unmount sudo umount /mnt/encrypted # Close LUKS container sudo cryptsetup close backup_crypt ✅Success Done! Your data is now encrypted. Without the password, the file looks like random data. 🔄 Daily Usage Open and Mount # Open with password prompt sudo cryptsetup open BackupCrypt.img backup_crypt # Mount sudo mount /dev/mapper/backup_crypt /mnt/encrypted Close and Lock # Always unmount first sudo umount /mnt/encrypted # Then close sudo cryptsetup close backup_crypt 📋 Command Reference Create Container Command Purpose Notes fallocate -l SIZE file.img Create empty file (fast) Sizes: 1G, 10G, 100G, etc. dd if=/dev/zero of=file.img bs=1M count=10240 Create file (slower, more secure) Overwrites with zeros cryptsetup luksFormat file.img Initialize LUKS encryption Sets password Open/Close Command Purpose cryptsetup open file.img name Open encrypted container cryptsetup close name Close encrypted container cryptsetup status name Check if container is open Filesystem Command Purpose mkfs.ext4 /dev/mapper/name Create ext4 filesystem mkfs.xfs /dev/mapper/name Create XFS filesystem mkfs.btrfs /dev/mapper/name Create Btrfs filesystem 💡 Pro Tips Create container with dd (more secure, slower) Use dd instead of fallocate for better security - overwrites the file with zeros: ...