7

I'm looking for a way to have a tmpfs-like file system that can be unlimited in size, but will use a specified amount of RAM after which the "oversize" data will be stored on another disk-backed filesystem

tmpfs

I'm running on a SSD-only system, with low available space (usually < 3 GB), so I don't want to reserve any space for SWAP or similar (that's my main requirement)

Do you know of any solution that would fit my use-case ?

6
  • 1
    The functionality you desire is already the default behaviour. Linux automatically caches files in RAM for you. Maybe you should describe your use case in more detail. Apr 22, 2016 at 22:32
  • If Linux already does this then why do some distros use the tmpfs file system for /tmp/? I'm assuming Linux's default cache behavior is designed for persistent files and won't handle this use case that well Jan 11, 2022 at 20:48
  • @HeathMitchell tmpfs is used to help writes: no reason to waste SSD wear (or tie up HDD writing) on a temporary file. It also probably makes it likely to stay in RAM for longer (although it still could get swapped to disk). Jul 20, 2022 at 21:22
  • As far as a use-case: I have 32GB of RAM, most of which is unused most of the time. I can not max out my download speed when writing to my SSD. I can, and would like to, max out my download speed when writing to RAM. (This would also avoid unnecessary wear and trims.) However, not all files will be <32GB, and I won't always have enough RAM available either. (In either case, the file must be copied to HDD after being downloaded - usually also extracted etc - so the fact that a tmpfs has no persistence has only upsides). But, since when does SO require a use case? The question is clear. Jul 20, 2022 at 21:27
  • In my humble opinion, you want a disk backed filesystem with well tuned caching.
    – peterh
    Feb 28 at 22:14

1 Answer 1

0

I don't know of any filesystem that matches your request. FWIW, decades ago, back when memory was more scarce, I recall that some Unix variants had a tmpfs filesystem that used spinning disk space but prioritized speed over recoverability.

You can get closer to what you're looking for in one of two ways. First, use a tmpfs filesystem and replace your overflow area with equivalent extra swap space. Note that swap space doesn't have to be provided by a partition.

The other half measure would be to use ext4 or another filesystem and set tunables such as min_batch_time and max_batch_time to outrageous values.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .