A few hours ago i reinstalled my server with Ubuntu Server 16.04.1 LTS. As part of my regular setup process, i delete /var/tmp and set up a symlink to /tmp which is on its own partition with nodev,nosuid,noexec.

The problem is, /var/tmp will not delete. I keep getting told:

rm: cannot remove '/var/tmp': Device or resource busy

I even tried logging in via cd based rescue mode and doing the delete and symlink there (mounting the partition first). It seems to work, but when i reboot the system - i see that /var/tmp was recreated.

Is there something new in Ubuntu Server 16.04.1 that creates a new /var/tmp folder on every boot up? If so, where is it?

P.S. Server has soft raid too.

| improve this question | | | | |
  • 1
    It's called systemd. Before you continue your old practices, you should take a moment to learn what it's doing and why. – Michael Hampton Aug 9 '16 at 4:00
  • Ah, sorry about that. I didnt realize things changed so drastically with the new release. I found this bugs.archlinux.org/task/31301 and it describes what would happen if i did manage to get the directory deleted and replaced with a symlink. Is this issue still the case (systemd wont work with a symlink)? – Ruok2bu Aug 9 '16 at 18:18
  • Ubuntu was the last distro to adopt systemd. The rest of us have had years of experience with it. You're having trouble because systemd expects to be able to create mount namespaces within /tmp and /var/tmp, (this is a security feature) and this breaks down if one of them is symlinked. There may also be other reasons I can't remember right now. Anyway, unless you're explicitly storing very large files in /tmp there's probably no reason to remount it to its own partition. – Michael Hampton Aug 9 '16 at 18:23
  • Ah, i see. Many thanks for the information Michael. I'll be forgoing symlinking /var/tmp as part of my setup. – Ruok2bu Aug 9 '16 at 18:58

There is a reason for these being different directories.

  • /var/tmp is intended for temp files that need to live trough a reboot
  • /var/run is intended for files that specifically should not be around anymore after a reboot (e.g. .pid files)
  • /tmp can be cleaned at almost any moment, it typically does not live trough a reboot, and can be 'tmpfs'

Programs that rely on these assumptions may behave weirdly when /var/tmp is cleaned all of a sudden. So you shouldn't just symlink it to /tmp

| improve this answer | | | | |

If you get this error from sudo rm -rf /var/tmp it means that you are trying to delete a mount point.

| improve this answer | | | | |
  • 1
    Not exactly, it means it's in use. Mounting a subtree to a directory is one way to lock a directory, but it is definitely not the only way. – Spooler Mar 12 '19 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.