2

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.

drudru
  • 123
  • 1
  • 5

2 Answers2

5

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.

sysadmin1138
  • 133,124
  • 18
  • 176
  • 300
2

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.
kasperd
  • 30,455
  • 17
  • 76
  • 124
  • 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. – Alex Martian Sep 26 '18 at 11:54
  • 1
    @AlexeiMartianov That was a typo. Corrected. – kasperd Sep 26 '18 at 12:14