/tmp directory filled up on a machine at work. The problem was, it was on the root partition which wasn't very big. In order to fix this, a co-worker created a
/new/tmp directory elsewhere, copied all the contents to the new directory, removed the original
/tmp and made a symlink
/tmp -> /new/tmp.
When he copied the files (really, this was somebody else, not me!) he didn't use
-a so the owner of every file under
root. Furthermore, he didn't set the permissions of the
/new/tmp directory so it was the default 0755. This caused no end of trouble and even tweaking mode and ownership bits failed to restore the machine to an acceptably working state. I ended up having to nuke everything in
/tmp and reboot.
/tmp directory contained various sockets and pipes and whatnot, since a bunch of people run Gnome through VNC, and I use
screen which has its own pipes.
Is there a safe way to move a
/tmp directory to a different volume on a running system? I'm not sure what I would have actually done to keep everything working. I'm particularly curious about what happens to pipes and sockets.
tmpfolder in a live, running system by doing
mv /tmp /tmp.bakand rsyncing
/tmpto the new destination, and then symlinking
/tmpto the new destination. Everything kept running smoothly, existing tmp files kept being accessed (from what I could tell) and new tmp files started being created in
/tmp(which symlinks to the new volume/destination). The plan is to delete
/tmp.bakafter rebooting the server during a proper maintenance window.