You are not logged in.

#1 2021-10-30 11:17:36

leonixyz
Member
Registered: 2014-07-12
Posts: 64

Encrypted file to be mounted as a filesystem that grows with content

Most of my stuff does not need to be stored encrypted. For some other, like personal documents, i would like to.

I'm looking for a way to create a plain file on my unencrypted ext4 partition, and then be able to mount that file as encrypted filesystem.

The file should be password protected and auto-grow with its content.

What can I use? What do you think I should consider? Do you have any kind of suggestion/consideration?
Thanks in advance

Maybe I can explain myself better by making some examples:

$ ls -l ./encrypted_storage.diskfile
[... regular file .... size 10 MB......]

$ mount -t ??? ./encrypted_storage.diskfile ./encrypted_storage/
[... type your password: XXXXXXX ...]

$ cp /path/to/personal_document.txt ./encrypted_storage/

$ umount ./encrypted_storage/

$ ls -l ./encrypted_storage.diskfile
[.... size 12 MB......]

Last edited by leonixyz (2021-10-30 11:19:36)

Offline

#2 2021-10-30 12:18:14

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,243

Re: Encrypted file to be mounted as a filesystem that grows with content

Google for "dm-crypt sparse file", see eg. https://serverfault.com/questions/69655 … -with-luks

Edit: the arch wiki has entries on dm-crypt, container encryption and sparse files, but afaics not on their combo.

Last edited by seth (2021-10-30 12:18:56)

Offline

#3 2021-10-30 14:51:48

leonixyz
Member
Registered: 2014-07-12
Posts: 64

Re: Encrypted file to be mounted as a filesystem that grows with content

alright thank you,....

it seems that dm-crypt on top of a sparse file works just fine... which is cool!

However, from what I read there is only one drawback: when you delete files from the encrypted storage, the size does not shrink. It's only able to grow in size with the content, not to shrink.

After some more research I found additional tools that might suite my needs as well:

- fscrypt: https://wiki.archlinux.org/title/Fscrypt
- EncFS: https://wiki.archlinux.org/title/EncFS
- eCryptFS: https://wiki.archlinux.org/title/ECryptfs

I chose fscrypt because it seems robust and easy enough to use.

None of these tools satisfy my initial requirements, but they were stated before knowing what alternatives there are available.

So called "stacked filesystem encryption" seems just enough for my needs.

Thanks

Offline

Board footer

Powered by FluxBB