1

I want a ramdisk on linux.

There is ramfs and tmpfs.

Tmpfs is what I want because it acts like a disk (size limits, etc.). However, it uses swap which means it may touch disk if it gets full.

IF I don't have swap turned on, will it still work?

I don't want that mount to touch disk at all.

4

Tmpfs will still work without swap, since it just uses the normal Linux memory allocator. Do not worry, it won't create swap for you out of nothing just because it doesn't have it.

  • i suspected as much, but I wanted to hear from someone who actually did it. we'll verify it in house. – drudru Nov 8 '11 at 22:44
  • However, if swap is on, it will possibly use it. I need something else. – drudru Aug 11 '13 at 22:29
1

You can use ramfs which is similar to tmpfs but should never touch disk. I'd still recommend tmpfs because it has more features and:

  • If you have no swap partition or swap file, neither will touch the disk.
  • If you have a swap partition data on ramfs will not touch the disk, but a process reading or writing that data could be swapped to disk.
  • 1
    "If you have a swap partition data on tmpfs will not touch the disk, " - maybe was so, however on Linux Mint 19 I was able to write data amounting to 150% of total RAM to tmpfs, watching SWAP grow in the process. – Alexei Martianov Sep 26 '18 at 11:54
  • 1
    @AlexeiMartianov That was a typo. Corrected. – kasperd Sep 26 '18 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.