systemd /tmp cleaning is suboptimal

Bug #2019026 reported by Steve Langasek
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
New
Wishlist
Unassigned

Bug Description

Historically on Debian and Ubuntu, before systemd, the default handling of /tmp was to periodically, and at boot, remove all files/directories older than 30 days; and leave other contents alone.

With the move to systemd, the "default" (really, hard-coded in /usr/lib/tmpfiles.d/tmp.conf) is to not clean /tmp periodically, but at boot to remove all contents.

This is suboptimal for two reasons.

By cleaning /tmp *only* at boot, if a system makes heavy use of /tmp and has lots of inodes under it, possibly due to failures of some process to clean up after itself, at boot the system will be unavailable for an unnecessarily long time while these files are removed.

By cleaning *all* files under /tmp, this makes a reboot an Event where in-progress files may be unnecessarily lost.

While the FHS does not *guarantee* that files under /tmp will persist across boot (because /tmp may be a tmpfs), it also does not *require* that /tmp be cleared on boot.

   Although data stored in /tmp may be deleted in a site-specific
   manner, it is recommended that files and directories located in
   /tmp be deleted whenever the system is booted.

   FHS added this recommendation on the basis of historical
   precedent and common practice, but did not make it a
   requirement because system administration is not within the
   scope of this standard.

I therefore believe the correct value for /usr/lib/tmpfiles.d/tmp.conf to restore past behavior is 'd /tmp 1777 root root 30d'.

Revision history for this message
Nick Rosbrook (enr0n) wrote :

I personally have become very accustomed to the current behavior where /tmp is emptied on reboot -- I have no idea what most users would say about this, so I wonder if changing that behavior would be unwelcome. I do think it could be nice to have the 30d behavior back, however.

In other words, if we did change this I think my preference would be:

 D /tmp 1777 root root 30d

so that we still always clear on boot, but also after 30d if needed.

On the other hand, this feels like it might be something that most people don't care about, and those that do are welcome to change their local system.

Changed in systemd (Ubuntu):
status: New → Incomplete
importance: Undecided → Wishlist
Revision history for this message
Steve Langasek (vorlon) wrote :

The reason it's specifically important to me not to clean at boot is that schroot bind mounts /tmp by default but does not bind mount /var/tmp by default, so I am accustomed (since long before the systemd behavior became the norm) to using this directory for sharing data between the host system and chroots and relying on it persisting across reboots (since it's not old). (And I don't use /home because it's stuff I *do* want garbage-collected for me - just not at reboot!)

When you say you've "become very accustomed to the current behavior where /tmp is emptied on reboot" - how would it impact you if it was NOT cleaned at reboot?

Revision history for this message
Steve Langasek (vorlon) wrote :

(setting bug back to New because I don't see any request for information)

Changed in systemd (Ubuntu):
status: Incomplete → New
Revision history for this message
Nick Rosbrook (enr0n) wrote :

> how would it impact you if it was NOT cleaned at reboot?

I just like it. It's easier for me to keep track in my head that "oh, this file in /tmp will only be around until I reboot", as opposed to trying to keep track of the actual age of a file. To be clear, I am not suggesting that my use case is strong argument for keeping the current default (I will happily write an /etc/tmpfiles.d/tmp.conf drop-in to meet my preference if needed). Just pointing out that there might be a range of preferences on the default handling of /tmp.

Also, you may have already come across this, but if not, this is the Debian bug that resulted in the current default: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=675422.

If you think it would be best for most Ubuntu users to change the current default, then we should go with your suggested change. If the motivation is mostly about your schroot use case, then I would suggest either modifying schroot to do what you need, or using /etc/tmpfiles.d/tmp.conf.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.