Set up an encrypted container or encrypt entire volume.

Create container

# dd if=/dev/urandom of=/home/user/container.file bs=1M count=500

# losetup /dev/loop0 /home/user/container.file

# cryptsetup -c aes-cbc-essiv:sha256 -y -s256 luksFormat /dev/loop0

During the last command you need to set a password for your container. Note that!

Open container

# cryptsetup luksOpen /dev/loop0 container.file.decrypted

Enter the password noted above.

Create filesystem

# mkfs.ext4 /dev/mapper/container.file.decrypted

Use container

After creating the container, decrypting it and creating a filesystem, we cam mount that decrypted filesystem:

mount /dev/mapper/container.file.decrypted /home/user/crypt

Now copy stuff to the mountpoint and unmount it again:

umount /dev/mapper/container.file.decrypted

Close decryption:

cryptsetup luksClose container.file.decrypted

Encrypt entire volume

Leave a Reply