Ubuntu Server 16.04.1 LTS and /var/tmp

ubuntu-16.04

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.

Best Answer

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

Related Topic