On Mon, 26 Jul 2021 23:19:09 +0300, Nicholas Guriev wrote:
>However in general, /tmp is not intended to have important data which
>is worth regretting.

Let alone that tmp could be mounted as tmpfs, see
https://en.wikipedia.org/wiki/Tmpfs . However, even if it's not a
tmpfs, a systemd unit might clean /tmp, for Ubuntu see
https://askubuntu.com/questions/20783/how-is-the-tmp-directory-cleaned-up
.

Disabling or masking related systemd units should work.

An example from my Arch Linux install. It's not mounted by fstab, but
by a systemd unit.

[rocketmouse@archlinux ~]$ df -h | grep tmpfs
tmpfs           3.9G   31M  3.9G   1% /dev/shm
tmpfs           3.9G  1.9M  3.9G   1% /tmp
tmpfs           786M  104K  785M   1% /run/user/1000
[rocketmouse@archlinux ~]$ cat /etc/fstab | grep tmp
#tmpfs          /tmp            tmpfs nodev,nosuid,size=3G     0 0
[rocketmouse@archlinux ~]$ systemctl status tmp.mount 
● tmp.mount - Temporary Directory /tmp
     Loaded: loaded (/proc/self/mountinfo; static)
     Active: active (mounted) since Sat 2021-07-03 21:09:58 CEST; 3 weeks 2 
days ago
      Where: /tmp
       What: tmpfs
       Docs: https://systemd.io/TEMPORARY_DIRECTORIES
             man:file-hierarchy(7)
             https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
      Tasks: 0 (limit: 9398)
     Memory: 32.0K
        CPU: 1ms
     CGroup: /system.slice/tmp.mount

Jul 03 21:09:58 archlinux systemd[1]: Mounting Temporary Directory (/tmp)...
Jul 03 21:09:58 archlinux systemd[1]: Mounted Temporary Directory (/tmp).
[rocketmouse@archlinux ~]$ systemctl status systemd-tmpfiles-clean
○ systemd-tmpfiles-clean.service - Cleanup of Temporary Directories
     Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-clean.service; 
static)
     Active: inactive (dead) since Mon 2021-07-26 21:35:55 CEST; 1h 47min ago
TriggeredBy: ● systemd-tmpfiles-clean.timer
       Docs: man:tmpfiles.d(5)
             man:systemd-tmpfiles(8)
    Process: 1018193 ExecStart=systemd-tmpfiles --clean (code=exited, 
status=0/SUCCESS)
   Main PID: 1018193 (code=exited, status=0/SUCCESS)
        CPU: 65ms

Jul 26 21:35:55 archlinux systemd[1]: Starting Cleanup of Temporary 
Directories...
Jul 26 21:35:55 archlinux systemd[1]: systemd-tmpfiles-clean.service: 
Deactivated successfully.
Jul 26 21:35:55 archlinux systemd[1]: Finished Cleanup of Temporary Directories.
[rocketmouse@archlinux ~]$ systemctl status systemd-tmpfiles-clean.timer 
● systemd-tmpfiles-clean.timer - Daily Cleanup of Temporary Directories
     Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-clean.timer; 
static)
     Active: active (waiting) since Sat 2021-07-03 21:09:58 CEST; 3 weeks 2 
days ago
    Trigger: Tue 2021-07-27 21:35:55 CEST; 22h left
   Triggers: ● systemd-tmpfiles-clean.service
       Docs: man:tmpfiles.d(5)
             man:systemd-tmpfiles(8)

Jul 03 21:09:58 archlinux systemd[1]: Started Daily Cleanup of Temporary 
Directories.
[rocketmouse@archlinux ~]$ man systemctl | grep " mask UNIT" -A4
       mask UNIT...
           Mask one or more units, as specified on the command line. This will 
link these unit files to /dev/null, making it impossible to start them. This is 
a stronger version of
           disable, since it prohibits all kinds of activation of the unit, 
including enablement and manual activation. Use this option with care. This 
honors the --runtime option to
           only mask temporarily until the next reboot of the system. The --now 
option may be used to ensure that the units are also stopped. This command 
expects valid unit names only,
           it does not accept unit file paths

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss

Reply via email to