/tmp and /var/tmp in Ubuntu

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Wed May 21 14:29:18 UTC 2025


Hello Nick,

Mounting /tmp as tmpfs makes sense on systems that are not very memory
constrained. I have been using this for the last years on all my systems.

I am wondering which mount option shall be used. I have tended to mount
with nosuid,nodev. But there are some rare use cases, e.g. with chroots
where this runs into issues.

Best regards

Heinrich


On Wed, May 21, 2025 at 4:20 PM Nick Rosbrook <nick.rosbrook at canonical.com>
wrote:

> Hi,
>
> ### Background
>
> In the 24.10 cycle, Ubuntu began defaulting to /tmp as a tmpfs
> (interestingly, Ubuntu was poised to do this many releases ago[1], but
> apparently did not go through with it at the time), and /var/tmp being
> cleaned up on a timer. This was done at the same time as Debian[2],
> and aligns both Debian and Ubuntu with upstream systemd. To summarize
> the changes:
>
> 1. /tmp became a tmpfs, with a cleanup age of 10d. Just like before,
> /tmp is cleaned on reboot, and a cleanup time is enforced to remove
> old/unused files. The primary difference is that instead of being a
> directory on the rootfs, /tmp is its own tmpfs with default size of
> 50% RAM.
> 2. /var/tmp gained a cleanup age of 30d. /var/tmp is still part of the
> rootfs, and is not cleaned on reboot.
> 3. Unlike Debian, we did not introduce a transitional
> /etc/systemd/tmpfiles.d/tmp.conf on upgrades. This is due to Ubuntu's
> stated goal to have consistency between upgraded and newly-installed
> systems.
>
> These changes are easy for a user/administrator to modify/override.
>
> $ systemctl mask tmp.mount
>
> or
>
> $ touch /etc/systemd/system/tmp.mount
>
> will prevent /tmp from being a tmpfs. And,
>
> $ echo 'D /tmp 1777 root root 30d' > /etc/tmpfiles.d/tmp.conf
>
> will restore the 24.04 LTS defaults for /tmp and /var/tmp cleanup ages
> (the 30d cleanup age is relatively recent in Ubuntu[3]). See [4][5]
> for comprehensive documentation on the configuration options.
>
> ### What now?
>
> Overall, there has been little push back to this change. Mostly, I
> have seen some expected complaints related to /tmp vs. /var/tmp usage.
> However, I have heard enough anecdotes (conversations, DMs, etc.) from
> Ubuntu developers that I thought it was worth bringing this up on
> ubuntu-devel now. My questions are:
>
> 1. Does anyone have a strong reason for changing these defaults? This
> would mean diverging from Debian and upstream.
> 2. Should we have a different transition plan for upgrades? In
> particular for 24.04 LTS to 26.04 LTS?
>
> Please keep in mind these are only defaults. As explained above, they
> can be easily modified for special cases.
>
> Thanks,
> Nick
>
> [1] https://ubuntu.com/blog/data-driven-analysis-tmp-on-tmpfs
> [2]
> https://lwn.net/ml/debian-devel/ebee234c6f72eb7dfe55809821c038491bfea542.camel@debian.org/
> [3] https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2019026
> [4]
> https://www.freedesktop.org/software/systemd/man/latest/tmpfiles.d.html
> [5]
> https://www.freedesktop.org/software/systemd/man/latest/systemd.mount.html
>
> --
> ubuntu-devel mailing list
> ubuntu-devel at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-devel/attachments/20250521/79a99e28/attachment.html>


More information about the ubuntu-devel mailing list