Mounted LUKS file turns into plaintext directory

Multi tool use


Mounted LUKS file turns into plaintext directory
I followed the CentOS instructions to create a Linux Encrypted Filesystem with dm-crypt.
This results in what appears to be an encrypted file mounted as a file system, when I checked losetup -l
, mount -l
and cryptsetup status secretfs
, everything looked as would be expected.
losetup -l
mount -l
cryptsetup status secretfs
After restarting the computer, and without issuing any commands to losetup
, cryptsetup
and mount
, the mounted (before restart) encrypted file (secretfs
mounted at /mnt/secretfs
) has turned into a normal plaintext folder, all files that existed in the mounted encrypted file, are readable at /mnt/secretfs
without having to open the encrypted file and mount it.
losetup
cryptsetup
mount
secretfs
/mnt/secretfs
/mnt/secretfs
This was unexpected and appears to make mounting an encrypted file insecure, I would appreciate any guidance to ensure that mounting an encrypted file always requries the passphrase to view it's contents and those contents are not copied to an unencrypted location.
Script
#!/bin/bash
set -e
# encrypted disk
dd of=secretfs bs=20G count=0 seek=8
chmod 600 secretfs
losetup /dev/loop0 secretfs
cryptsetup -y luksFormat /dev/loop0
cryptsetup luksOpen /dev/loop0 secretfs
cryptsetup status secretfs
mke2fs -j -O dir_index /dev/mapper/secretfs
tune2fs -l /dev/mapper/secretfs
mkdir /mnt/secretfs
mount /dev/mapper/secretfs /mnt/secretfs
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.