Skip to contentSkip to conversation

Can LUKS be used on a tmpfs?

dm-crypt H McCurdy 4 participants 4 messages Dec 23, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 1738110781.2276602.1450897552997.JavaMail.yahoo.ref@mail.yahoo.com

H McCurdy

author
#1 lore raw

Hi,
Is it possible to get crypt_init() to use a tmpfs instead of a block device or a file?
I realize there are sanity issues related to such an inquiry because the key is in RAM and so is the "disk."  Regardless, I have the question. BTW, an older ramdisk (/dev/ram0) does appear to work.
Hugh

#2 lore raw

On 23 Dec 2015 19:05 +0000, from [email protected] (H McCurdy):

Quoted 2 lines

Is it possible to get crypt_init() to use a tmpfs instead of a block device or a file?

Not sure exactly what you are looking to do, but you can't put a tmpfs on any storage-backed device. You could however create a temporary (likely sparse) file, store that file in a tmpfs, and create a LUKS container within that file, with a normal file system inside the container which you can use to store data.

Would be quite a lot of overhead, though. And you need to be root to mount a tmpfs in the first place, unless you set it up in fstab with a "user" directive, which would sort of defeat the point.

Isn't it easier to just set appropriate permissions on a tmpfs (or even ramfs, which would prevent ever writing the data to disk)? You'd get pretty much the same results, minus virtually all the overhead...

Signature · 3 lines
Michael Kjörling • https://michael.kjorling.se • [email protected]
                 “People who think they know everything really annoy
                 those of us who know we don’t.” (Bjarne Stroustrup)
#3 lore raw
In reply to H McCurdy

Simply short: No.

tmpfs is, as the name suggests, a filesystem, which lives in the VFS domain, whereas dmcrypt lives in the block layer.

So yes, ramdisks in the form of blockdevices will work. It might even possibly work on a file within the tmpfs. (Give is a try [there's still loopback devices..], afterall it's all volatile memory and fiddling around does not need any extra work)

Regards

-Sven

Am 23.12.2015 um 20:05 schrieb H McCurdy:

Quoted 18 lines

Hi,

Is it possible to get crypt_init() to use a tmpfs instead of a block device or a file?

I realize there are sanity issues related to such an inquiry because the key is in RAM and so is the "disk." Regardless, I have the question.

BTW, an older ramdisk (/dev/ram0) does appear to work.

Hugh

_______________________________________________
dm-crypt mailing list
[email protected]
http://www.saout.de/mailman/listinfo/dm-crypt

#4 lore raw
In reply to H McCurdy
Quoted 4 lines · H McCurdy

Hi,

Is it possible to get crypt_init() to use a tmpfs instead of a block device or a file?

No, dm-crypt works only over block devices (/dev/ram* are block devices as well).

You can create a file on tmpfs and use that through loopback though (but this adds another layer there).

Milan