Saturday 10 October 2015

Linux, Elementary and the problem with temp files

One legacy of more than fifteen years using Linux is complacency.  some of us are so used to Linux being pretty well bulletproof that we forget it has changed.  And it has grown.  I fall for this all the time.  A root file system of a grew hundred megabytes used to be plenty.  Later as Linux distributions grew I started making root about two, then four gigabytes.  Over the last few years I installed into root partitions of fourteen and twenty gigabytes.  Now I find my Elementary OS Freya is taking all but three and a half of the fourteen gigabytes allocated to root.

This was not much of an issue in the past, but with NBN in Australia we have significantly increased our ability to move data around.  And as someone who likes playing with operating systems and graphics, not to mention editing video, I end up with large files in my /tmp directory.  This creates fairly regular warnings that my hard disk is low on space.

As an example, just now I decided to pull in a 1.6GB iso.  It wants to transit /tmp on the way to its eventual destination.  And there is only about 2GB space in /root.  Next time there's a major release of Elementary I will probably reformat my hard drive and allocate about 30GB to root.  For now though the simplest option is to make more room in /tmp.

Luckily in Linux the problem is relatively easy to solve.  First I need to redirect all saves to /root/tmp to my home directory.   So first I make a new /tmp under /home/user.   Then I send all 'current' tmp stuff there.  This applies to operations after Linux has actually booted.  There will be some files still going to /root/tmp, but most of them will be zero bytes in size.

Opening my text editor as root I can edit the environment file.

$  sudo kate /etc/environment          And on a new line enter the following:

TEMP=/home/user/tmp

Then save the file and reboot the computer.   whatever text editor you use can be substituted for kate.  gedit, kwrite, vi, whatever is in use at the moment.

Something to be aware of though is that things like lock files for the word processor and other functions will also be redirected to this /home/user/tmp directory.  So it is easy to kill stuff that shouldn't be 'made dead'.   If that is a concern, make the tmp directory hidden by putting a dot in front of it.  But remember to make the environment path read    TEMP=/home/user/.tmp      so the system can find it.




No comments:

Post a Comment