Generated image
|| #resource #security #luks

Encrypted LUKS Container

Create an encrypted volume on linux using LUKS

Problem

This page describes how to create an encrypted container on a #linux system using LUKS.

*This is not the same as on-the-fly encryption

Solution

The only software required for this process is cryptsetup. It can be installed with apt:

apt install cryptsetup

All the following commands should be run as root

  1. Create file
fallocate -l 25G /enc

Change the size of the file as necessary. This will determine the available drive space when mounted.

  1. Create LUKS container
cryptsetup luksFormat /enc

Follow the prompts in the command line - including the passphrase to unlock the container.

  1. Setup filesystem
cryptsetup luksOpen /enc enc
mkfs.ext4 /dev/mapper/enc

Once the container has been setup, the root user can mount it with the following commands.

  1. Open container
cryptsetup luksOpen /enc enc

You will be prompted for the passphrase used when creating the volume.

  1. Mount container
mount /dev/mapper/enc /data

Details


Maybe try another one?

Count Files in Folder Count the number of files in a folder using the terminal
2022.10.03
Go: Graceful Shutdown Handling OS signals and shutting down gracefully
2022.02.22
Resisting the urge to automate too soon
2024.08.09