LUKS stands for Linux Unified Key Setup. It’s the standard disk-encryption system on Linux, used to protect data at rest by encrypting entire disks or partitions.
A loop device is a virtual block device in Linux that lets you treat a regular file as if it were a disk or partition.
The idea is using blockfile as disk and use LUKS to protect the disk content
Create file that use as LUKS encrypt disk
Open the encrypted disk for usage and close it
The process has two main steps
- one time create the disk
- open mount / umount close
- create the encrypt disk
- open it
- format
- mount
- add files
- umount
- add key
- Usage
- Open and Mount
- Umount and close
Step1
One time step that contain the following steps
- create block file using dd
- run as a disk using loop device
sudolosetup--find--show~/secure.img
# the command return the device loop to use# /dev/loop3
3️⃣ Create the encrypt disk
- Initializes the device as a LUKS encrypted container
- Writes a LUKS header to the device
- Erases any existing filesystem or data references
sudocryptsetupluksFormat/dev/loop3
# WARNING!# ========# This will overwrite data on /dev/loop3 irrevocably.# # Are you sure? (Type 'yes' in capital letters): YES# Enter passphrase for /home/user/secure.img: # Verify passphrase:
#Unlock a LUKS-encrypted block device and expose it as a new decrypted virtual device named secure_container.# before /dev/loop3 are encryptedsudocryptsetupopen/dev/loop3secure_container
## the decrypt file open into /dev/mapper/secure_container
sudocryptsetupopen--typeluks\secure.imgsecure_container\--key-filekeyfile.bin
# open the encrypt to /dev/mapper/secure_container# mount sudomount/dev/mapper/secure_container/mnt