1 XMR = $620.09

Please login

Region:

Current view: Threads | Classic
Sort by: Tips | New

Linux Tip: Storing Data in RAM Using ramfs and tmpfs

yuzuki Donor - Supporter
N/A (0)
Posts: 46
Earned: 0.1 XMR
Tipped: 0 XMR
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

sudo mount -t tmpfs --mkdir -o

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.
Tip Monero to yuzuki
QR Code 86GEJPxGRCyYBzQC18xTq1hzv2z2Trpu2RLwcLsgmQEw8itpca2eXknCuoBXo8jw5pevfcwNiHkGf4S257nDG4wLEZuYRXd
Publish Tip to yuzuki

Please login to publish your tip

TernLatch
N/A (0)
Posts: 20
Earned: 0 XMR
Tipped: 0 XMR
Reply to post #1798
One privacy gotcha: tmpfs is not necessarily RAM-only. Its pages can go to swap; the kernel docs say swap is enabled by default. Where supported, the noswap mount option disables swapping for that tmpfs mount, while size sets a capacity limit.

ramfs avoids swap but has no configurable filesystem size cap, so sending every download there can exhaust memory. "Temporary" and "never touches a disk" are different promises; these mount options aren't a whole-system no-disk guarantee.

Kernel docs, including the swap default and ramfs distinction:
https://docs.kernel.org/filesystems/tmpfs.html
Tip Monero to TernLatch
QR Code 82qthWSHLyDVqod56v7BVdQS81Ag7ruqrVr1fqULrdj2Sf2eHuPtf3AgmaxsX9h5aDLHE9e7f8GsR3pp46Wp5bh3NjPfggf
Publish Tip to TernLatch

Please login to publish your tip

babyboi098 Donor - Supporter
5 (11)
Posts: 41
Earned: 0 XMR
Tipped: 0 XMR
oh hey, didnt know kikuri was still around, cool. do u have a link to this info in your KB?
Tip Monero to babyboi098
QR Code 86Kyc9zP3jzAuf27MqkkdiVjXkyGozBMRRr3LAtSjj1wG4soG7WSNEnNcfLTzEB22rY29BhF8rEZ3cD6hs3eFfU3FPFGFDT
Publish Tip to babyboi098

Please login to publish your tip

Page:
1
You must login in order to publish a post