Skip to content

Linux Disk Encryption

Mattscreative edited this page Nov 19, 2025 · 2 revisions

🔒 Linux Disk Encryption Guide

Complete beginner-friendly guide to disk encryption on Linux, covering Arch Linux, CachyOS, and other distributions including LUKS encryption, encrypted swap, and encrypted installation.


📋 Table of Contents

  1. LUKS Encryption
  2. Encrypting Partitions
  3. Encrypted Swap
  4. Mounting Encrypted Disks
  5. Troubleshooting

🔐 LUKS Encryption

Install cryptsetup

Install tools:

# Arch/CachyOS
sudo pacman -S cryptsetup

# Debian/Ubuntu
sudo apt install cryptsetup

# Fedora
sudo dnf install cryptsetup

Check Version

Check cryptsetup:

# Check version
cryptsetup --version

💾 Encrypting Partitions

Encrypt Partition

Create encrypted partition:

# Encrypt partition
sudo cryptsetup luksFormat /dev/sda2

# Enter passphrase when prompted

Open Encrypted Partition

Open encrypted device:

# Open encrypted partition
sudo cryptsetup open /dev/sda2 cryptroot

# Format
sudo mkfs.ext4 /dev/mapper/cryptroot

# Mount
sudo mount /dev/mapper/cryptroot /mnt

🔄 Encrypted Swap

Encrypt Swap

Create encrypted swap:

# Create swap
sudo cryptsetup -d /dev/urandom open --type plain /dev/sda3 swap

# Format
sudo mkswap /dev/mapper/swap

# Enable
sudo swapon /dev/mapper/swap

Auto-Enable Encrypted Swap

Configure fstab:

# Edit fstab
sudo vim /etc/fstab

Add:

/dev/mapper/swap none swap sw 0 0

📂 Mounting Encrypted Disks

Manual Mount

Mount encrypted disk:

# Open encrypted partition
sudo cryptsetup open /dev/sda2 cryptroot

# Mount
sudo mount /dev/mapper/cryptroot /mnt/data

Auto-Mount

Configure fstab:

# Edit fstab
sudo vim /etc/fstab

Add:

/dev/mapper/cryptroot /mnt/data ext4 defaults 0 2

🔧 Troubleshooting

Cannot Open Encrypted Disk

Check device:

# Check device
lsblk

# Check LUKS
sudo cryptsetup luksDump /dev/sda2

📝 Summary

This guide covered disk encryption for Arch Linux, CachyOS, and other distributions, including LUKS, encrypted swap, and mounting.


🔗 Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally