Lounge Started Jul 28, 2026 12:41 PM

Linux Tip: Storing Data in RAM Using ramfs and tmpfs

0 replies - 8 views - 1 thanks - 1 tippers - 1 watchers

Jul 28, 2026 12:41 PM Last edited Jul 28, 2026 12:42 PM
#1

Did you know can easily mount a filesystem that will store any data exclusively in RAM? Sometimes, you don't want to store data on your disk, such as keyfiles, notes, documents, media content, and other data. There's no need to launch a live distro just for the sake of storing data in memory, when you can just mount a tmpfs or ramfs filesystem.

It's simple:

sudo mount -t ramfs --mkdir <mount_point>

sudo mount -t tmpfs --mkdir -o <mount_point>

For example:

sudo mount -t ramfs --mkdir myramvol /mnt/ram

Now, any data stored in /mnt/ram will be stored in memory.

If your CPU does not support memory encryption, you can still encrypt the data by creating a LUKS volume within the /mnt/ram directory.

sudo fallocate -l 1G /mnt/ram/crypto
sudo cryptsetup luksFormat --type luks2 /mnt/ram/crypto
sudo cryptsetup open /mnt/ram/crypto ramcrypto
sudo mkfs.ext4 /dev/mapper/ramcrypto
sudo mount /dev/mapper/ramcrypto /mnt/encrypted_ram

You can use a generated password, since the encrypted volume is going to get wiped when you shut down anyway. Point is, you now have an encrypted LUKS volume stored in memory and you can rest safely the data is kept only temporarily and is encrypted just in case.

Even better, create a quick shell script and bind it all to a simple command. Another idea is to overlay mount it to ~/Downloads. All downloads are now stored in memory.

1 thanks - 1 tippers - 1 watchers

Replies

Page 1 of 1 - 0 total

No replies yet. Be the first to reply.

Post A Reply

You must be logged in to reply. Login or register.