-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux Disk Encryption
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to disk encryption on Linux, covering Arch Linux, CachyOS, and other distributions including LUKS encryption, encrypted swap, and encrypted installation.
Install tools:
# Arch/CachyOS
sudo pacman -S cryptsetup
# Debian/Ubuntu
sudo apt install cryptsetup
# Fedora
sudo dnf install cryptsetupCheck cryptsetup:
# Check version
cryptsetup --versionCreate encrypted partition:
# Encrypt partition
sudo cryptsetup luksFormat /dev/sda2
# Enter passphrase when promptedOpen encrypted device:
# Open encrypted partition
sudo cryptsetup open /dev/sda2 cryptroot
# Format
sudo mkfs.ext4 /dev/mapper/cryptroot
# Mount
sudo mount /dev/mapper/cryptroot /mntCreate 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/swapConfigure fstab:
# Edit fstab
sudo vim /etc/fstabAdd:
/dev/mapper/swap none swap sw 0 0
Mount encrypted disk:
# Open encrypted partition
sudo cryptsetup open /dev/sda2 cryptroot
# Mount
sudo mount /dev/mapper/cryptroot /mnt/dataConfigure fstab:
# Edit fstab
sudo vim /etc/fstabAdd:
/dev/mapper/cryptroot /mnt/data ext4 defaults 0 2
Check device:
# Check device
lsblk
# Check LUKS
sudo cryptsetup luksDump /dev/sda2This guide covered disk encryption for Arch Linux, CachyOS, and other distributions, including LUKS, encrypted swap, and mounting.
- Filesystem Management - Filesystem setup
- Backup and Restore - Backups
- Security Configuration - Security
- ArchWiki Disk Encryption: https://wiki.archlinux.org/title/Dm-crypt
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.