[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Idea: mount /tmp to tmpfs depending on free space and RAM

2012/5/28 Roger Leigh wrote:

> The primary cause of problems is simply that the tmpfs /tmp isn't big
> enough. [...] what guarantees are offered by the system in terms of
> minimum and maximum available space on /tmp? [...] Consider the default:
> /tmp is on the rootfs (which [...] may have lots of free space or very
> little). [...] consider tmpfs mounted on /tmp: the size specifies the
> total available space.

Well, technically, we already guarantee that. The option TMP_OVERFLOW_LIMIT
does. It mounts /tmp to tmpfs if there's too few free space there. But we
can make it better.

  mount /tmp to tmpfs only when amount of free space in /tmp is fewer
  than amount of RAM.

Technical details:
0. fstab is already processed and /tmp was (or was not) mounted to a
   separate partition.
1. init-script cleans it (since it must clean it anyway)
2. and then compares `df /tmp/` with amount of RAM available.
3. If amount of RAM is larger it mounts /tmp to tmpfs
4. otherwise leaves /tmp as it is.

This way we can guarantee that there will be as much space in /tmp as
possible but *at least* as much as the amount of RAM available.

Looks reasonable? Will that suit everyone?

IMHO: this option should not break anything (and may even fix something)
so it can be enabled by default. But it MUST be possible to disable it for
those rare cases when admin intentionally left /tmp on a small partition.


Reply to: