Best way to mount /tmp in fstab?

46

The default is just a directory in the root filesystem.

That's fine but I have a desktop, a ton of RAM and reboot very infrequently... Which is the perfect description of somebody who could be using RAM instead of SSD for caching temporary stuff... So mine is mounted as a tmpfs RAMdisk, defined in fstab as:

tmpfs    /tmp    tmpfs    defaults,noatime,mode=1777   0  0

If you power cycle lots, this obviously isn't going to be a good idea for you.

You asked on another —now deleted— answer what the two zeroes were on the end, that's handled by another answer but they basically mean the system doesn't care about what happens to this filesystem if things crash. It won't dump out or check it for errors on boot.

noatime is just there as a tiny performance thing. Nothing I know of needs to audit access times of /tmp so I don't bother storing them. There's nothing inherently dangerous about allowing SUID, exec or character devices in /tmp and some things might need them.

In terms of security, while anything can write into /tmp it doesn't mean anything can overwrite or even read existing files. If you have a go-rw permission file, other people won't be able to mess around with it. The various systems that write into /tmp already do things to make sure that they're not clashing over filenames (typically by appending the $USER variable to the filename).

Share:
46

Related videos on Youtube

user10777718
Author by

user10777718

Updated on September 18, 2022

Comments

  • user10777718
    user10777718 over 1 year

    I created a new Dynamic Web Project in Eclipse and did nothing more.

    Now I do the initial commit.

    The following files can be committed:

    enter image description here

    I feel that none of these files are needed in Git - am I right?

    And how to prevent these files from appearing again in this menu window.

    • howlger
      howlger about 5 years
      .gitignore have to be shared, MANIFEST.MF is part of your project and the rest are project specific Eclipse settings. Using project specific settings but not sharing them does not make sense to me.
  • DanJGer
    DanJGer over 7 years
    in Ubuntu 14.04+ tmpreaper manpages.ubuntu.com/manpages/wily/man8/tmpreaper.8.html is used by default to clean up /tmp and uses atime to determine age so you would want to update the settings to use ctime if you want it to clean files over time.
  • howlger
    howlger about 5 years
    The folder(s) containing generated (in Eclipse called derived) files are automatically added to .gitignore (this is why there is the file .gitignore). Only project specific settings to share are stored in the project. Not sharing these files means you have different settings/configuration on different computer, e.g. different settings for the formatter, etc.
  • jo_
    jo_ about 5 years
    Yes .gitignore should be in version control
  • madhead
    madhead about 2 years
    Well, I made that answer based on my expirience. Editing /etc/fstab didn't work for me on 20.04, but I found a mention of tmp.mount here. So, for me tmp.mount systemd unit was the right place, not the /etc/fstab.
  • madhead
    madhead about 2 years
    One more link about tmp.mount: wiki.archlinux.org/title/tmpfs#Disable_automatic_mount. Although it's for Arch Wiki, it is still about systemd specifics.