In this tutorial we will see how to create and use an encrypted archive with cryptsetup. This might be useful if you keep personal data on a movable device (for example a USB stick), which might be lost or accessed by unauthorized people. In this case they won't be able to look at your personal data without knowing the password.
Encrypted Archive with Cryptsetup
Create the archive
Make sure that
apt list cryptsetup
apt install cryptsetup
Create an image file for the archive:
fallocate -l 15G archive1.img
However, to make sure that the created file has random data, you can use a command like this (which is slower):
dd if=/dev/urandom of=archive1.img bs=10M count=100
This would increase the encryption strength, since an attacker can't distinguish the part of the archive that is free from the part that has encrypted data.
Create a loop device for this image file:
losetup -f archive1.img
losetup -a | grep archive1.img
lsblk | grep loop