Results 1 to 2 of 2

Thread: What's the story on "/tmp".

  1. #1
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,503
    Blog Entries
    3

    Default What's the story on "/tmp".

    I recently did a new Tumbleweed install (20151118). Today, I added a line to "/etc/fstab" to mount a tmpfs file system as "/tmp". I then rebooted, so that it would be mounted. I did not want to mount while running, because that would interfere with processes currently using "/tmp" (such as my Xwindows session).

    On reboot, the mount "tmpfs" file system for "/tmp" came up nicely.

    I then tried looking underneath the mount point, so that I could delete what was left over from the prior "/tmp". To my surprise, there was nothing there. Is systemd now cleaning the "/tmp" directory in the root file system before mounting?

    After that, I checked another Tumbleweed system, also running 20151118. On that system, I do not have a "tmpfs" mounted "/tmp". But I do have "/etc/tmpfiles.d/tmp.conf" which is supposed to delete everything in "/tmp" at startup.

    To my surprise, "/tmp" on that system contains some directories and file with a date of November 5. That is older than the last boot. So it looks as if the temp files are not being cleaned up on startup as they should be.

    Presumably, this is all from the "systemd" people. Can anyone fill me in on what is actually going on?
    openSUSE Leap 15.1; KDE Plasma 5;
    testing Leap 15.2Alpha

  2. #2

    Exclamation Re: What's the story on "/tmp".

    hi,
    i have the same problem.
    and i think i found the source.
    it is the file /usr/lib/systemd/system/tmp.mount and /usr/lib/systemd/system/systemd-tmpfiles-clean.timer which control this behaviour.
    in KDE systemsettings5 there is a systemd module/section where you can control the systemd services.
    one of them is tmp.mount and systemd-tmpfiles-clean.timer.

    this is the contents of file /usr/lib/systemd/system/tmp.mount (without comments):

    Code:
    [Unit]
    Description=Temporary Directory
    Documentation=man:hier(7)
    Documentation=http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
    ConditionPathIsSymbolicLink=!/tmp
    DefaultDependencies=no
    Conflicts=umount.target
    Before=local-fs.target umount.target
    
    [Mount]
    What=tmpfs
    Where=/tmp
    Type=tmpfs
    Options=mode=1777,strictatime
    i think this is responsible for automatically mounting tmpfs on /tmp, so no need for a /etc/fstab entry.
    and then there is /usr/lib/systemd/system/systemd-tmpfiles-clean.service and /usr/lib/systemd/system/systemd-tmpfiles-clean.timer with this content:

    Code:
    [Unit]
    Description=Cleanup of Temporary Directories
    Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
    DefaultDependencies=no
    Conflicts=shutdown.target
    After=local-fs.target time-sync.target
    Before=shutdown.target
    
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/systemd-tmpfiles --clean
    IOSchedulingClass=idle

    Code:
    [Unit]
    Description=Daily Cleanup of Temporary Directories
    Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
    
    [Timer]
    OnBootSec=15min
    OnUnitActiveSec=1d
    and this is responsible for auto cleaning /tmp once a day.
    all of them were active on my system.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •